Articles in this section
Category / Section

How to load a PDF document from URL into PDF Viewer from client-side

3 mins read

PDF viewer do not have support to load the PDF document from the URL directly. However, you can load the PDF document by converting the URL to base64 string using the client-side load() API in the sample level.

Refer to the following code snippet. 

          var staticUrl = 'http://www.syncfusion.com/downloads/support/directtrac/general/pd/HTTP_Succinctly-1719682472';
            var xhr = new XMLHttpRequest();
            xhr.open('GET', staticUrl, true);
            xhr.responseType = 'blob';
            xhr.onload = function(e) {
                if (this.status == 200) {
                    var myBlob = this.response;
                    var reader = new window.FileReader();
                  //read the blob data
                    reader.readAsDataURL(myBlob);
                    reader.onloadend = function () {
                        base64data = reader.result; 
                        var pdfviewerObject = $('#PdfViewer').data('ejPdfViewer');
                      //load the base64 string
                        pdfviewerObject.load(base64data);
                    }
                }
            };
            xhr.send();

 

Sample link:  

http://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample2003119113

 

Executing the previously given sample will provide the output as follows.

 

 

You can find the PDF Viewer’s other options like adding Toolbar Customization, TextMarkup annotation, and Handwritten Signature features here with code examples.

Refer here to explore the rich set of PDF Viewer features. 

An online demo link to view PDF documents using Syncfusion PDF Viewer.

See Also: 

https://www.syncfusion.com/jquery/aspnet-web-forms-ui-controls/pdf-viewer

https://www.syncfusion.com/jquery/javascript-ui-controls/pdf-viewer

https://www.syncfusion.com/uwp-ui-controls/pdf-viewer

https://www.syncfusion.com/winforms-ui-controls/pdf-viewer

https://www.syncfusion.com/wpf-ui-controls/pdf-viewer

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied