2

I need to both analyze and generate PDF annotations based on FDF exports. I'd much prefer working with XFDF data and standard XML technology, but annotations are not exportable as XFDF by Foxit Reader, which happens to be the most convenient tool for the specific PDF marking task.

Is there anything that can convert between FDF and XFDF? I didn't see any functionality related to XFDF in the iText documentation.

Thomas W
  • 14,757
  • 6
  • 48
  • 67
  • The comments created by the Foxit PDF products are not 100% interoperable with other PDF viewers so your analysis of the FDF it produces will be off. Instead, use the free Acrobat Reader DC which can export comments to XFDF directly and you won't need to translate formats. – joelgeraci Apr 28 '17 at 14:23
  • @joelgeraci So far, I had no problems with exchanging comments between Adobe Reader and Foxit and back. What precisely isn't interoperable? In any case, Adobe Reader isn't well suited for our task, which is marking up partly really large documents with tons of lines. With Foxit, I can comfortably draw 3 lines a second with a graphics tablet. In Adobe Reader I have to re-select the line tool after every line. I'd rather write a converter myself than accept defeat ;-). – Thomas W Apr 28 '17 at 14:43
  • Ok - got it. Yes - the UX for some of the commenting tools in Reader does need work. The interoperability issues are more around appearance generation than the actual properties which makes annotations appear to jump or otherwise reformat when modified in other editors. – joelgeraci Apr 28 '17 at 15:06
  • You might find the Adobe FDF toolkit (Google it) useful to parse the FDF and then your favorite XML tool for the export. I still recommend using Adobe Reader for exporting *examples* of XFDF so you can write your own translator. – joelgeraci Apr 28 '17 at 15:08
  • @joelgeraci Thanks for that hint. Do you have experience with the FDF toolkit? I don't really see anything that would help me a lot with annotations. It's very focused on forms. As FDF uses PostScript syntax, I consider writing a PostScript program that will extract the information for me. – Thomas W Apr 28 '17 at 15:50
  • Ack! I forgot that the FDF Toolkit only handled form field annotations. It's been years since I touched it. FDF doesn't use PostScript syntax, it's a variant of PDF syntax. Writing a parser library will be more tedious than difficult but once you have a parser, converting to XFDF and back, though easy, would be sort of a waste of computation. – joelgeraci Apr 28 '17 at 16:17
  • I wonder whether XSLT could be used for the conversion. – Max Wyss Apr 28 '17 at 17:16
  • @MaxWyss: I've quite a lot of XSLT experience, but from FDF to XFDF - no way. The other way round: Of course! – Thomas W Apr 30 '17 at 17:18
  • @joelgeraci: Of course FDF uses PDF syntax, but PDF in turn is sort of a strict version of PostScript (syntax wise - the comands are different, of course). I had some initial success with FDF and Ghostscript but hoped I could avoid that dirty route. Should I achieve something useful, I'll put it on GitHub and add my own answer here. – Thomas W Apr 30 '17 at 17:27
  • One idea would be to import the FDF back into the original PDF (assuming you have it) and then use something to export it to XFDF. You can do this in bulk with a little bit of programming. I have not come across an APi that will just conver from FDF to XFDF, I do work for a company (Datalogics) that has a Java SDK that supports importing/exporting with FDF and XFDF, it might be overkill for what you are lookng to do unless you have 100s or more of these to do though. – Brandon Haugen May 02 '17 at 19:13

1 Answers1

1

I wrote a little PostScript program I called fdf2xfdf that does just enough so that I can work with it. PostScript isn't precisely the nicest language to work with, but it does an excellent job at parsing the FDF out of the box.

Thomas W
  • 14,757
  • 6
  • 48
  • 67