You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2020/10/26 21:43:49 UTC
svn commit: r1882892 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
Author: msahyoun
Date: Mon Oct 26 21:43:48 2020
New Revision: 1882892
URL: http://svn.apache.org/viewvc?rev=1882892&view=rev
Log:
PDFBOX-4985: reset the cached AcroForm when first called with getAcroForm(true)
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java?rev=1882892&r1=1882891&r2=1882892&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java Mon Oct 26 21:43:48 2020
@@ -60,6 +60,7 @@ public class PDDocumentCatalog implement
private final COSDictionary root;
private final PDDocument document;
+ private boolean hasAcroFormFixesApplied;
private PDAcroForm cachedAcroForm;
/**
@@ -114,14 +115,23 @@ public class PDDocumentCatalog implement
* Get the documents AcroForm. This will return null if no AcroForm is part of the document.
*
* Depent on setting <code>applyFixes</code> some fixing/changes will be done to the AcroForm
- * as documented in {@link org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm#PDAcroForm(PDDocument, COSDictionary, boolean)}. If you need
- * to ensure that there are no fixes applied call <code>applyFixes</code> with <code>false</code>
+ * as documented in {@link org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm#PDAcroForm(PDDocument, COSDictionary, boolean)}.
+ * If you need to ensure that there are no fixes applied call <code>applyFixes</code> with <code>false</code>
*
* @param applyFixes applies fixes
* @return The document's AcroForm.
*/
public PDAcroForm getAcroForm(boolean applyFixes)
{
+ if (!hasAcroFormFixesApplied && applyFixes)
+ {
+ cachedAcroForm = null;
+ hasAcroFormFixesApplied = true;
+ }
+ else if (hasAcroFormFixesApplied && !applyFixes)
+ {
+ LOG.warn("AcroForm content has already been retrieved with applyFixes set to true - original content changed because of that");
+ }
if (cachedAcroForm == null)
{
COSDictionary dict = (COSDictionary)root.getDictionaryObject(COSName.ACRO_FORM);