Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Sep 19, 2024
2 parents 24ff388 + 34a7e27 commit b4d8da1
Show file tree
Hide file tree
Showing 157 changed files with 1,931 additions and 1,688 deletions.
17 changes: 16 additions & 1 deletion BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

# Building and testing **iText Community**

To build **iText Community**, you need to build `itextsharp/itextcore/iTextCore.sln`.
To run tests, [Ghostscript][1] and [Imagemagick][2] must be installed.
Some of the tests compare generated PDF files with template files that show the correct results, and these tools are used to
Expand All @@ -14,5 +17,17 @@ environment variables. Examples of paths on Windows:
If you have a new version of ImageMagick, then there is no compare.exe utility there, wrap the path to magick.exe in quotes and call compare command:
ITEXT_MAGICK_COMPARE_EXEC=`"C:\Program Files\ImageMagick-7.0.9-Q16\magick.exe" compare`


# Deploying iText

When using **iText Community** in a project and want to deploy it you have to consider a few things for different deployments.

- **FrameworkDependend**: No additional parameters are required.
- **SelfContained**: No additional parameters are required.
- **PublishSingleFile**: When using `-p:PublishSingleFile=true` you will also need to add `-p:IncludeAllContentForSelfExtract=true`. This is important when using `hyph` or `font-asian` modules.
- **AssemblyTrimming**: Using `-p:PublishTrimmed=true` is currently not supported.



[1]: https://www.ghostscript.com/
[2]: https://www.imagemagick.org/
[2]: https://www.imagemagick.org/
12 changes: 6 additions & 6 deletions itext.tests/itext.forms.tests/itext/forms/PdfChoiceFieldTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,27 @@ public virtual void ChoiceFieldsWithUnicodeTest() {
pdfDoc.AddNewPage();
// 规
PdfFormField field = new ChoiceFormFieldBuilder(pdfDoc, "combo1").SetWidgetRectangle(new Rectangle(36, 666
, 40, 80)).SetOptions(new String[] { "\u89c4", "\u89c9" }).SetConformanceLevel(null).CreateComboBox().
SetValue("\u89c4");
, 40, 80)).SetOptions(new String[] { "\u89c4", "\u89c9" }).SetConformance(null).CreateComboBox().SetValue
("\u89c4");
field.SetFont(font);
field.GetFirstFormAnnotation().SetBorderColor(ColorConstants.BLACK);
form.AddField(field);
// 觉
field = new ChoiceFormFieldBuilder(pdfDoc, "combo2").SetWidgetRectangle(new Rectangle(136, 666, 40, 80)).SetOptions
(new String[] { "\u89c4", "\u89c9" }).SetConformanceLevel(null).CreateComboBox();
(new String[] { "\u89c4", "\u89c9" }).SetConformance(null).CreateComboBox();
field.SetValue("\u89c4").SetFont(font);
field.SetValue("\u89c9");
field.GetFirstFormAnnotation().SetBorderColor(ColorConstants.BLACK);
form.AddField(field);
// 规
field = new ChoiceFormFieldBuilder(pdfDoc, "list1").SetWidgetRectangle(new Rectangle(236, 666, 50, 80)).SetOptions
(new String[] { "\u89c4", "\u89c9" }).SetConformanceLevel(null).CreateList().SetValue("\u89c4");
(new String[] { "\u89c4", "\u89c9" }).SetConformance(null).CreateList().SetValue("\u89c4");
field.SetFont(font);
field.GetFirstFormAnnotation().SetBorderColor(ColorConstants.BLACK);
form.AddField(field);
// 觉
field = new ChoiceFormFieldBuilder(pdfDoc, "list2").SetWidgetRectangle(new Rectangle(336, 666, 50, 80)).SetOptions
(new String[] { "\u89c4", "\u89c9" }).SetConformanceLevel(null).CreateList();
(new String[] { "\u89c4", "\u89c9" }).SetConformance(null).CreateList();
field.SetValue("\u89c4").SetFont(font);
field.SetValue("\u89c9");
field.GetFirstFormAnnotation().SetBorderColor(ColorConstants.BLACK);
Expand Down Expand Up @@ -146,7 +146,7 @@ public virtual void MultiSelectByValueTest() {
document.AddNewPage();
PdfAcroForm form = PdfFormCreator.GetAcroForm(document, true);
PdfChoiceFormField choice = (PdfChoiceFormField)new ChoiceFormFieldBuilder(document, "choice").SetWidgetRectangle
(new Rectangle(336, 666, 50, 80)).SetOptions(new String[] { "one", "two", "three", "four" }).SetConformanceLevel
(new Rectangle(336, 666, 50, 80)).SetOptions(new String[] { "one", "two", "three", "four" }).SetConformance
(null).CreateList().SetValue("two").SetFont(null);
choice.GetFirstFormAnnotation().SetBorderColor(ColorConstants.BLACK);
choice.SetMultiSelect(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public virtual void CreateCheckBoxWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreateCheckBoxWithConformanceLevelTest() {
PdfButtonFormField checkBoxFormField = new CheckBoxFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle
(DUMMY_RECTANGLE).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateCheckBox();
(DUMMY_RECTANGLE).SetConformance(PdfConformance.PDF_A_1A).CreateCheckBox();
CompareCheckBoxes(checkBoxFormField, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public virtual void CreateComboBoxWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreateComboBoxWithConformanceLevelTest() {
PdfChoiceFormField choiceFormField = new ChoiceFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle
(DUMMY_RECTANGLE).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateComboBox();
(DUMMY_RECTANGLE).SetConformance(PdfConformance.PDF_A_1A).CreateComboBox();
CompareChoices(new PdfDictionary(), choiceFormField, true);
}

Expand Down Expand Up @@ -150,7 +150,7 @@ public virtual void CreateListWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreateListWithConformanceLevelTest() {
PdfChoiceFormField choiceFormField = new ChoiceFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle
(DUMMY_RECTANGLE).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateList();
(DUMMY_RECTANGLE).SetConformance(PdfConformance.PDF_A_1A).CreateList();
PdfDictionary expectedDictionary = new PdfDictionary();
expectedDictionary.Put(PdfName.Ff, new PdfNumber(0));
CompareChoices(expectedDictionary, choiceFormField, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ public virtual void ConstructorTest() {
public virtual void GetSetConformanceLevelTest() {
FormFieldBuilderTest.TestBuilder builder = new FormFieldBuilderTest.TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME
);
builder.SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A);
NUnit.Framework.Assert.AreSame(PdfAConformanceLevel.PDF_A_1A, builder.GetConformanceLevel());
builder.SetConformance(PdfConformance.PDF_A_1A);
NUnit.Framework.Assert.AreSame(PdfAConformance.PDF_A_1A, builder.GetConformance().GetAConformance());
}

[NUnit.Framework.Test]
public virtual void GetSetConformanceLevelPdfUATest() {
FormFieldBuilderTest.TestBuilder builder = new FormFieldBuilderTest.TestBuilder(DUMMY_DOCUMENT, DUMMY_NAME
);
builder.SetConformanceLevel(PdfUAConformanceLevel.PDFUA_1);
NUnit.Framework.Assert.AreSame(PdfUAConformanceLevel.PDFUA_1, builder.GetConformanceLevel());
builder.SetConformance(PdfConformance.PDF_UA_1);
NUnit.Framework.Assert.AreSame(PdfUAConformance.PDF_UA_1, builder.GetConformance().GetUAConformance());
}

private class TestBuilder : FormFieldBuilder<FormFieldBuilderTest.TestBuilder> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public virtual void CreatePushButtonWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreatePushButtonWithConformanceLevelTest() {
PdfButtonFormField pushButtonFormField = new PushButtonFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle
(DUMMY_RECTANGLE).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreatePushButton();
(DUMMY_RECTANGLE).SetConformance(PdfConformance.PDF_A_1A).CreatePushButton();
ComparePushButtons(pushButtonFormField, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ public virtual void CreateRadioButtonWithoutWidgetThrowsExceptionTest() {
public virtual void CreateRadioButtonWithConformanceLevelTest() {
RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME);
PdfButtonFormField radioGroup = builder.CreateRadioGroup();
PdfFormAnnotation radioAnnotation = builder.SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateRadioButton
(DUMMY_APPEARANCE_NAME, DUMMY_RECTANGLE);
PdfFormAnnotation radioAnnotation = builder.SetConformance(PdfConformance.PDF_A_1A).CreateRadioButton(DUMMY_APPEARANCE_NAME
, DUMMY_RECTANGLE);
CompareRadioButtons(radioAnnotation, radioGroup, false);
}

[NUnit.Framework.Test]
public virtual void CreateRadioButtonWithConformanceLevelAddedToGroupTest() {
RadioFormFieldBuilder builder = new RadioFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME);
PdfButtonFormField radioGroup = builder.CreateRadioGroup();
PdfFormAnnotation radioAnnotation = builder.SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateRadioButton
(DUMMY_APPEARANCE_NAME, DUMMY_RECTANGLE);
PdfFormAnnotation radioAnnotation = builder.SetConformance(PdfConformance.PDF_A_1A).CreateRadioButton(DUMMY_APPEARANCE_NAME
, DUMMY_RECTANGLE);
radioGroup.AddKid(radioAnnotation);
CompareRadioButtons(radioAnnotation, radioGroup, true);
}
Expand Down Expand Up @@ -235,7 +235,7 @@ private static void CompareRadioButtons(PdfFormAnnotation radioButtonFormField,
));
}
}
if (radioButtonFormField.pdfConformanceLevel != null) {
if (radioButtonFormField.pdfConformance != null && radioButtonFormField.pdfConformance.IsPdfAOrUa()) {
PutIfAbsent(expectedDictionary, PdfName.F, new PdfNumber(PdfAnnotation.PRINT));
}
// for the AS key if it's added to the group we expect it to be off or the value if the radiogroup was selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public virtual void CreateSignatureWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreateSignatureWithConformanceLevelTest() {
PdfSignatureFormField signatureFormField = new SignatureFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle
(DUMMY_RECTANGLE).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateSignature();
(DUMMY_RECTANGLE).SetConformance(PdfConformance.PDF_A_1A).CreateSignature();
CompareSignatures(signatureFormField, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public virtual void CreateTextWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreateTextWithConformanceLevelTest() {
PdfTextFormField textFormField = new TextFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle(DUMMY_RECTANGLE
).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateText();
).SetConformance(PdfConformance.PDF_A_1A).CreateText();
PdfDictionary expectedDictionary = new PdfDictionary();
expectedDictionary.Put(PdfName.Ff, new PdfNumber(0));
CompareTexts(expectedDictionary, textFormField, true);
Expand All @@ -92,7 +92,7 @@ public virtual void CreateMultilineTextWithoutWidgetTest() {
[NUnit.Framework.Test]
public virtual void CreateMultilineTextWithConformanceLevelTest() {
PdfTextFormField textFormField = new TextFormFieldBuilder(DUMMY_DOCUMENT, DUMMY_NAME).SetWidgetRectangle(DUMMY_RECTANGLE
).SetConformanceLevel(PdfAConformanceLevel.PDF_A_1A).CreateMultilineText();
).SetConformance(PdfConformance.PDF_A_1A).CreateMultilineText();
PdfDictionary expectedDictionary = new PdfDictionary();
expectedDictionary.Put(PdfName.Ff, new PdfNumber(PdfTextFormField.FF_MULTILINE));
CompareTexts(expectedDictionary, textFormField, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public virtual void CreateCheckBoxFactoryDefaultPdfTest() {
[NUnit.Framework.Test]
public virtual void CreateCheckBoxFactoryPdfATest() {
CheckBox checkBox = new CheckBox("test");
checkBox.SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
checkBox.SetPdfConformance(PdfConformance.PDF_A_1B);
CheckBoxRenderer renderer = (CheckBoxRenderer)checkBox.GetRenderer();
ICheckBoxRenderingStrategy strategy = renderer.CreateCheckBoxRenderStrategy();
NUnit.Framework.Assert.IsTrue(strategy is PdfACheckBoxRenderingStrategy);
Expand All @@ -132,7 +132,7 @@ public virtual void CreateCheckBoxFactoryHtmlTest() {
public virtual void CreateCheckBoxFactoryHtmlWithPdfATest() {
CheckBox checkBox = new CheckBox("test");
checkBox.SetProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE);
checkBox.SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
checkBox.SetPdfConformance(PdfConformance.PDF_A_1B);
CheckBoxRenderer renderer = (CheckBoxRenderer)checkBox.GetRenderer();
ICheckBoxRenderingStrategy strategy = renderer.CreateCheckBoxRenderStrategy();
NUnit.Framework.Assert.IsTrue(strategy is HtmlCheckBoxRenderingStrategy);
Expand Down Expand Up @@ -215,17 +215,15 @@ public virtual void BasicCheckBoxDrawingTestPdfAMode() {
String cmpPdf = SOURCE_FOLDER + "cmp_basicCheckBoxPdfA.pdf";
using (Document document = new Document(new PdfDocument(new PdfWriter(outPdf)))) {
//should be invisble because there is no default border
CheckBox checkBoxUnset = new CheckBox("test").SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
CheckBox checkBoxUnset = new CheckBox("test").SetPdfConformance(PdfConformance.PDF_A_1B);
document.Add(checkBoxUnset);
CheckBox checkBoxset = new CheckBox("test").SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
CheckBox checkBoxset = new CheckBox("test").SetPdfConformance(PdfConformance.PDF_A_1B);
checkBoxset.SetChecked(true);
document.Add(checkBoxset);
CheckBox checkBoxUnsetInteractive = new CheckBox("test1").SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B
);
CheckBox checkBoxUnsetInteractive = new CheckBox("test1").SetPdfConformance(PdfConformance.PDF_A_1B);
checkBoxUnsetInteractive.SetInteractive(true);
document.Add(checkBoxUnsetInteractive);
CheckBox checkBoxsetInteractive = new CheckBox("test2").SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B
);
CheckBox checkBoxsetInteractive = new CheckBox("test2").SetPdfConformance(PdfConformance.PDF_A_1B);
checkBoxsetInteractive.SetInteractive(true);
checkBoxsetInteractive.SetChecked(true);
document.Add(checkBoxsetInteractive);
Expand Down Expand Up @@ -339,7 +337,7 @@ public virtual void CheckBoxSetCheckTypes() {
}
);
GenerateCheckBoxes(document, (checkBox) => {
checkBox.SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
checkBox.SetPdfConformance(PdfConformance.PDF_A_1B);
checkBox.SetCheckBoxType(enumConstant);
}
);
Expand All @@ -356,7 +354,7 @@ public virtual void SetPdfAConformanceLevel() {
foreach (CheckBoxType enumConstant in EnumUtil.GetAllValuesOfEnum<CheckBoxType>()) {
GenerateCheckBoxes(document, (checkBox) => {
checkBox.SetSize(20);
checkBox.SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_3B);
checkBox.SetPdfConformance(PdfConformance.PDF_A_3B);
checkBox.SetCheckBoxType(enumConstant);
}
);
Expand Down Expand Up @@ -502,7 +500,7 @@ private void GenerateCheckBoxesForAllRenderingModes(Document document, Action<Ch
document.Add(new Paragraph("Pdfa rendering mode"));
GenerateCheckBoxes(document, (checkBox) => {
checkBox.SetProperty(Property.RENDERING_MODE, RenderingMode.DEFAULT_LAYOUT_MODE);
checkBox.SetPdfConformanceLevel(PdfAConformanceLevel.PDF_A_1B);
checkBox.SetPdfConformance(PdfConformance.PDF_A_1B);
alterFunction(checkBox);
}
);
Expand Down
Loading

0 comments on commit b4d8da1

Please sign in to comment.