Custom import/export of annotations

133 views
Skip to first unread message

Len Charest

unread,
Jul 29, 2014, 9:20:53 PM7/29/14
to pdfne...@googlegroups.com
I am researching how to integrate the HTML5 WebViewer with a web service for annotations. The annotations service is a custom service developed in-house. It is based on OData (http://www.odata.org/) and its default wire format is JSON.

From an engineering perspective, the cleanest approach to this integration would be to augment the AnnotationManager with custom import/export functions specific to the needs of our service. E.g., AnnotationManager.prototype.ImportAnnotationsCustom = function (jsonPayload) { ... }

My question is: how difficult would this be? Export seems relatively straightforward; we can get the current set of annotations from the manager and serialize each as JSON. Import seems like it might be more challenging. Based on my comparison of an in-memory annotation and its XFDF serialization, it feels like there is some not insignificant deserialization logic inside the black box. For example, there seem to be many undocumented properties on an in-memory annotation that have no direct mapping from the XFDF.

All comments/advice/direction much appreciated.

Thanks,
Len

Ryan

unread,
Jul 30, 2014, 5:27:01 PM7/30/14
to pdfne...@googlegroups.com
Hi Len,

If you can avoid it, I would not modify/extend the AnnotationManager, in this case. Instead I would recommend working with XFDF, and doing the XFDF to/from OData conversion outside of webviewer.

The XFDF spec is open, and we do follow it, with a few extensions, but these don't break XFDF compatbility. For example, we support Widget annotations, which are the visual aspect of PDF fields. We also add a <defmtx> entry, which maps the coordinate system of the XFDF annotations, into XPS coordinate system (which has a flipped y, and a different default dpi then PDF). You can ignore both of these in your conversions. The Xod file itself contains its own defmtx entries, so those will be used if none are found in the XFDF file.

If you are only dealing with certain annotations (such as text highlights) then you would not need to write a full XFDF/OData converter, and just worry about those particular entries.

If the above information doesn't help, then feel free to explain in more detail what you are doing (you can also contact support in this case, instead of this forum).

Also, note that there is a separate WebViewer forum. I will cross post this conversation there.
https://groups.google.com/forum/#!forum/pdfnet-webviewer

Len Charest

unread,
Jul 30, 2014, 5:49:42 PM7/30/14
to pdfne...@googlegroups.com
I did not know about the WebViewer forum. Thanks for the heads-up. I will continue the conversation there.
Reply all
Reply to author
Forward
0 new messages