Skip to content

Commit 4621195

Browse files
iText-CIpavel-alay
authored andcommitted
[RELEASE] Merge branch 'release/2.1.0'
2 parents b41f278 + a0b3778 commit 4621195

File tree

1,391 files changed

+7519
-53974
lines changed

Some content is hidden

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

1,391 files changed

+7519
-53974
lines changed

itext.tests/itext.html2pdf.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("ae4e5743-0665-4705-9a33-07ea57cdd269")]
1717

18-
[assembly: AssemblyVersion("2.0.2.0")]
19-
[assembly: AssemblyFileVersion("2.0.2.0")]
20-
[assembly: AssemblyInformationalVersion("2.0.2")]
18+
[assembly: AssemblyVersion("2.1.0.0")]
19+
[assembly: AssemblyFileVersion("2.1.0.0")]
20+
[assembly: AssemblyInformationalVersion("2.1.0")]
2121

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

itext.tests/itext.html2pdf.tests/itext.html2pdf.tests.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<WarningLevel>4</WarningLevel>
3434
</PropertyGroup>
3535
<ItemGroup>
36-
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
37-
<HintPath>$(SolutionDir)\packages\NUnit.3.4.1\lib\net40\nunit.framework.dll</HintPath>
36+
<Reference Include="nunit.framework, Version=3.7.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
37+
<HintPath>$(SolutionDir)\packages\NUnit.3.7.1\lib\net40\nunit.framework.dll</HintPath>
3838
<Private>True</Private>
3939
</Reference>
4040
<Reference Include="System" />
@@ -73,6 +73,14 @@
7373
<Project>{f9880dc4-f015-4413-af86-66d0e9512774}</Project>
7474
<Name>itext.pdftest</Name>
7575
</ProjectReference>
76+
<ProjectReference Include="..\..\..\styled-xml-parser\itext\itext.styledxmlparser\itext.styledxmlparser.csproj">
77+
<Project>{8636f290-00df-403e-b841-e4bfd6d9ce7a}</Project>
78+
<Name>itext.styledxmlparser</Name>
79+
</ProjectReference>
80+
<ProjectReference Include="..\..\..\svg\itext\itext.svg\itext.svg.csproj">
81+
<Project>{ddec35d2-5781-471d-5ea1-a6e433eddb11}</Project>
82+
<Name>itext.svg</Name>
83+
</ProjectReference>
7684
<ProjectReference Include="..\..\itext\itext.html2pdf\itext.html2pdf.csproj">
7785
<Project>{ff6ba09d-3655-466a-8c17-a7bfd3479ca1}</Project>
7886
<Name>itext.html2pdf</Name>
@@ -83,9 +91,7 @@
8391
<None Include="itext.snk" />
8492
<None Include="packages.config" />
8593
</ItemGroup>
86-
<ItemGroup>
87-
<Folder Include="itext\html2pdf\attach\impl" />
88-
</ItemGroup>
94+
<ItemGroup />
8995
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
9096
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
9197
Other similar extension points exist, see Microsoft.Common.targets.

itext.tests/itext.html2pdf.tests/itext.html2pdf.tests.netstandard.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
<StartupObject />
2525
<AssemblyName>itext.html2pdf.tests</AssemblyName>
2626
</PropertyGroup>
27-
<ItemGroup>
28-
</ItemGroup>
2927
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
3028
<PackageReference Include="Microsoft.NETCore.App">
3129
<Version>1.0.0</Version>
@@ -53,6 +51,8 @@
5351
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.netstandard.csproj" />
5452
<ProjectReference Include="..\..\..\itextcore\itext\itext.hyph\itext.hyph.netstandard.csproj" />
5553
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.netstandard.csproj" />
54+
<ProjectReference Include="..\..\..\styled-xml-parser\itext\itext.styledxmlparser\itext.styledxmlparser.netstandard.csproj" />
55+
<ProjectReference Include="..\..\..\svg\itext\itext.svg\itext.svg.netstandard.csproj" />
5656
<ProjectReference Include="..\..\itext\itext.html2pdf\itext.html2pdf.netstandard.csproj" />
5757
</ItemGroup>
5858
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">

itext.tests/itext.html2pdf.tests/itext/html2pdf/BackgroundTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: iText Software.
55
66
This program is free software; you can redistribute it and/or modify
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2018 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
using System;
44+
using System.IO;
45+
using iText.Forms;
46+
using iText.IO.Util;
47+
using iText.Kernel.Pdf;
48+
using iText.Kernel.Utils;
49+
using iText.Layout;
50+
using iText.Layout.Element;
51+
using iText.Test;
52+
53+
namespace iText.Html2pdf {
54+
/// <summary>
55+
/// This class is used for testing of pdfHTML conversion cases
56+
/// extends ExtendedITextTest test class
57+
/// </summary>
58+
public abstract class ExtendedHtmlConversionITextTest : ExtendedITextTest {
59+
/// <exception cref="System.IO.IOException"/>
60+
/// <exception cref="System.Exception"/>
61+
public virtual void ConvertToPdfAndCompare(String name, String sourceFolder, String destinationFolder) {
62+
ConvertToPdfAndCompare(name, sourceFolder, destinationFolder, false, sourceFolder);
63+
}
64+
65+
/// <exception cref="System.IO.IOException"/>
66+
/// <exception cref="System.Exception"/>
67+
public virtual void ConvertToPdfAndCompare(String name, String sourceFolder, String destinationFolder, bool
68+
tagged) {
69+
ConvertToPdfAndCompare(name, sourceFolder, destinationFolder, tagged, sourceFolder);
70+
}
71+
72+
/// <exception cref="System.IO.IOException"/>
73+
/// <exception cref="System.Exception"/>
74+
public virtual void ConvertToPdfAndCompare(String name, String sourceFolder, String destinationFolder, bool
75+
tagged, String fontsFolder) {
76+
String sourceHtml = sourceFolder + name + ".html";
77+
String cmpPdf = sourceFolder + "cmp_" + name + ".pdf";
78+
String destinationPdf = destinationFolder + name + ".pdf";
79+
ConverterProperties converterProperties = GetConverterProperties(fontsFolder);
80+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationPdf));
81+
if (tagged) {
82+
pdfDocument.SetTagged();
83+
}
84+
using (FileStream fileInputStream = new FileStream(sourceHtml, FileMode.Open, FileAccess.Read)) {
85+
HtmlConverter.ConvertToPdf(fileInputStream, pdfDocument, converterProperties);
86+
}
87+
System.Console.Out.WriteLine("html: file:///" + UrlUtil.ToNormalizedURI(sourceHtml).AbsolutePath + "\n");
88+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationPdf, cmpPdf, destinationFolder
89+
, "diff_" + name + "_"));
90+
}
91+
92+
/// <exception cref="System.IO.IOException"/>
93+
/// <exception cref="System.Exception"/>
94+
public virtual void ConvertToElementsAndCompare(String name, String sourceFolder, String destinationFolder
95+
) {
96+
ConvertToElementsAndCompare(name, sourceFolder, destinationFolder, false, sourceFolder);
97+
}
98+
99+
/// <exception cref="System.IO.IOException"/>
100+
/// <exception cref="System.Exception"/>
101+
public virtual void ConvertToElementsAndCompare(String name, String sourceFolder, String destinationFolder
102+
, bool tagged) {
103+
ConvertToElementsAndCompare(name, sourceFolder, destinationFolder, tagged, sourceFolder);
104+
}
105+
106+
/// <exception cref="System.IO.IOException"/>
107+
/// <exception cref="System.Exception"/>
108+
public virtual void ConvertToElementsAndCompare(String name, String sourceFolder, String destinationFolder
109+
, bool tagged, String fontsFolder) {
110+
String sourceHtml = sourceFolder + name + ".html";
111+
String cmpPdf = sourceFolder + "cmp_" + name + ".pdf";
112+
String destinationPdf = destinationFolder + name + ".pdf";
113+
ConverterProperties converterProperties = GetConverterProperties(fontsFolder);
114+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationPdf));
115+
if (tagged) {
116+
pdfDocument.SetTagged();
117+
}
118+
Document document = new Document(pdfDocument);
119+
using (FileStream fileInputStream = new FileStream(sourceHtml, FileMode.Open, FileAccess.Read)) {
120+
foreach (IElement element in HtmlConverter.ConvertToElements(fileInputStream, converterProperties)) {
121+
document.Add((IBlockElement)element);
122+
}
123+
}
124+
System.Console.Out.WriteLine("html: file:///" + UrlUtil.ToNormalizedURI(sourceHtml).AbsolutePath + "\n");
125+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationPdf, cmpPdf, destinationFolder
126+
, "diff_" + name + "_"));
127+
}
128+
129+
/// <exception cref="System.IO.IOException"/>
130+
/// <exception cref="System.Exception"/>
131+
/// <exception cref="Javax.Xml.Parsers.ParserConfigurationException"/>
132+
/// <exception cref="Org.Xml.Sax.SAXException"/>
133+
public virtual void ConvertToPdfAcroformFlattenAndCompare(String name, String sourceFolder, String destinationFolder
134+
, bool tagged) {
135+
String sourceHtml = sourceFolder + name + ".html";
136+
if (tagged) {
137+
name = name + "Tagged";
138+
}
139+
String outPdfPath = destinationFolder + name + ".pdf";
140+
String outPdfPathAcro = destinationFolder + name + "_acro.pdf";
141+
String outPdfPathFlatted = destinationFolder + name + "_acro_flatten.pdf";
142+
String cmpPdfPath = sourceFolder + "cmp_" + name + ".pdf";
143+
String cmpPdfPathAcro = sourceFolder + "cmp_" + name + "_acro.pdf";
144+
String cmpPdfPathAcroFlatten = sourceFolder + "cmp_" + name + "_acro_flatten.pdf";
145+
String diff1 = "diff1_" + name;
146+
String diff2 = "diff2_" + name;
147+
String diff3 = "diff3_" + name;
148+
//convert tagged PDF without acroform (from html with form elements)
149+
PdfWriter taggedWriter = new PdfWriter(outPdfPath);
150+
PdfDocument pdfTagged = new PdfDocument(taggedWriter);
151+
if (tagged) {
152+
pdfTagged.SetTagged();
153+
}
154+
HtmlConverter.ConvertToPdf(new FileStream(sourceHtml, FileMode.Open, FileAccess.Read), pdfTagged, new ConverterProperties
155+
().SetBaseUri(sourceFolder));
156+
//convert PDF with acroform
157+
PdfWriter writerAcro = new PdfWriter(outPdfPathAcro);
158+
PdfDocument pdfTaggedAcro = new PdfDocument(writerAcro);
159+
if (tagged) {
160+
pdfTaggedAcro.SetTagged();
161+
}
162+
ConverterProperties converterPropertiesAcro = new ConverterProperties();
163+
converterPropertiesAcro.SetBaseUri(sourceFolder);
164+
converterPropertiesAcro.SetCreateAcroForm(true);
165+
HtmlConverter.ConvertToPdf(new FileStream(sourceHtml, FileMode.Open, FileAccess.Read), pdfTaggedAcro, converterPropertiesAcro
166+
);
167+
System.Console.Out.WriteLine("html: file:///" + UrlUtil.ToNormalizedURI(sourceHtml).AbsolutePath + "\n");
168+
//flatted created tagged PDF with acroform
169+
PdfDocument document = new PdfDocument(new PdfReader(outPdfPathAcro), new PdfWriter(outPdfPathFlatted));
170+
PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(document, false);
171+
acroForm.FlattenFields();
172+
document.Close();
173+
//compare with cmp
174+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdfPath, cmpPdfPath, destinationFolder
175+
, diff1));
176+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdfPathAcro, cmpPdfPathAcro, destinationFolder
177+
, diff2));
178+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdfPathFlatted, cmpPdfPathAcroFlatten,
179+
destinationFolder, diff3));
180+
//compare tags structure if tagged
181+
if (tagged) {
182+
CompareTagStructure(outPdfPath, cmpPdfPath);
183+
CompareTagStructure(outPdfPathAcro, cmpPdfPathAcro);
184+
CompareTagStructure(outPdfPathFlatted, cmpPdfPathAcroFlatten);
185+
}
186+
}
187+
188+
/// <exception cref="System.IO.IOException"/>
189+
/// <exception cref="System.Exception"/>
190+
/// <exception cref="Javax.Xml.Parsers.ParserConfigurationException"/>
191+
/// <exception cref="Org.Xml.Sax.SAXException"/>
192+
private void CompareTagStructure(String outPath, String cmpPath) {
193+
CompareTool compareTool = new CompareTool();
194+
String tagStructureErrors = compareTool.CompareTagStructures(outPath, cmpPath);
195+
String resultMessage = "";
196+
if (tagStructureErrors != null) {
197+
resultMessage += tagStructureErrors + "\n";
198+
}
199+
NUnit.Framework.Assert.IsTrue(tagStructureErrors == null, resultMessage);
200+
}
201+
202+
private ConverterProperties GetConverterProperties(String fontsFolder) {
203+
ConverterProperties properties = new ConverterProperties().SetBaseUri(fontsFolder);
204+
return properties;
205+
}
206+
}
207+
}

itext.tests/itext.html2pdf.tests/itext/html2pdf/Html2ElementsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: iText Software.
55
66
This program is free software; you can redistribute it and/or modify

itext.tests/itext.html2pdf.tests/itext/html2pdf/Html2PdfTest.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: iText Software.
55
66
This program is free software; you can redistribute it and/or modify
@@ -45,6 +45,7 @@ source product.
4545
using iText.IO.Util;
4646
using iText.Kernel.Utils;
4747
using iText.Test;
48+
using iText.Test.Attributes;
4849

4950
namespace iText.Html2pdf {
5051
public class Html2PdfTest : ExtendedITextTest {
@@ -144,5 +145,19 @@ public virtual void HelloDivDocumentTest() {
144145
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "hello_div.pdf", sourceFolder
145146
+ "cmp_hello_div.pdf", destinationFolder, "diff03_"));
146147
}
148+
149+
/// <exception cref="System.IO.IOException"/>
150+
/// <exception cref="System.Exception"/>
151+
[NUnit.Framework.Test]
152+
[LogMessage(iText.Html2pdf.LogMessageConstant.WORKER_UNABLE_TO_PROCESS_OTHER_WORKER)]
153+
public virtual void ABlockInPTagTest() {
154+
//TODO after DEVSIX-2002 fix change cmp_ file and remove expected LogMessage annotation
155+
HtmlConverter.ConvertToPdf(new FileInfo(sourceFolder + "aBlockInPTag.html"), new FileInfo(destinationFolder
156+
+ "aBlockInPTag.pdf"));
157+
System.Console.Out.WriteLine("html: file:///" + UrlUtil.ToNormalizedURI(sourceFolder + "aBlockInPTag.html"
158+
).AbsolutePath + "\n");
159+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "aBlockInPTag.pdf", sourceFolder
160+
+ "cmp_aBlockInPTag.pdf", destinationFolder, "diff03_"));
161+
}
147162
}
148163
}

itext.tests/itext.html2pdf.tests/itext/html2pdf/ResourceResolverTest.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: iText Software.
55
66
This program is free software; you can redistribute it and/or modify
@@ -444,6 +444,26 @@ public void ResourceResolverTest16D()
444444
}
445445
}
446446

447+
[NUnit.Framework.Test]
448+
[NUnit.Framework.Ignore("The path to the image shall be changed to reference some available shared file in order to run the test correctly.")]
449+
public void ResourceResolverTest17()
450+
{
451+
String baseUri = sourceFolder;
452+
String outPdf = destinationFolder + "resourceResolverTest17.pdf";
453+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest17.pdf";
454+
using (
455+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest17.html", FileMode.Open,
456+
FileAccess.Read),
457+
fileOutputStream = new FileStream(outPdf, FileMode.Create))
458+
{
459+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
460+
new ConverterProperties().SetBaseUri(baseUri));
461+
NUnit.Framework.Assert.IsNull(
462+
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff17_"));
463+
}
464+
}
465+
466+
447467
// TODO test with absolute http links for resources?
448468
// TODO test with http base URI?
449469
}

itext.tests/itext.html2pdf.tests/itext/html2pdf/attach/impl/FontFaceSrcTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: iText Software.
55
66
This program is free software; you can redistribute it and/or modify
@@ -43,9 +43,9 @@ source product.
4343
using System;
4444
using System.IO;
4545
using System.Text.RegularExpressions;
46-
using iText.Html2pdf.Css;
47-
using iText.Html2pdf.Css.Parse;
4846
using iText.IO.Util;
47+
using iText.StyledXmlParser.Css;
48+
using iText.StyledXmlParser.Css.Parse;
4949
using iText.Test;
5050
using iText.Test.Attributes;
5151

@@ -119,7 +119,7 @@ public virtual void SrcPropertyTest() {
119119

120120
/// <exception cref="System.Exception"/>
121121
[NUnit.Framework.Test]
122-
[LogMessage(iText.Html2pdf.LogMessageConstant.QUOTE_IS_NOT_CLOSED_IN_CSS_EXPRESSION)]
122+
[LogMessage(iText.StyledXmlParser.LogMessageConstant.QUOTE_IS_NOT_CLOSED_IN_CSS_EXPRESSION)]
123123
public virtual void ParseBase64SrcTest() {
124124
CssStyleSheet styleSheet = CssStyleSheetParser.Parse(new FileStream(sourceFolder + "srcs2.css", FileMode.Open
125125
, FileAccess.Read));

itext.tests/itext.html2pdf.tests/itext/html2pdf/attach/impl/layout/Html2PdfPropertyTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: iText Software.
55
66
This program is free software; you can redistribute it and/or modify

0 commit comments

Comments
 (0)