Skip to content

Commit 6ef3dbf

Browse files
Kate IvanovaiText-CI
authored andcommitted
Add integration tests for missing form fields border styles
DEVSIX-4532 Autoported commit. Original commit hash: [80d432a69]
1 parent 5b85e76 commit 6ef3dbf

File tree

8 files changed

+49
-1
lines changed

8 files changed

+49
-1
lines changed

itext.tests/itext.forms.tests/itext/forms/widget/AppearanceCharacteristicsTest.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ source product.
4141
4242
*/
4343
using System;
44+
using System.Collections.Generic;
4445
using iText.Forms;
46+
using iText.Forms.Fields;
4547
using iText.Kernel.Colors;
48+
using iText.Kernel.Geom;
4649
using iText.Kernel.Pdf;
50+
using iText.Kernel.Pdf.Annot;
4751
using iText.Kernel.Utils;
4852
using iText.Test;
4953

@@ -75,5 +79,49 @@ public virtual void FillFormWithRotatedFieldAndPageTest() {
7579
NUnit.Framework.Assert.Fail(errorMessage);
7680
}
7781
}
82+
83+
[NUnit.Framework.Test]
84+
public virtual void BorderStyleInCreatedFormFieldsTest() {
85+
//TODO: update cmp file after fixing DEVSIX-836
86+
String outPdf = destinationFolder + "borderStyleInCreatedFormFields.pdf";
87+
PdfDocument doc = new PdfDocument(new PdfWriter(outPdf));
88+
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
89+
PdfFormField formField1 = PdfTextFormField.CreateText(doc, new Rectangle(100, 600, 100, 50), "firstField",
90+
"Hello, iText!");
91+
formField1.GetWidgets()[0].SetBorderStyle(PdfAnnotation.STYLE_BEVELED);
92+
formField1.SetBorderWidth(2).SetBorderColor(ColorConstants.BLUE);
93+
PdfFormField formField2 = PdfTextFormField.CreateText(doc, new Rectangle(100, 500, 100, 50), "secondField"
94+
, "Hello, iText!");
95+
formField2.GetWidgets()[0].SetBorderStyle(PdfAnnotation.STYLE_UNDERLINE);
96+
formField2.SetBorderWidth(2).SetBorderColor(ColorConstants.BLUE);
97+
PdfFormField formField3 = PdfTextFormField.CreateText(doc, new Rectangle(100, 400, 100, 50), "thirdField",
98+
"Hello, iText!");
99+
formField3.GetWidgets()[0].SetBorderStyle(PdfAnnotation.STYLE_INSET);
100+
formField3.SetBorderWidth(2).SetBorderColor(ColorConstants.BLUE);
101+
form.AddField(formField1);
102+
form.AddField(formField2);
103+
form.AddField(formField3);
104+
form.FlattenFields();
105+
doc.Close();
106+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, sourceFolder + "cmp_borderStyleInCreatedFormFields.pdf"
107+
, destinationFolder));
108+
}
109+
110+
[NUnit.Framework.Test]
111+
public virtual void UpdatingBorderStyleInFormFieldsTest() {
112+
//TODO: update cmp file after fixing DEVSIX-836
113+
String inputPdf = sourceFolder + "borderStyleInCreatedFormFields.pdf";
114+
String outPdf = destinationFolder + "updatingBorderStyleInFormFields.pdf";
115+
PdfDocument doc = new PdfDocument(new PdfReader(inputPdf), new PdfWriter(outPdf));
116+
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, false);
117+
IDictionary<String, PdfFormField> fields = form.GetFormFields();
118+
fields.Get("firstField").SetValue("New Value 1");
119+
fields.Get("secondField").SetValue("New Value 2");
120+
fields.Get("thirdField").SetValue("New Value 3");
121+
form.FlattenFields();
122+
doc.Close();
123+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, sourceFolder + "cmp_updatingBorderStyleInFormFields.pdf"
124+
, destinationFolder));
125+
}
78126
}
79127
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
32e32df7c67c91522f0366e831b2d9272dd9dd65
1+
80d432a69fa6bb00876f8a2a20d3b032abe92c20

0 commit comments

Comments
 (0)