简体   繁体   中英

How to import an XFDF into an PDF with Apache pdfbox 2.0

In pdfbox 1.8 there was a class "ImportXFDF", as you can see here: pdfbox API 1.8.11 for ImportXFDF . It was very easy to import the data from an XFDF File into the PDF fields with the importFDF-Method.

With the new version 2.0 the class was removed, and I can't find where the functionality is now (I hope it was not dropped?). pdfbox API 2.0.1 The Migration Guide on the website doesn't tell anything about this function.

Anyone knows how to import an XFDF into an PDF file now? Thanks for your help!

Okay, I checked out the original implementation of ImportXFDF which is very small and copied it into my code:

public void importFDF(PDDocument pdfDocument, FDFDocument fdfDocument) throws IOException
{
  PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
  PDAcroForm acroForm = docCatalog.getAcroForm();
  acroForm.setCacheFields(true);
  acroForm.importFDF(fdfDocument);
}

Works very well with the 2.0 version :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM