How to Display an Uploaded PDF using Javascript?

Hello,


I am using both Uploader and PDFViewer in a solution. The user chooses the PDF file and uploads it to the database using the Uploader control. Up to this part, everything is fine. And I also got the "actionComplete" event working on Javascript to see the success of the upload. But from this point forward I was not able to find out how to display the uploaded PDF file in the PDFViewer after the "actionComplete" event.


I would appreciate any help in the subject.


Regards,


Alexandre


4 Replies 1 reply marked as answer

VS Vasugi Sivajothi Syncfusion Team September 8, 2021 04:07 PM UTC

Hi Alexandre, 
 
Thank you for contacting Syncfusion support. 
 
You can load the document from the document path or base64string in the client-side using the load API. We have shared the code snippet and sample for your reference which can be downloaded from the below link.   
 
Code snippet: 
 
<button type="button" onclick="loadFromPath()">LoadDocumentFromPath</button> 
<button type="button" onclick="loadFromBase()">LoadDocumentFromBase</button> 
 
function loadFromPath() { 
        var viewer = document.getElementById('pdfViewer').ej2_instances[0]; 
        viewer.load("FormFillingDocument.pdf"); 
    } 
    function loadFromBase() { 
        var viewer = document.getElementById('pdfViewer').ej2_instances[0]; 
        viewer.load("data:application/pdf;base64,JVBE…”, null); 
} 
 
 
 
 
 
 
 
Kindly try this and revert to us with more details if you have any concerns about this. 
 
Regards, 
Vasugi. 


Marked as answer

AL Alexandre September 10, 2021 03:17 PM UTC

Hello,


Thanks for the support! I got it working here, and now the PDF is displayed at the PDFViewer after beeing uploaded to the database. It works just fine at my development machine, but when I test it at the production server I got a "Server Error" and the PDF is not displayed.


Should I change any settings before deploying?


Regards,


Alexandre 



AL Alexandre replied to Alexandre September 11, 2021 08:40 AM UTC

Hello,


I just solved the issue with the help of other posts in the forum. I was just a matter of adding folder permissions for the app in the production server.


Regards,


Alexandre



SM Selvakumar Murugan Syncfusion Team September 13, 2021 08:27 AM UTC

Hi Alexandre,  

Thank you for the update. We are glad to know that the issue was resolved. Please revert to us if you need any further assistance. 

Regards,
Selvakumar 


Loader.
Up arrow icon