Skip to content

Commit 086d766

Browse files
committed
Merge branch 'release/2.0.0'
2 parents 58dfb66 + 54a6b3c commit 086d766

File tree

1,292 files changed

+6658
-3373
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,292 files changed

+6658
-3373
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("1.0.2.0")]
19-
[assembly: AssemblyFileVersion("1.0.2.0")]
20-
[assembly: AssemblyInformationalVersion("1.0.2")]
18+
[assembly: AssemblyVersion("2.0.0.0")]
19+
[assembly: AssemblyFileVersion("2.0.0.0")]
20+
[assembly: AssemblyInformationalVersion("2.0.0")]
2121

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
<Reference Include="System.Core" />
4242
</ItemGroup>
4343
<ItemGroup>
44-
<Compile Include="org\jsoup\**\*.cs" />
4544
<Compile Include="itext\html2pdf\**\*.cs" />
4645
<Compile Include="Properties\AssemblyInfo.cs" />
4746
</ItemGroup>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2017 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.Kernel.Utils;
46+
using iText.Test;
47+
48+
namespace iText.Html2pdf {
49+
public class BackgroundTest : ExtendedITextTest {
50+
public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
51+
.CurrentContext.TestDirectory) + "/resources/itext/html2pdf/css/BackgroundTest/";
52+
53+
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
54+
+ "/test/itext/html2pdf/css/BackgroundTest/";
55+
56+
[NUnit.Framework.OneTimeSetUp]
57+
public static void BeforeClass() {
58+
CreateDestinationFolder(destinationFolder);
59+
}
60+
61+
/// <exception cref="System.IO.IOException"/>
62+
/// <exception cref="System.Exception"/>
63+
[NUnit.Framework.Test]
64+
[NUnit.Framework.Ignore("DEVSIX-1708")]
65+
public virtual void BackgroundSizeTest01() {
66+
HtmlConverter.ConvertToPdf(new FileInfo(sourceFolder + "backgroundsize01.html"), new FileInfo(destinationFolder
67+
+ "backgroundsize01.pdf"));
68+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "backgroundsize01.pdf"
69+
, sourceFolder + "cmp_backgroundsize01.pdf", destinationFolder, "diff01_"));
70+
}
71+
}
72+
}

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ source product.
4242
*/
4343
using System;
4444
using System.Collections.Generic;
45+
using iText.Html2pdf.Attach.Impl;
4546
using iText.Layout.Element;
4647
using iText.Layout.Properties;
4748
using iText.Test;
@@ -65,7 +66,7 @@ public virtual void HtmlToElementsTest01() {
6566
NUnit.Framework.Assert.IsTrue(lst[0] is Paragraph);
6667
Paragraph p = (Paragraph)lst[0];
6768
NUnit.Framework.Assert.AreEqual("Hello world!", ((Text)p.GetChildren()[0]).GetText());
68-
NUnit.Framework.Assert.AreEqual(12f, (float)(Object)p.GetProperty<float?>(Property.FONT_SIZE), 1e-10);
69+
NUnit.Framework.Assert.AreEqual(12f, p.GetProperty<UnitValue>(Property.FONT_SIZE).GetValue(), 1e-10);
6970
}
7071

7172
/// <exception cref="System.IO.IOException"/>
@@ -79,7 +80,7 @@ public virtual void HtmlToElementsTest02() {
7980
NUnit.Framework.Assert.AreEqual(2, t.GetNumberOfRows());
8081
NUnit.Framework.Assert.AreEqual("123", ((Text)(((Paragraph)t.GetCell(0, 0).GetChildren()[0]).GetChildren()
8182
[0])).GetText());
82-
NUnit.Framework.Assert.AreEqual(24f, (float)(Object)t.GetProperty<float?>(Property.FONT_SIZE), 1e-10);
83+
NUnit.Framework.Assert.AreEqual(24f, t.GetProperty<UnitValue>(Property.FONT_SIZE).GetValue(), 1e-10);
8384
}
8485

8586
/// <exception cref="System.IO.IOException"/>
@@ -147,5 +148,25 @@ public virtual void HtmlToElementsTest08() {
147148
String html = "<html><p>Hello world!</p><meta name=\"author\" content=\"Bruno\"><table><tr><td>123</td><td><456></td></tr><tr><td>Long cell</td></tr></table><p>Hello world!</p></html>";
148149
HtmlConverter.ConvertToElements(html);
149150
}
151+
152+
/// <exception cref="System.IO.IOException"/>
153+
[NUnit.Framework.Test]
154+
public virtual void HtmlToElementsTest09() {
155+
//Test OutlineHandler exception throwing
156+
/*
157+
Outlines require a PdfDocument, and OutlineHandler is based around its availability
158+
Any convert to elements workflow of course doesn't have a PdfDocument.
159+
Instead of throwing an NPE when trying it, the OutlineHandler will check for the existence of a pdfDocument
160+
If no PdfDocument is found, the handler will do nothing silently
161+
*/
162+
String html = "<html><p>Hello world!</p><meta name=\"author\" content=\"Bruno\"><table><tr><td>123</td><td><456></td></tr><tr><td>Long cell</td></tr></table><p>Hello world!</p></html>";
163+
ConverterProperties props = new ConverterProperties();
164+
OutlineHandler outlineHandler = new OutlineHandler();
165+
outlineHandler.PutTagPriorityMapping("h1", 1);
166+
outlineHandler.PutTagPriorityMapping("h3", 2);
167+
outlineHandler.PutTagPriorityMapping("p", 3);
168+
props.SetOutlineHandler(outlineHandler);
169+
HtmlConverter.ConvertToElements(html);
170+
}
150171
}
151172
}

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

Lines changed: 106 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,16 @@ source product.
4949
using iText.Kernel;
5050
using iText.Test;
5151
using iText.Test.Attributes;
52+
using NUnit.Framework;
5253

5354
namespace iText.Html2pdf {
5455
public class ResourceResolverTest : ExtendedITextTest {
55-
public static readonly String sourceFolder = TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext.CurrentContext.TestDirectory) + "/resources/itext/html2pdf/ResourceResolverTest/";
56+
public static readonly String sourceFolder =
57+
TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext.CurrentContext.TestDirectory) +
58+
"/resources/itext/html2pdf/ResourceResolverTest/";
5659

5760
public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory
58-
+ "/test/itext/html2pdf/ResourceResolverTest/";
61+
+ "/test/itext/html2pdf/ResourceResolverTest/";
5962

6063
[NUnit.Framework.OneTimeSetUp]
6164
public static void BeforeClass() {
@@ -70,71 +73,149 @@ public virtual void ResourceResolverTest03() {
7073
String outPdf = destinationFolder + "resourceResolverTest03.pdf";
7174
String cmpPdf = sourceFolder + "cmp_resourceResolverTest03.pdf";
7275

73-
using (FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest03.html", FileMode.Open, FileAccess.Read),
74-
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
75-
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().SetBaseUri(baseUri));
76-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff03_"
76+
using (
77+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest03.html", FileMode.Open,
78+
FileAccess.Read),
79+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
80+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
81+
new ConverterProperties().SetBaseUri(baseUri));
82+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder,
83+
"diff03_"
7784
));
7885
}
7986
}
80-
87+
8188
/// <exception cref="System.IO.IOException"/>
8289
/// <exception cref="System.Exception"/>
8390
[NUnit.Framework.Test]
84-
public virtual void ResourceResolverTest07()
85-
{
91+
public virtual void ResourceResolverTest07() {
8692
String outPdf = destinationFolder + "resourceResolverTest07.pdf";
8793
String cmpPdf = sourceFolder + "cmp_resourceResolverTest07.pdf";
8894
HtmlConverter.ConvertToPdf(new FileInfo(sourceFolder + "resourceResolverTest07.html"), new FileInfo(outPdf
8995
));
90-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff07_"
96+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder,
97+
"diff07_"
9198
));
9299
}
93100

94101
/// <exception cref="System.IO.IOException"/>
95102
/// <exception cref="System.Exception"/>
96103
[NUnit.Framework.Test]
97-
public virtual void ResourceResolverTest09()
98-
{
104+
public virtual void ResourceResolverTest09() {
99105
String outPdf = destinationFolder + "resourceResolverTest09.pdf";
100106
String cmpPdf = sourceFolder + "cmp_resourceResolverTest09.pdf";
101107
HtmlConverter.ConvertToPdf(new FileInfo(sourceFolder + "resourceResolverTest09.html"), new FileInfo(outPdf
102108
));
103-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff09_"
109+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder,
110+
"diff09_"
104111
));
105112
}
106113

107114
/// <exception cref="System.IO.IOException"/>
108115
/// <exception cref="System.Exception"/>
109116
[NUnit.Framework.Test]
110-
public virtual void ResourceResolverTest10()
111-
{
117+
public virtual void ResourceResolverTest10() {
112118
String outPdf = destinationFolder + "resourceResolverTest10.pdf";
113119
String cmpPdf = sourceFolder + "cmp_resourceResolverTest10.pdf";
114-
using (FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest10.html", FileMode.Open, FileAccess.Read),
115-
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
116-
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().SetBaseUri("%homepath%"));
120+
using (
121+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest10.html", FileMode.Open,
122+
FileAccess.Read),
123+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
124+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
125+
new ConverterProperties().SetBaseUri("%homepath%"));
117126
NUnit.Framework.Assert.IsNull(
118127
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff10_"));
119-
}
128+
}
120129
}
121130

122131
/// <exception cref="System.IO.IOException"/>
123132
/// <exception cref="System.Exception"/>
124133
[NUnit.Framework.Test]
125-
public virtual void ResourceResolverTest11()
126-
{
134+
public virtual void ResourceResolverTest11() {
127135
String outPdf = destinationFolder + "resourceResolverTest11.pdf";
128136
String cmpPdf = sourceFolder + "cmp_resourceResolverTest11.pdf";
129-
using (FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest11.html", FileMode.Open, FileAccess.Read),
130-
fileOutputStream = new FileStream(outPdf, FileMode.Create))
131-
{
132-
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream, new ConverterProperties().SetBaseUri("https://en.wikipedia.org/wiki/Welsh_Corgi"));
137+
using (
138+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest11.html", FileMode.Open,
139+
FileAccess.Read),
140+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
141+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
142+
new ConverterProperties().SetBaseUri("https://en.wikipedia.org/wiki/Welsh_Corgi"));
133143
NUnit.Framework.Assert.IsNull(
134144
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff11_"));
135145
}
136146
}
137147

148+
[NUnit.Framework.Test]
149+
[Ignore("DEVSIX-1668")]
150+
public void ResourceResolverTest12() {
151+
String baseUri = sourceFolder + "path with spaces";
152+
153+
String outPdf = destinationFolder + "resourceResolverTest12.pdf";
154+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest12.pdf";
155+
using (
156+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest12.html", FileMode.Open,
157+
FileAccess.Read),
158+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
159+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
160+
new ConverterProperties().SetBaseUri(baseUri));
161+
NUnit.Framework.Assert.IsNull(
162+
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff12_"));
163+
}
164+
}
165+
166+
[NUnit.Framework.Test]
167+
public void ResourceResolverTest13() {
168+
String baseUri = sourceFolder;
169+
170+
String outPdf = destinationFolder + "resourceResolverTest13.pdf";
171+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest13.pdf";
172+
using (
173+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest13.html", FileMode.Open,
174+
FileAccess.Read),
175+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
176+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
177+
new ConverterProperties().SetBaseUri(baseUri));
178+
NUnit.Framework.Assert.IsNull(
179+
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff13_"));
180+
}
181+
}
182+
183+
[NUnit.Framework.Test]
184+
[Ignore("DEVSIX-1668")]
185+
public void ResourceResolverTest14() {
186+
String baseUri = sourceFolder + "path%20with%20spaces";
187+
188+
String outPdf = destinationFolder + "resourceResolverTest14.pdf";
189+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest14.pdf";
190+
using (
191+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest12.html", FileMode.Open,
192+
FileAccess.Read),
193+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
194+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
195+
new ConverterProperties().SetBaseUri(baseUri));
196+
NUnit.Framework.Assert.IsNull(
197+
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff14_"));
198+
}
199+
}
200+
201+
[NUnit.Framework.Test]
202+
203+
public void ResourceResolverTest15() {
204+
String baseUri = sourceFolder;
205+
206+
String outPdf = destinationFolder + "resourceResolverTest15.pdf";
207+
String cmpPdf = sourceFolder + "cmp_resourceResolverTest15.pdf";
208+
using (
209+
FileStream fileInputStream = new FileStream(sourceFolder + "resourceResolverTest15.html", FileMode.Open,
210+
FileAccess.Read),
211+
fileOutputStream = new FileStream(outPdf, FileMode.Create)) {
212+
HtmlConverter.ConvertToPdf(fileInputStream, fileOutputStream,
213+
new ConverterProperties().SetBaseUri(baseUri));
214+
NUnit.Framework.Assert.IsNull(
215+
new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff15_"));
216+
}
217+
}
218+
138219

139220
// TODO test with absolute http links for resources?
140221
// TODO test with http base URI?

0 commit comments

Comments
 (0)