Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Getting document metadata within custom annotation's draw method

55 views
Skip to first unread message

Aleks Clark

unread,
Jun 23, 2014, 12:39:13 PM6/23/14
to pdfnet-w...@googlegroups.com
Greetings, 

I'm working on a method of including image annotations in XOD/XFDF, and need to access some data about the document (id, etc) from within the draw method of the custom annotation, in order to set an image url. How can I do this?

Thanks,


Aleks

Matt Parizeau

unread,
Jun 23, 2014, 9:14:05 PM6/23/14
to pdfnet-w...@googlegroups.com
Hi Aleks,

You could access the document id through readerControl.doc_id and if you wanted to get the Document object you could use readerControl.docViewer.GetDocument()

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Aleks Clark

unread,
Jun 23, 2014, 10:58:00 PM6/23/14
to pdfnet-w...@googlegroups.com
Hey Matt,

Yea, I got that figured out which solves the immediate problem, but I would like a more general way of passing data from the instantiating javascript into custom viewer code, (annotations, buttons, etc).I mean I guess I could urlencode EVERYTHING into the ID string but that seems a bit clunky :)

Matt Parizeau

unread,
Jun 24, 2014, 12:54:00 PM6/24/14
to pdfnet-w...@googlegroups.com
Hi Aleks,

You can take a look at the WebViewer Developer Guide on page 13 under the section "Pass Custom Data through WebViewer". Under the hood it's basically doing what you're saying, URL encoding/decoding for you.

Maybe you could use the custom parameter to pass URLs to where the annotation or button data is stored and then load them dynamically (e.g. with $.get).

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