I would like to merge all data from an XFDF string (which I receive from Pdftron's Webviewer) to an existing PDF.
The only way I found so far is to read the XFDF from a file, like this:
FDFDoc fdfDoc = FDFDoc.createFromXFDF("/path/to/file.xfdf");
pdfDoc = new PDFDoc(document);
pdfDoc.fdfMerge(fdfDoc);
pdfDoc.flattenAnnotations(false);
I do not want to save the XFDF - which I already have in memory - to a temporary file, just to load it back into memory a little later.
Is there a way to read the data of the XFDF string (into an FDFDoc) directly from the String itself or a Stream?
I tried to use one the FDFDoc constructors, but to no avail. With
new FDFDoc(new FileInputStream("/path/to/file.xfdf"
)) I am getting the following Exception:
Message: Header not found
Conditional expression: false
Filename : Parser.cpp
Function : trn::SDF::Parser::SkipHeader
Linenumber : 759
Error code : 0
at pdftron.FDF.FDFDoc.FDFDocCreate(Native Method)
at pdftron.FDF.FDFDoc.<init>(FDFDoc.java:59)
So appearantly FDFDoc-Constructors are not for XFDF data.
Any help is appreciated. Thank you.