Load pdf from external/ other place , Annotations

634 views
Skip to first unread message

Dipak Dendage

unread,
Jan 18, 2016, 11:37:55 AM1/18/16
to PDFTron WebViewer
Hi,

I have downloaded sample PDFTron project and if I include
initial( initialDoc: "Booking.pdf" ) document from my local( machine ) then it's working fine,

But when I am trying to load PDF/XOD file from another location let's assume from server then it give me network failure error.

I referred https://www.pdftron.com/webviewer/demo/tutorials/getting-started-annotations.html but not able to solve my problem.

Here is my code
$(function() {
var viewerElement = document.getElementById("viewer");
var myWebViewer = new PDFTron.WebViewer({
path: "lib",
type: "html5",
documentType: "pdf",
initialDoc: "demo.pdf",
serverUrl: "https://www.server.url/demo.pdf",
documentId: "1",
enableAnnotations: true,
}, viewerElement);
});

I tried with multiple ways like removed serverUrl and put whole URL in initial DOC but not able to solve problem.

Please help me to get out from this stuck.

Matt Bojey

unread,
Jan 18, 2016, 11:48:43 AM1/18/16
to PDFTron WebViewer
Hi,

Your serverUrl should be pointing to a PHP file that will serve the annotations for the document.  To get the actual document you need to make sure that the path to the document is relative to your HTML file, as described here https://www.pdftron.com/webviewer/demo/tutorials/getting-started.html Are your documents on the same server as the WebViewer?  If not, this may be helpful https://www.pdftron.com/webviewer/demo/tutorials/xdomain.html

Matt

Dipak Dendage

unread,
Jan 19, 2016, 11:40:51 AM1/19/16
to PDFTron WebViewer
Thanks Matt, 

I have to call web service for getting PDF file, web-service build in .Net. Previously PDF directly shows in browser but now client want to show pdf files in PDFTron.  

I tried with multiple ways but not able to find out proper solution.
Could you please help me what actual parameter needs in webviewer constructor required ? 
 
Thanks.

Matt Bojey

unread,
Jan 19, 2016, 1:51:02 PM1/19/16
to PDFTron WebViewer
Hi,

Can you show me a screenshot of your console (F12)?  What error are you seeing in the network tab?  It might be an issue with CORS not being enabled on your server, you can see how to deal with that here http://enable-cors.org/

Matt

vanc

unread,
Nov 29, 2017, 11:55:33 AM11/29/17
to PDFTron WebViewer
Hi Matt,

Could you post some sample code to show how files can be loaded from local http server. If no annotations are required to be loaded, can we skip the serverUrl option.

Matt Parizeau

unread,
Nov 29, 2017, 7:05:02 PM11/29/17
to PDFTron WebViewer
Yes, if no annotations are required you can skip serverUrl. Loading from a local http server just make sure that both your html file and initialDoc can be accessed from the server and then make the path of the initialDoc relative to the html file. Loading the html from your file system and the document from a local server will likely run into problems.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages