Hello all, we're experiencing a problem with PDFs generated/modified with PDFBox.
What we do is merging annotations in XFDF format to existing documents, save them and then deliver them to our users. This works, aside from the occasionally missing appearance stream, pretty well. Recently, one user pointed out some problems with the "Summarize Comments" function in the print dialog of Adobe Reader DC. Whenever he tries to use this function on documents containing annotations we merged into it, Adobe Reader only produces a "too much recursion" error. I created a sample PDF from scratch with PDFBox 2.0.21 which shows this behaviour too : https://www.dropbox.com/s/zvgw4qx53pwa286/demo_merged.pdf?dl=1 To reproduce: - download the PDF - open it in Adobe Reader DC - open the print dialog (ctrl-P) - click "Summarize Contents" - confirm with "Yes" The code for this PDF is at the end of the email. So, is there anything I can do with my merge code to make these PDFs more palatable for this function of Adobe Reader ? If not, is this a structural problem created by PDFBox or something Adobe must look into ? Thanks in advance, Kai Keggenhoff -- kai.keggenh...@thinkproject.com import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.fdf.FDFAnnotation; import org.apache.pdfbox.pdmodel.fdf.FDFDocument; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; import javax.xml.parsers.DocumentBuilderFactory; import org.xml.sax.InputSource; import java.io.StringReader; import java.util.List; public class MergeTest { public static void main(String args[]) { String xfdf = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xfdf xmlns=\"http://ns.adobe.com/xfdf/\" xml:space=\"preserve\"" + "><annots" + "><freetext color=\"#FFFFFF\" creationdate=\"D:20180924102518+02'00'\" flags=\"print\" date=\"D:20180924102537+02'00'\" page=\"0\" rect=\"17.382233,685.894287,121.675568,758.765869\" subject=\"Textfeld\" title=\"keggenhoff\"" + "><contents-richtext" + "><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:18.11.0\" xfa:spec=\"2.0.2\" style=\"font-size:12.0pt;text-align:left;color:#FF0000;font-weight:normal;font-style:normal;font-family:Helvetica,sans-serif;font-stretch:normal\"" + "><p dir=\"ltr\"" + ">P1 <span style=\"text-decoration:word;font-family:Helvetica\"" + ">P2</span" + "> P3</p" + "></body" + "></contents-richtext" + "><defaultappearance" + ">0.898 0.1333 0.2157 rg /Helv 12 Tf</defaultappearance" + "><defaultstyle" + ">font: Helvetica,sans-serif 12.0pt; text-align:left; color:#E52237 </defaultstyle" + "></freetext" + "></annots" + "><f href=\"/C/Users/KEGGEN~1/AppData/Local/Temp/demo.pdf\"" + "/><fields" + "><field name=\"submit\"" + "/></fields" + "><ids original=\"F285D06ECA30C5579E72B6B7AE07BC0B\" modified=\"1A190CB840919E279B93BF3D5D488C13\"" + "/></xfdf" + ">"; createPdf("demo_merged.pdf", xfdf); } private static void createPdf(String filename, String xfdf) { try { org.w3c.dom.Document xfdf_doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xfdf))); FDFDocument fdf_doc = new FDFDocument(xfdf_doc); PDPage page = new PDPage(); List<FDFAnnotation> xfdfAnnotations = fdf_doc.getCatalog().getFDF().getAnnotations(); for (FDFAnnotation xfdfAnnotation : xfdfAnnotations) { PDAnnotation a = PDAnnotation.createAnnotation(xfdfAnnotation.getCOSObject()); page.getAnnotations().add(a); } PDDocument pdf = new PDDocument(); pdf.addPage(page); pdf.save(filename); } catch (Exception e) { e.printStackTrace(); } } }