How to show annotations in web viewer if we have multiple annotation data server urls

216 views
Skip to first unread message

Pawan Kumar

unread,
Jul 18, 2016, 12:51:59 PM7/18/16
to PDFTron WebViewer
Hi Team,

I am trying to integrate web viewer(PDFNETJS) in my existing solution where we have a parent document which can have multiple annotation related objects on server side. On UI I can load parent document with single annotation data easily by using below code snippet. 
Case 1: Parent document object has related one annotation object on server side
serverURL: http://localhost//mysampleapp/11/1/xfdfcontent
MFWA.WebViewer = new PDFTron.WebViewer( {
				type: "html5, Silverlight, flash",
				initialDoc: pdfDocUrl, // This url will fetch parent document data in application/pdf
				path: 'js/PreviewPane/lib/',
				enableAnnotations: true,
				documentType: "pdf",
				serverUrl: serverURL // This is returning annotation data (xfdf) related with parent document in application/xml form
}, pdfObj );

In above case parent document is loading properly along with single annotation object data in web viewer

Case 2: Parent document object can have 2 or many annotation objects on server side
serverURL: 
http://localhost//mysampleapp/12/1/xfdfcontent (return first related annotation object data for parent doc)
http://localhost//mysampleapp/12/2/xfdfcontent (return fsecond related annotation object data for parent doc)

MFWA.WebViewer = new PDFTron.WebViewer( {
				type: "html5, Silverlight, flash",
				initialDoc: pdfDocUrl, //This url will fetch parent document data in application/pdf
				path: 'js/PreviewPane/lib/',
				enableAnnotations: true,
				documentType: "pdf",
				serverUrl: // What to pass here because it can load data of single annotation object once 
}, pdfObj );

In above case parent document can have 2 or more annotation objects related to that parent object which need to be loaded in web viewer. Suppose 1st annotation object can be square and 2nd can be ellipse. 

So in this case I am not able to understand that how it need to be handled on client side as we are using PDFNetJs. Can you please suggest that if we need to load annotation data(xfdf) from multiple server calls in single document then what approach we need to follow?

Regards,
Pawan

Matt Parizeau

unread,
Jul 20, 2016, 6:08:44 PM7/20/16
to PDFTron WebViewer
Hi Pawan,

Is there a reason why each server URL returns only one annotation? Our example annotationHandler.php returns the entire XFDF file which contains all annotations so you only need to have one server URL and import annotations once.

If you store the annotations separately on your server we would recommend that the server URL will combine all of the individual annotation XFDF information into a single XFDF document that can be returned to WebViewer. It is definitely possible to load each of the annotations individually but this will be slower as you may have to make many network calls to get all the information.

Let me know if that makes sense and if you have any further questions about it!

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