aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java12
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFDocumentHandler.java5
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFPainter.java1
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java2
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java6
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java5
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingContext.java9
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java1
-rw-r--r--fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java6
-rw-r--r--fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java6
10 files changed, 52 insertions, 1 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
index 2e13e7015..b63039812 100644
--- a/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
+++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFDocument.java
@@ -176,6 +176,8 @@ public class PDFDocument {
private boolean mergeFontsEnabled;
+ private boolean mergeFormFieldsEnabled;
+
private boolean linearizationEnabled;
private boolean formXObjectEnabled;
@@ -432,7 +434,7 @@ public class PDFDocument {
* @param obj {@link PDFObject} to add
* @return the added {@link PDFObject} added (with its object number set)
*/
- <T extends PDFObject> T registerTrailerObject(T obj) {
+ public <T extends PDFObject> T registerTrailerObject(T obj) {
assignObjectNumber(obj);
addTrailerObject(obj);
return obj;
@@ -1187,6 +1189,14 @@ public class PDFDocument {
}
}
+ public boolean isMergeFormFieldsEnabled() {
+ return mergeFormFieldsEnabled;
+ }
+
+ public void setMergeFormFieldsEnabled(boolean mergeFormFieldsEnabled) {
+ this.mergeFormFieldsEnabled = mergeFormFieldsEnabled;
+ }
+
private interface TrailerOutputHelper {
void outputStructureTreeElements(OutputStream stream) throws IOException;
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
index 5e3ab010e..02c532c1c 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFDocumentHandler.java
@@ -97,6 +97,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
private final PDFDocumentNavigationHandler documentNavigationHandler
= new PDFDocumentNavigationHandler(this);
+ private Map<String, Object> usedFieldNames = new HashMap<>();
private Map<Integer, PDFArray> pageNumbers = new HashMap<Integer, PDFArray>();
private Map<String, PDFReference> contents = new HashMap<String, PDFReference>();
@@ -377,6 +378,10 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
return structureTreeBuilder;
}
+ public Map<String, Object> getUsedFieldNames() {
+ return usedFieldNames;
+ }
+
public Map<Integer, PDFArray> getPageNumbers() {
return pageNumbers;
}
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFPainter.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFPainter.java
index cebd083a8..5478f4490 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFPainter.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFPainter.java
@@ -245,6 +245,7 @@ public class PDFPainter extends AbstractIFPainter<PDFDocumentHandler> {
PDFRenderingContext pdfContext = new PDFRenderingContext(
getUserAgent(), generator, getDocumentHandler().getCurrentPage(), getFontInfo());
pdfContext.setMarkedContentInfo(imageMCI);
+ pdfContext.setUsedFieldNames(getDocumentHandler().getUsedFieldNames());
pdfContext.setPageNumbers(getDocumentHandler().getPageNumbers());
pdfContext.setPdfLogicalStructureHandler(logicalStructureHandler);
pdfContext.setCurrentSessionStructElem((PDFStructElem) getContext().getStructureTreeElement());
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
index 28111ceed..e71072bfe 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererConfig.java
@@ -60,6 +60,7 @@ import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
import static org.apache.fop.render.pdf.PDFRendererOption.FORM_XOBJECT;
import static org.apache.fop.render.pdf.PDFRendererOption.LINEARIZATION;
import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FONTS;
+import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FORM_FIELDS;
import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
import static org.apache.fop.render.pdf.PDFRendererOption.PDF_UA_MODE;
@@ -150,6 +151,7 @@ public final class PDFRendererConfig implements RendererConfig {
parseAndPut(OUTPUT_PROFILE, cfg);
parseAndPut(DISABLE_SRGB_COLORSPACE, cfg);
parseAndPut(MERGE_FONTS, cfg);
+ parseAndPut(MERGE_FORM_FIELDS, cfg);
parseAndPut(LINEARIZATION, cfg);
parseAndPut(FORM_XOBJECT, cfg);
parseAndPut(VERSION, cfg);
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
index 677256fe4..97834ed2a 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOption.java
@@ -87,6 +87,12 @@ public enum PDFRendererOption implements RendererConfigOption {
return Boolean.valueOf(value);
}
},
+ MERGE_FORM_FIELDS("merge-form-fields", false) {
+ @Override
+ Boolean deserialize(String value) {
+ return Boolean.valueOf(value);
+ }
+ },
LINEARIZATION("linearization", false) {
@Override
Boolean deserialize(String value) {
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
index 02cc9f57d..0360782ef 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRendererOptionsConfig.java
@@ -36,6 +36,7 @@ import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
import static org.apache.fop.render.pdf.PDFRendererOption.FORM_XOBJECT;
import static org.apache.fop.render.pdf.PDFRendererOption.LINEARIZATION;
import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FONTS;
+import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FORM_FIELDS;
import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
import static org.apache.fop.render.pdf.PDFRendererOption.PDF_UA_MODE;
@@ -140,6 +141,10 @@ public final class PDFRendererOptionsConfig {
return (Boolean)properties.get(MERGE_FONTS);
}
+ public Boolean getMergeFormFieldsEnabled() {
+ return (Boolean)properties.get(MERGE_FORM_FIELDS);
+ }
+
public Boolean getLinearizationEnabled() {
return (Boolean)properties.get(LINEARIZATION);
}
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingContext.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingContext.java
index b99bcdbfe..8a38d002b 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingContext.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingContext.java
@@ -40,6 +40,7 @@ public class PDFRenderingContext extends AbstractRenderingContext {
private FontInfo fontInfo;
private PDFPage page;
private MarkedContentInfo mci;
+ private Map<String, Object> usedFieldNames;
private Map<Integer, PDFArray> pageNumbers;
private PDFLogicalStructureHandler pdfLogicalStructureHandler;
private PDFStructElem currentSessionStructElem;
@@ -96,6 +97,14 @@ public class PDFRenderingContext extends AbstractRenderingContext {
return mci;
}
+ public Map<String, Object> getUsedFieldNames() {
+ return usedFieldNames;
+ }
+
+ public void setUsedFieldNames(Map<String, Object> usedFieldNames) {
+ this.usedFieldNames = usedFieldNames;
+ }
+
public Map<Integer, PDFArray> getPageNumbers() {
return pageNumbers;
}
diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
index f2cf5beff..345cc424f 100644
--- a/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
+++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PDFRenderingUtil.java
@@ -630,6 +630,7 @@ class PDFRenderingUtil {
this.pdfDoc.enableAccessibility(userAgent.isAccessibilityEnabled());
pdfDoc.setMergeFontsEnabled(rendererConfig.getMergeFontsEnabled());
+ pdfDoc.setMergeFormFieldsEnabled(rendererConfig.getMergeFormFieldsEnabled());
pdfDoc.setLinearizationEnabled(rendererConfig.getLinearizationEnabled());
pdfDoc.setFormXObjectEnabled(rendererConfig.getFormXObjectEnabled());
diff --git a/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java b/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
index d21739476..273d97633 100644
--- a/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
+++ b/fop-core/src/test/java/org/apache/fop/apps/PDFRendererConfBuilder.java
@@ -32,6 +32,7 @@ import static org.apache.fop.render.pdf.PDFEncryptionOption.USER_PASSWORD;
import static org.apache.fop.render.pdf.PDFRendererOption.DISABLE_SRGB_COLORSPACE;
import static org.apache.fop.render.pdf.PDFRendererOption.FILTER_LIST;
import static org.apache.fop.render.pdf.PDFRendererOption.FORM_XOBJECT;
+import static org.apache.fop.render.pdf.PDFRendererOption.MERGE_FORM_FIELDS;
import static org.apache.fop.render.pdf.PDFRendererOption.OUTPUT_PROFILE;
import static org.apache.fop.render.pdf.PDFRendererOption.PDF_A_MODE;
import static org.apache.fop.render.pdf.PDFRendererOption.PDF_X_MODE;
@@ -99,6 +100,11 @@ public final class PDFRendererConfBuilder extends RendererConfBuilder {
return this;
}
+ public PDFRendererConfBuilder setMergeFormFieldsEnabled(boolean b) {
+ createTextElement(MERGE_FORM_FIELDS, String.valueOf(b));
+ return this;
+ }
+
public final class EncryptionParamsBuilder {
private final Element el;
diff --git a/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java b/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java
index 7b81b4db8..e7d7a5c59 100644
--- a/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java
+++ b/fop-core/src/test/java/org/apache/fop/render/pdf/PDFRendererConfigParserTestCase.java
@@ -226,4 +226,10 @@ public class PDFRendererConfigParserTestCase
public void testErroneousPDFVersionsNotSet() throws Exception {
pdfVersionTester("");
}
+
+ @Test
+ public void testMergeFormFields() throws Exception {
+ parseConfig(createRenderer().setMergeFormFieldsEnabled(true));
+ assertTrue(conf.getConfigOptions().getMergeFormFieldsEnabled());
+ }
}