Skip to content

Commit 167bf3e

Browse files
Duplicated entries in the AcroForm /Fields array
DEVSIX-460
1 parent a5bb161 commit 167bf3e

File tree

5 files changed

+5
-3
lines changed

5 files changed

+5
-3
lines changed

forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ protected PdfArray getFields() {
762762

763763
@Override
764764
protected boolean isWrappedObjectMustBeIndirect() {
765-
return true;
765+
return false;
766766
}
767767

768768
private Map<String, PdfFormField> iterateFields(PdfArray array) {

forms/src/main/java/com/itextpdf/forms/PdfPageFormCopier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void copy(PdfPage fromPage, PdfPage toPage) {
9696

9797
private PdfFormField mergeFieldsWithTheSameName(PdfFormField existingField, PdfFormField newField) {
9898
PdfFormField mergedField = PdfFormField.createEmptyField(documentTo);
99-
formTo.removeField(existingField.getFieldName().toUnicodeString());
99+
formTo.getFields().remove(newField.getPdfObject());
100100
mergedField.
101101
put(PdfName.FT, existingField.getFormType()).
102102
put(PdfName.T, existingField.getFieldName()).

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@ public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect,
571571
check.setFieldName(name);
572572
check.setValue(value);
573573
annot.setAppearanceState(new PdfName(value));
574+
if (value.equals("Off")) {
575+
value = "Yes";
576+
}
574577
check.drawCheckAppearance(rect.getWidth(), rect.getHeight(), value);
575578

576579
return (PdfButtonFormField) check;

forms/src/test/java/com/itextpdf/forms/PdfFormCopyTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static public void beforeClass() {
3636
@LogMessages(messages = {
3737
@LogMessage(messageTemplate = LogMessageConstant.DOCUMENT_ALREADY_HAS_FIELD, count = 13)
3838
})
39-
@Ignore("Merging forms with the same name: widget annotation of old field is removed")
4039
public void copyFieldsTest01() throws IOException, InterruptedException {
4140
String srcFilename1 = sourceFolder + "appearances1.pdf";
4241
String srcFilename2 = sourceFolder + "fieldsOn2-sPage.pdf";

0 commit comments

Comments
 (0)