Parsing / Saving Annotations from XFDF string

373 views
Skip to first unread message

Support

unread,
Apr 11, 2013, 8:55:37 PM4/11/13
to pdfne...@googlegroups.com
Q:

You currently support creating and loading annotations embedded within a PDF FIle. However, we are storing annotations separately from our PDF files and "side-loading" them when needed. The question is, does the PDFTron API support parsing from these raw bytes. I have included some sample data below to illustrate the data we are working with.

<</Type/Annot/Subtype/Ink /F 4 /Rect [63.433685 486.696930 339.155182 612.355408] /C [0.121000 0.3
50
000 1.000000] /BS <</W 3.000000>> /InkList [[154.217514 573.489258 ... ] ] /M(D:20130329233951+00'00)>>
-------
A:

 

Recently we made changes to FDFDoc.SaveAsXFDF() method so that the string parameter it takes can be either the filepath or the XML string buffer that contains the XFDF itself. Similarly there is a method to load from a file or a string (if the string is not a path). This will be included as part of the next official release (the unoffical build already include new methods).

         /**
          * Convert FDF file to and from XFDF file
          * @param filepath - string containing either the XFDF file name or the xml buffer containing the XFDF
          * @return A new TRN_FDFDoc.
          */
         static FDFDoc CreateFromXFDF( const UString& filepath );

         /**
          * Export FDF file as an XFDF file
          * @param filepath - the filepath of the exported XFDF file
          */
         void SaveAsXFDF( const UString& filepath );

         /**
          * Export FDF file as a XFDF string
          * @return A UString containing the XFDF representation of the FDF file
          */
         UString SaveAsXFDF();

Support

unread,
Apr 11, 2013, 8:56:33 PM4/11/13
to pdfne...@googlegroups.com
Q:
 

With a PDF document already loaded and displayed in PDFTron, we would like to be able to dynamically add annotations created sometime after document load.  

In our case, the annotation is persisted to a server as a string of text conforming to the PDF spec, so our hope is that we can leverage existing PDFTron file parsing code even though the PDF will already be fully loaded.  The sequence would be:

1)  We load a PDF file in the usual way

2)  Sometime later we receive a message containing an annotation as a text string conforming to the PDF spec

3)  We call some PDFTron API with the annotation represented as a text buffer

4)  The annotation appears overlaid on the file loaded in step 1

From your response, I'm assuming that an XFDF acts as a kind of container for form elements, such as annotations, and that in my step #3 above, we would call your new API method: CreateFromXFDF() passing in the text buffer.  Is this correct?  If so, I see that it returns an FDFDoc.  Is there some additional step to associate this FDFDoc with the originally loaded PDF?

------------
A:
 

Yes, you can use PDFDoc.FDFMerge and FDFExtract and shown in FDF sample project: 
   http://www.pdftron.com/pdfnet/samplecode.html#FDF
Reply all
Reply to author
Forward
0 new messages