Skip to content

Commit 8954d07

Browse files
committed
[RELEASE] iText 9.4.0
2 parents 9975469 + c09397f commit 8954d07

File tree

993 files changed

+25902
-2152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

993 files changed

+25902
-2152
lines changed

BUILDING.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,74 @@ When using **iText Community** in a project and want to deploy it you have to co
2828
- **AssemblyTrimming**: Using `-p:PublishTrimmed=true` is currently not supported.
2929

3030

31+
# Building AOT
32+
33+
Aot is a quite complex feature, iText library is a non trivial project, meaning it does require some fixes to get it working.
34+
35+
36+
1. iText relies on `SignedXml` for the `LotlValidator` functionality currently there is an open issue: https://github.com/dotnet/runtime/issues/97274.
37+
To fix usage within iText you need some additional annotations so the algorithms don't get trimmed away.
38+
2. One way to fix this is add following annotations to your code to make sure trimming does not happen.
39+
```csharp
40+
41+
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Security.Cryptography.SHA1Managed",
42+
"System.Security.Cryptography.Algorithms")]
43+
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Security.Cryptography.SHA256Managed",
44+
"System.Security.Cryptography.Algorithms")]
45+
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Security.Cryptography.SHA384Managed",
46+
"System.Security.Cryptography.Algorithms")]
47+
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Security.Cryptography.SHA512Managed",
48+
"System.Security.Cryptography.Algorithms")]
49+
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Security.Cryptography.RSAPKCS1SignatureFormatter",
50+
"System.Security.Cryptography.Algorithms")]
51+
[DynamicDependency(DynamicallyAccessedMemberTypes.All, "System.Security.Cryptography.RSAPKCS1SignatureDeformatter",
52+
"System.Security.Cryptography.Algorithms")]
53+
void LotlValidationExample() {
54+
ValidatorChainBuilder chainBuilder = new ValidatorChainBuilder();
55+
chainBuilder.TrustEuropeanLotl(true);
56+
ValidationReport report;
57+
using (LotlService lotlService =
58+
new LotlService(new LotlFetchingProperties(new RemoveOnFailingCountryData()).SetCountryNames("AT"))) {
59+
lotlService.InitializeCache();
60+
61+
62+
chainBuilder.WithLotlService(() => lotlService);
63+
LotlValidator lotlValidator = new LotlValidator(lotlService);
64+
lotlService.WithLotlValidator(() => lotlValidator);
65+
lotlService.InitializeCache();
66+
report = lotlValidator.Validate();
67+
}
68+
69+
}
70+
```
71+
2. Some default modules rely on specific classes that initialize default implementations might be trimmed away. To avoid this we recommend adding following entries to the `ILLink descriptors file`:
72+
```xml
73+
<linker>
74+
<assembly fullname="itext.kernel">
75+
<type fullname="iText.Kernel.Utils.RegisterDefaultDiContainer" preserve="all" />
76+
</assembly>
77+
<assembly fullname="itext.forms">
78+
<type fullname="iText.Forms.Util.RegisterDefaultDiContainer" preserve="all" />
79+
</assembly>
80+
</linker>
81+
```
82+
If you didn't set up an `ILLink descriptors file` already for your project you can do it by adding a file called `ILLink.Descriptors.xml` and adding the required configuration to you `project.csrpoj` file.
83+
```xml
84+
<ItemGroup>
85+
<EmbeddedResource Include="ILLink.Descriptors.xml">
86+
<LogicalName>ILLink.Descriptors.xml</LogicalName>
87+
</EmbeddedResource>
88+
</ItemGroup>
89+
```
90+
91+
3. If you are using the `font-asian`, or `hyph` module you should call the initializers on the startup of you application.
92+
```
93+
new iText.FontAsian.FontAsianDummyInitializer(); // Font asian
94+
new iText.Hyph.HyphDummyInitializer(); // Hyph module
95+
```
96+
97+
98+
3199

32100
[1]: https://www.ghostscript.com/
33101
[2]: https://www.imagemagick.org/

doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
3232
# title of most generated pages and in a few other places.
3333
# The default value is: My Project.
3434

35-
PROJECT_NAME = "iText 9.3.0 API"
35+
PROJECT_NAME = "iText 9.4.0 API"
3636

3737
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
3838
# could be handy for archiving the generated documentation or if some version

itext.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
33
<metadata>
44
<id>itext</id>
5-
<version>9.3.0</version>
5+
<version>9.4.0</version>
66
<title>iText Community</title>
77
<authors>Apryse Software</authors>
88
<owners>Apryse Software</owners>
@@ -19,12 +19,12 @@
1919
<repository type="git" url="https://github.com/itext/itext7-dotnet.git" />
2020
<dependencies>
2121
<group targetFramework="net461">
22-
<dependency id="itext.commons" version="9.3.0" />
22+
<dependency id="itext.commons" version="9.4.0" />
2323
<dependency id="Microsoft.Extensions.Logging" version="5.0.0" />
2424
<dependency id="System.Security.Cryptography.Xml" version="6.0.2" />
2525
</group>
2626
<group targetFramework="netstandard2.0">
27-
<dependency id="itext.commons" version="9.3.0" />
27+
<dependency id="itext.commons" version="9.4.0" />
2828
<dependency id="Microsoft.Extensions.Logging" version="5.0.0" />
2929
<dependency id="System.Diagnostics.Process" version="4.3.0" />
3030
<dependency id="System.Globalization.Extensions" version="4.3.0" />

itext.tests/itext.barcodes.tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
[assembly: Guid("d015a3aa-613c-45d9-b908-7d47c4b613af")]
1717

18-
[assembly: AssemblyVersion("9.3.0.0")]
19-
[assembly: AssemblyFileVersion("9.3.0.0")]
20-
[assembly: AssemblyInformationalVersion("9.3.0")]
18+
[assembly: AssemblyVersion("9.4.0.0")]
19+
[assembly: AssemblyFileVersion("9.4.0.0")]
20+
[assembly: AssemblyInformationalVersion("9.4.0")]
2121

2222
[assembly: Parallelizable(ParallelScope.ContextMask)]
2323

itext.tests/itext.barcodes.tests/itext/barcodes/BarcodeQRCodeTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public virtual void Barcode01Test() {
5454
PdfDocument document = new PdfDocument(writer);
5555
PdfPage page = document.AddNewPage();
5656
PdfCanvas canvas = new PdfCanvas(page);
57-
IDictionary<EncodeHintType, Object> hints = new Dictionary<EncodeHintType, Object>();
58-
hints.Put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
5957
BarcodeQRCode barcode = new BarcodeQRCode("some specific text 239214 hello world");
6058
barcode.PlaceBarcode(canvas, ColorConstants.GRAY, 12);
6159
document.Close();

itext.tests/itext.commons.tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
[assembly: Guid("502eda37-c014-4822-8e5c-4e5d21b085e9")]
1717

18-
[assembly: AssemblyVersion("9.3.0.0")]
19-
[assembly: AssemblyFileVersion("9.3.0.0")]
20-
[assembly: AssemblyInformationalVersion("9.3.0")]
18+
[assembly: AssemblyVersion("9.4.0.0")]
19+
[assembly: AssemblyFileVersion("9.4.0.0")]
20+
[assembly: AssemblyInformationalVersion("9.4.0")]
2121

2222
#if !NETSTANDARD2_0
2323
[assembly: NUnit.Framework.Timeout(300000)]

itext.tests/itext.forms.tests/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
[assembly: Guid("6fe2f714-6b3e-4b20-8c70-28bfce084ed2")]
1616

17-
[assembly: AssemblyVersion("9.3.0.0")]
18-
[assembly: AssemblyFileVersion("9.3.0.0")]
19-
[assembly: AssemblyInformationalVersion("9.3.0")]
17+
[assembly: AssemblyVersion("9.4.0.0")]
18+
[assembly: AssemblyFileVersion("9.4.0.0")]
19+
[assembly: AssemblyInformationalVersion("9.4.0")]
2020

2121
#if !NETSTANDARD2_0
2222
[assembly: NUnit.Framework.Timeout(300000)]

itext.tests/itext.forms.tests/itext/forms/FlatteningTest.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
2323
using System;
24+
using System.Collections.Generic;
2425
using iText.Forms.Fields;
2526
using iText.Forms.Logs;
27+
using iText.Kernel.Font;
2628
using iText.Kernel.Pdf;
2729
using iText.Kernel.Pdf.Canvas.Parser;
2830
using iText.Kernel.Utils;
@@ -53,6 +55,54 @@ public virtual void FlatteningFormFieldNoSubtypeInAPTest() {
5355
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
5456
}
5557

58+
[NUnit.Framework.Test]
59+
public virtual void FlatteningPdfWithButtons() {
60+
String src = sourceFolder + "flatteningPdfWithButtons.pdf";
61+
String dest = destinationFolder + "flatteningPdfWithButtonsOutput.pdf";
62+
String cmp = sourceFolder + "cmp_flatteningPdfWithButtons.pdf";
63+
using (PdfDocument pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest))) {
64+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
65+
PdfFont font = PdfFontFactory.CreateFont();
66+
PdfFormField field = form.GetField("myPushButton");
67+
field.SetValue("push button", font, 12);
68+
field.RegenerateField();
69+
PdfFormField field2 = form.GetField("myCheckBox");
70+
field2.SetValue("check box", font, 12);
71+
field2.RegenerateField();
72+
RadioFormFieldBuilder builder = new RadioFormFieldBuilder(pdfDoc, "answer");
73+
PdfButtonFormField radioGroup = builder.CreateRadioGroup();
74+
radioGroup.SetValue("answer 1");
75+
form.AddField(radioGroup);
76+
}
77+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
78+
}
79+
80+
[NUnit.Framework.Test]
81+
public virtual void FlatteningPdfWithFields() {
82+
String src = sourceFolder + "flatteningPdfWithFields.pdf";
83+
String dest = destinationFolder + "flatteningPdfWithFields.pdf";
84+
String cmp = sourceFolder + "cmp_flatteningPdfWithFields.pdf";
85+
using (PdfDocument pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest))) {
86+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true);
87+
PdfFont font = PdfFontFactory.CreateFont();
88+
IDictionary<PdfName, PdfObject> appearance = new Dictionary<PdfName, PdfObject>();
89+
appearance.Put(PdfName.CA, new PdfString("wrong text"));
90+
PdfFormField inputField = form.GetField("inputField");
91+
inputField.GetPdfObject().Put(PdfName.MK, new PdfDictionary(appearance));
92+
inputField.SetValue("input field regenerated", font, 12);
93+
inputField.RegenerateField();
94+
PdfFormField comboBoxField = form.GetField("comboBoxField");
95+
inputField.GetPdfObject().Put(PdfName.MK, new PdfDictionary(appearance));
96+
comboBoxField.SetValue("Red", font, 12);
97+
comboBoxField.RegenerateField();
98+
PdfFormField textAreaField = form.GetField("textAreaField");
99+
textAreaField.GetPdfObject().Put(PdfName.MK, new PdfDictionary(appearance));
100+
textAreaField.SetValue("text area field regenerated", font, 12);
101+
textAreaField.RegenerateField();
102+
}
103+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(dest, cmp, destinationFolder, "diff_"));
104+
}
105+
56106
[NUnit.Framework.Test]
57107
[LogMessage(FormsLogMessageConstants.N_ENTRY_IS_REQUIRED_FOR_APPEARANCE_DICTIONARY)]
58108
public virtual void FormFlatteningTestWithoutNEntry() {

itext.tests/itext.forms.tests/itext/forms/fields/merging/OnDuplicateFormFieldNameStrategyTest.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ You should have received a copy of the GNU Affero General Public License
2727
using iText.Forms.Form.Element;
2828
using iText.Kernel.Colors;
2929
using iText.Kernel.Exceptions;
30+
using iText.Kernel.Font;
3031
using iText.Kernel.Geom;
3132
using iText.Kernel.Pdf;
3233
using iText.Kernel.Utils;
@@ -237,10 +238,25 @@ public virtual void FieldsWithSameNamesTest() {
237238
}
238239
}
239240

241+
[NUnit.Framework.Test]
242+
public virtual void MergeFieldsStrategyTest() {
243+
String destination = SOURCE_FOLDER + "mergeFieldsStrategyTest.pdf";
244+
using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(destination), new PdfWriter(new MemoryStream
245+
()))) {
246+
PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDocument, true, new MergeFieldsStrategy());
247+
PdfTextFormField firstField = new TextFormFieldBuilder(pdfDocument, "samplefield").SetWidgetRectangle(new
248+
Rectangle(30, 850, 100, 30)).CreateText();
249+
PdfFont pdfFont = pdfDocument.GetDefaultFont();
250+
firstField.SetValue("text").SetFont(pdfFont).SetFontSize(20f);
251+
form.AddField(firstField);
252+
NUnit.Framework.Assert.AreEqual(1, form.GetAllFormFields().Count);
253+
}
254+
}
255+
240256
[NUnit.Framework.Test]
241257
public virtual void AddIndexStrategySeparatesTheFields() {
242258
try {
243-
PdfFormCreator.SetFactory(new _PdfFormFactory_283());
259+
PdfFormCreator.SetFactory(new _PdfFormFactory_303());
244260
using (PdfDocument pdfInnerDoc = new PdfDocument(new PdfWriter(DESTINATION_FOLDER + "add_index.pdf"))) {
245261
Document doc = new Document(pdfInnerDoc);
246262
doc.Add(new CheckBox("test1").SetBorder(new SolidBorder(ColorConstants.RED, 1)));
@@ -256,8 +272,8 @@ public virtual void AddIndexStrategySeparatesTheFields() {
256272
}
257273
}
258274

259-
private sealed class _PdfFormFactory_283 : PdfFormFactory {
260-
public _PdfFormFactory_283() {
275+
private sealed class _PdfFormFactory_303 : PdfFormFactory {
276+
public _PdfFormFactory_303() {
261277
}
262278

263279
public override PdfAcroForm GetAcroForm(PdfDocument document, bool createIfNotExist) {

itext.tests/itext.forms.tests/itext/forms/form/element/SignatureFieldAppearanceTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ public virtual void CustomModeTest() {
440440
flexContainer.SetProperty(Property.FLEX_WRAP, FlexWrapPropertyValue.WRAP);
441441
flexContainer.SetProperty(Property.FLEX_DIRECTION, FlexDirectionPropertyValue.ROW_REVERSE);
442442
flexContainer.SetProperty(Property.ALIGN_ITEMS, AlignmentPropertyValue.CENTER);
443-
flexContainer.Add(new iText.Layout.Element.Image(ImageDataFactory.Create(SOURCE_FOLDER + "1.png")).Scale(0.1f
444-
, 0.3f).SetPadding(10)).Add(new List().Add(new ListItem("Flex container with").SetListSymbol(ListNumberingType
443+
flexContainer.Add(new iText.Layout.Element.Image(ImageDataFactory.Create(SOURCE_FOLDER + "1.png")).Scale(0.5f
444+
, 0.5f).SetPadding(10)).Add(new List().Add(new ListItem("Flex container with").SetListSymbol(ListNumberingType
445445
.ZAPF_DINGBATS_1)).Add(new ListItem("image and list,").SetListSymbol(ListNumberingType.ZAPF_DINGBATS_2
446446
)).Add(new ListItem("wrap, row-reverse,").SetListSymbol(ListNumberingType.ZAPF_DINGBATS_3)).Add(new ListItem
447447
("green dots border").SetListSymbol(ListNumberingType.ZAPF_DINGBATS_4)).SetPadding(10)).SetBorder(new

0 commit comments

Comments
 (0)