Skip to content

Commit 6586952

Browse files
author
Benoit Lagae
committed
Merge branch 'hotfix/unicodeformfield' into develop
2 parents 06d69f7 + 30369f9 commit 6586952

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,10 @@ private Map<String, PdfFormField> iterateFields(PdfArray array, Map<String, PdfF
845845
parentField = PdfFormField.makeFormField(parentField.getParent(), document);
846846
}
847847
}
848-
name = fieldName.toUnicodeString() + "." + index;
848+
name = fieldName.getValue() + "." + index;
849849
index++;
850850
} else {
851-
name = fieldName.toUnicodeString();
851+
name = fieldName.getValue();
852852
}
853853
fields.put(name, formField);
854854
if (formField.getKids() != null) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,12 +1214,12 @@ public PdfString getFieldName() {
12141214
PdfFormField parentField = PdfFormField.makeFormField(getParent(), getDocument());
12151215
PdfString pName = parentField.getFieldName();
12161216
if (pName != null) {
1217-
parentName = pName.toUnicodeString() + ".";
1217+
parentName = pName.getValue() + ".";
12181218
}
12191219
}
12201220
PdfString name = getPdfObject().getAsString(PdfName.T);
12211221
if (name != null) {
1222-
name = new PdfString(parentName + name.toUnicodeString());
1222+
name = new PdfString(parentName + name.getValue());
12231223
}
12241224
return name;
12251225
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ public void formFieldTest03() throws IOException, InterruptedException {
130130
}
131131
}
132132

133+
@Test
134+
public void unicodeFormFieldTest() throws IOException {
135+
String filename = sourceFolder + "unicodeFormFieldFile.pdf";
136+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
137+
PdfAcroForm form = PdfAcroForm.getAcroForm(pdfDoc, true);
138+
Map<String, PdfFormField> formFields = form.getFormFields();
139+
byte[] result = {(byte) 0xFE,(byte) 0xFF,(byte) 0x5E,(byte) 0x10,(byte) 0x53,(byte) 0xF7,(byte) 0x00,(byte) 0x31}; // 帐号1: account number 1
140+
Assert.assertArrayEquals(formFields.keySet().toArray()[0].toString().getBytes(), result);
141+
}
142+
133143
@Test
134144
public void choiceFieldTest01() throws IOException, InterruptedException {
135145
String filename = destinationFolder + "choiceFieldTest01.pdf";

0 commit comments

Comments
 (0)