Skip to content

Commit a241655

Browse files
Ross FrankiText-CI
authored andcommitted
add test for DEVSIX-2156
Autoported commit. Original commit hash: [12da6291f]
1 parent bd582da commit a241655

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

itext.tests/itext.forms.tests/itext/forms/FormFieldFlatteningTest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ source product.
4141
4242
*/
4343
using System;
44+
using System.IO;
4445
using iText.Forms.Fields;
4546
using iText.Kernel.Colors;
4647
using iText.Kernel.Pdf;
4748
using iText.Kernel.Utils;
4849
using iText.Test;
50+
using iText.Test.Attributes;
4951

5052
namespace iText.Forms {
5153
public class FormFieldFlatteningTest : ExtendedITextTest {
@@ -209,5 +211,30 @@ private static void FillTextFieldsThenFlattenThenCompare(String testName) {
209211
doc.Close();
210212
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
211213
}
214+
215+
/// <exception cref="System.IO.IOException"/>
216+
[NUnit.Framework.Test]
217+
[LogMessage(iText.IO.LogMessageConstant.DOCUMENT_ALREADY_HAS_FIELD, Count = 3)]
218+
public virtual void FlattenReadOnly() {
219+
//Logging is expected since there are duplicate field names
220+
//isReadOnly should be true after DEVSIX-2156
221+
PdfWriter writer = new PdfWriter(new MemoryStream());
222+
PdfDocument pdfDoc = new PdfDocument(writer);
223+
PdfReader reader = new PdfReader(sourceFolder + "readOnlyForm.pdf");
224+
PdfDocument pdfInnerDoc = new PdfDocument(reader);
225+
pdfInnerDoc.CopyPagesTo(1, pdfInnerDoc.GetNumberOfPages(), pdfDoc, new PdfPageFormCopier());
226+
pdfInnerDoc.Close();
227+
reader = new PdfReader(sourceFolder + "readOnlyForm.pdf");
228+
pdfInnerDoc = new PdfDocument(reader);
229+
pdfInnerDoc.CopyPagesTo(1, pdfInnerDoc.GetNumberOfPages(), pdfDoc, new PdfPageFormCopier());
230+
pdfInnerDoc.Close();
231+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, false);
232+
bool isReadOnly = true;
233+
foreach (PdfFormField field in form.GetFormFields().Values) {
234+
isReadOnly = (isReadOnly && field.IsReadOnly());
235+
}
236+
pdfDoc.Close();
237+
NUnit.Framework.Assert.IsFalse(isReadOnly);
238+
}
212239
}
213240
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b7a901674e5cb6ae3c018047fdc5c80598478de2
1+
12da6291f4df3a21df2574d7028b68353bc5a912

0 commit comments

Comments
 (0)