[ https://issues.apache.org/jira/browse/PDFBOX-5878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17880141#comment-17880141 ]
Michael Klink edited comment on PDFBOX-5878 at 9/8/24 2:01 PM: --------------------------------------------------------------- As an aside: The document has set *NeedAppearances* to *true*, so regenerating the appearances for flattening would be appropriate here whether there are any issues in the PDF or not. Furthermore, when (re-)creating form field appearances, one should always create from scratch. The only exception may be if one has analyzed the existing appearance contents and has made sure that one has removed all old field contents from it and also that there is nothing in it that moves the to-be-drawn new content out of the bbox or otherwise obscures it. Else this might be a variation of one of the well-known www.pdf-insecurity.org attacks. But I think it in general is really hard to tell whether some "rectangles and such" are drawn as part of a specific style or as an forgery attempt. Thus, I'd really propose to always re-create from scratch. was (Author: mkl): As an aside: The document has set *NeedAppearances* to *true*, so regenerating the appearances for flattening would be appropriate here whether there are any issues in the PDF or not. Furthermore, when (re-)creating form field appearances, one should always create from scratch. The only exception may be if one has analyzed the existing appearance contents and has made sure that one has removed all old field contents from it and also that there is nothing in it that moves the to-be-drawn new content out of the bbox or otherwise obscure it. Else this might be a variation of one of the well-known www.pdf-insecurity.org attacks. But I think it in general is really hard to tell whether some "rectangles and such" are drawn as part of a specific style or as an forgery attempt. Thus, I'd really propose to always re-create from scratch. > pdf form field text gets blurred after flattening > ------------------------------------------------- > > Key: PDFBOX-5878 > URL: https://issues.apache.org/jira/browse/PDFBOX-5878 > Project: PDFBox > Issue Type: Bug > Components: AcroForm > Affects Versions: 2.0.28, 3.0.3 PDFBox > Environment: Mac Ventura, java 18 PDFBox 3.0.3, Tomcat 9 > Linux; version: 5.15.0-105-generic, java 17, Tomcat 9.0.93 > Reporter: Joseph Jezerinac > Priority: Major > Labels: Appearance > Attachments: Bildschirmfoto vom 2024-09-05 10-07-13.png, > PDFBox5878-flattened.pdf, PDFBox5878-saved.pdf, beforeFlattening.pdf, > flattened.pdf > > > After flattening a pdf acro form, value of some fields get blurred > {code:java} > PDDocument pdDocument = Loader.loadPDF(inFile, ""); > pdDocument.setResourceCache(new DefaultResourceCache()); > try { > boolean save = false; > if (pdDocument.isEncrypted()) { > pdDocument.setAllSecurityToBeRemoved(true); > save = true; > } > final PDDocumentCatalog pdDocumentCatalog = > pdDocument.getDocumentCatalog(); > if (pdDocumentCatalog != null) { > final PDAcroForm pdForm = pdDocumentCatalog.getAcroForm(); > if (pdForm != null) { > pdForm.flatten(); > save = true; > } > } > if (save) { > pdDocument.save(outFile); > } > } > catch (Exception e) {} > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org