Skip to content

Commit 80a0dcd

Browse files
Benoit Lagaeitext-teamcity
authored andcommitted
Merge branch 'hotfix/unicodeforms' into develop
Autoported commit. Original commit hash: [f86610438]
2 parents 76ca1b6 + 8499530 commit 80a0dcd

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

itext.tests/itext.forms.tests/itext/forms/PdfFormFieldTest.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,20 @@ public virtual void UnicodeFormFieldTest() {
121121
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
122122
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
123123
IDictionary<String, PdfFormField> formFields = form.GetFormFields();
124-
byte[] result = new byte[] { (byte)0xFE, (byte)0xFF, (byte)0x5E, (byte)0x10, (byte)0x53, (byte)0xF7, (byte
125-
)0x00, (byte)0x31 };
124+
String fieldName = "\u5E10\u53F71";
126125
// 帐号1: account number 1
127-
NUnit.Framework.Assert.AreEqual(formFields.Keys.ToArray(new String[1])[0].GetBytes(), result);
126+
NUnit.Framework.Assert.AreEqual(fieldName, formFields.Keys.ToArray(new String[1])[0]);
127+
}
128+
129+
/// <exception cref="System.IO.IOException"/>
130+
[NUnit.Framework.Test]
131+
public virtual void UnicodeFormFieldTest2() {
132+
String filename = sourceFolder + "unicodeFormFieldFile.pdf";
133+
PdfDocument pdfDoc = new PdfDocument(new PdfReader(filename));
134+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
135+
String fieldName = "\u5E10\u53F71";
136+
// 帐号1: account number 1
137+
NUnit.Framework.Assert.IsNotNull(form.GetField(fieldName));
128138
}
129139

130140
/// <exception cref="System.IO.IOException"/>

itext/itext.forms/itext/forms/PdfAcroForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,11 +952,11 @@ private IDictionary<String, PdfFormField> IterateFields(PdfArray array, IDiction
952952
parentField = PdfFormField.MakeFormField(parentField.GetParent(), document);
953953
}
954954
}
955-
name = fieldName.GetValue() + "." + index;
955+
name = fieldName.ToUnicodeString() + "." + index;
956956
index++;
957957
}
958958
else {
959-
name = fieldName.GetValue();
959+
name = fieldName.ToUnicodeString();
960960
}
961961
fields.Put(name, formField);
962962
if (formField.GetKids() != null) {

itext/itext.forms/itext/forms/fields/PdfFormField.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,12 +1578,12 @@ public virtual PdfString GetFieldName() {
15781578
());
15791579
PdfString pName = parentField.GetFieldName();
15801580
if (pName != null) {
1581-
parentName = pName.GetValue() + ".";
1581+
parentName = pName.ToUnicodeString() + ".";
15821582
}
15831583
}
15841584
PdfString name = GetPdfObject().GetAsString(PdfName.T);
15851585
if (name != null) {
1586-
name = new PdfString(parentName + name.GetValue());
1586+
name = new PdfString(parentName + name.ToUnicodeString(), PdfEncodings.UNICODE_BIG);
15871587
}
15881588
return name;
15891589
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dbab5374686a1d8971a2554aad565ef8bd39e643
1+
f86610438d1a8c56782300fada2c44af4e6fe747

0 commit comments

Comments
 (0)