Skip to content

Commit c9d0d70

Browse files
committed
[RELEASE] Merge branch 'release/2.1.1'
2 parents 4621195 + de60b7e commit c9d0d70

File tree

178 files changed

+5486
-177
lines changed

Some content is hidden

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

178 files changed

+5486
-177
lines changed

itext.html2pdf.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
Project("{28A44613-21BB-46E2-BB98-23808869FDDE}") = "itext.html2pdf", "itext\itext.html2pdf\itext.html2pdf.netstandard.csproj", "{FF6BA09D-3655-466A-8C17-A7BFD3479CA1}"
4+
EndProject
5+
Project("{28A44613-21BB-46E2-BB98-23808869FDDE}") = "itext.html2pdf.tests", "itext.tests\itext.html2pdf.tests\itext.html2pdf.tests.netstandard.csproj", "{AE4E5743-0665-4705-9A33-07EA57CDD269}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{FF6BA09D-3655-466A-8C17-A7BFD3479CA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{FF6BA09D-3655-466A-8C17-A7BFD3479CA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{FF6BA09D-3655-466A-8C17-A7BFD3479CA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{FF6BA09D-3655-466A-8C17-A7BFD3479CA1}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{AE4E5743-0665-4705-9A33-07EA57CDD269}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{AE4E5743-0665-4705-9A33-07EA57CDD269}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{AE4E5743-0665-4705-9A33-07EA57CDD269}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{AE4E5743-0665-4705-9A33-07EA57CDD269}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
GlobalSection(SolutionProperties) = preSolution
23+
HideSolutionNode = FALSE
24+
EndGlobalSection
25+
EndGlobal

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.1.0.0")]
19-
[assembly: AssemblyFileVersion("2.1.0.0")]
20-
[assembly: AssemblyInformationalVersion("2.1.0")]
18+
[assembly: AssemblyVersion("2.1.1.0")]
19+
[assembly: AssemblyFileVersion("2.1.1.0")]
20+
[assembly: AssemblyInformationalVersion("2.1.1")]
2121

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

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

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
<ProjectGuid>{AE4E5743-0665-4705-9A33-07EA57CDD269}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>
11-
</RootNamespace>
10+
<RootNamespace></RootNamespace>
1211
<AssemblyName>itext.html2pdf.tests</AssemblyName>
1312
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1413
<FileAlignment>512</FileAlignment>
@@ -45,42 +44,72 @@
4544
<Compile Include="Properties\AssemblyInfo.cs" />
4645
</ItemGroup>
4746
<ItemGroup>
48-
<ProjectReference Include="..\..\..\itextcore\itext\itext.forms\itext.forms.csproj">
47+
<ProjectReference Include="..\..\..\itextcore\itext\itext.forms\itext.forms.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.forms\itext.forms.csproj')">
4948
<Project>{e2828ac4-3c63-4b2a-b5ad-5f98862775be}</Project>
5049
<Name>itext.forms</Name>
5150
</ProjectReference>
52-
<ProjectReference Include="..\..\..\itextcore\itext\itext.hyph\itext.hyph.csproj">
51+
<Reference Include="itext.forms, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.forms\itext.forms.csproj')">
52+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.forms.dll</HintPath>
53+
</Reference>
54+
<ProjectReference Include="..\..\..\itextcore\itext\itext.hyph\itext.hyph.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.hyph\itext.hyph.csproj')">
5355
<Project>{56137079-541A-425A-AB97-43AF63793C97}</Project>
5456
<Name>itext.hyph</Name>
5557
</ProjectReference>
56-
<ProjectReference Include="..\..\..\itextcore\itext\itext.io\itext.io.csproj">
58+
<Reference Include="itext.hyph, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.hyph\itext.hyph.csproj')">
59+
<HintPath>$(SolutionDir)\packages\itext7.hyph.7.1.4\lib\net40\itext.hyph.dll</HintPath>
60+
</Reference>
61+
<ProjectReference Include="..\..\..\itextcore\itext\itext.io\itext.io.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.io\itext.io.csproj')">
5762
<Project>{cee5e7e1-1bf0-4be1-9941-903262ce2f83}</Project>
5863
<Name>itext.io</Name>
5964
</ProjectReference>
60-
<ProjectReference Include="..\..\..\itextcore\itext\itext.kernel\itext.kernel.csproj">
65+
<Reference Include="itext.io, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.io\itext.io.csproj')">
66+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.io.dll</HintPath>
67+
</Reference>
68+
<ProjectReference Include="..\..\..\itextcore\itext\itext.kernel\itext.kernel.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.kernel\itext.kernel.csproj')">
6169
<Project>{4e7819e8-7555-4e2e-9a01-d8718a2cfdda}</Project>
6270
<Name>itext.kernel</Name>
6371
</ProjectReference>
64-
<ProjectReference Include="..\..\..\itextcore\itext\itext.layout\itext.layout.csproj">
72+
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942" Condition="!Exists('..\..\..\itextcore\itext\itext.kernel\itext.kernel.csproj')">
73+
<HintPath>$(SolutionDir)\packages\Portable.BouncyCastle.1.8.1.3\lib\net40\BouncyCastle.Crypto.dll</HintPath>
74+
</Reference>
75+
<Reference Include="itext.kernel, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.kernel\itext.kernel.csproj')">
76+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.kernel.dll</HintPath>
77+
</Reference>
78+
<ProjectReference Include="..\..\..\itextcore\itext\itext.layout\itext.layout.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.layout\itext.layout.csproj')">
6579
<Project>{42173642-db52-44d3-9883-3e34c65c53bc}</Project>
6680
<Name>itext.layout</Name>
6781
</ProjectReference>
68-
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.csproj">
82+
<Reference Include="itext.layout, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.layout\itext.layout.csproj')">
83+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.layout.dll</HintPath>
84+
</Reference>
85+
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.csproj')">
6986
<Project>{9fc2f0b3-a8d2-46da-8724-72e00e67a8fa}</Project>
7087
<Name>itext.pdfa</Name>
7188
</ProjectReference>
72-
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj">
89+
<Reference Include="itext.pdfa, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.csproj')">
90+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.pdfa.dll</HintPath>
91+
</Reference>
92+
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj')">
7393
<Project>{f9880dc4-f015-4413-af86-66d0e9512774}</Project>
7494
<Name>itext.pdftest</Name>
7595
</ProjectReference>
76-
<ProjectReference Include="..\..\..\styled-xml-parser\itext\itext.styledxmlparser\itext.styledxmlparser.csproj">
96+
<Reference Include="itext.pdftest, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj')">
97+
<HintPath>$(SolutionDir)\packages\itext7.pdftest.7.1.4\lib\net40\itext.pdftest.dll</HintPath>
98+
</Reference>
99+
<ProjectReference Include="..\..\..\itextcore\itext\itext.styledxmlparser\itext.styledxmlparser.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.styledxmlparser\itext.styledxmlparser.csproj')">
77100
<Project>{8636f290-00df-403e-b841-e4bfd6d9ce7a}</Project>
78101
<Name>itext.styledxmlparser</Name>
79102
</ProjectReference>
80-
<ProjectReference Include="..\..\..\svg\itext\itext.svg\itext.svg.csproj">
103+
<Reference Include="itext.styledxmlparser, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.styledxmlparser\itext.styledxmlparser.csproj')">
104+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.styledxmlparser.dll</HintPath>
105+
</Reference>
106+
<ProjectReference Include="..\..\..\itextcore\itext\itext.svg\itext.svg.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.svg\itext.svg.csproj')">
81107
<Project>{ddec35d2-5781-471d-5ea1-a6e433eddb11}</Project>
82108
<Name>itext.svg</Name>
83109
</ProjectReference>
110+
<Reference Include="itext.svg, Version=7.1.4.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca" Condition="!Exists('..\..\..\itextcore\itext\itext.svg\itext.svg.csproj')">
111+
<HintPath>$(SolutionDir)\packages\itext7.7.1.4\lib\net40\itext.svg.dll</HintPath>
112+
</Reference>
84113
<ProjectReference Include="..\..\itext\itext.html2pdf\itext.html2pdf.csproj">
85114
<Project>{ff6ba09d-3655-466a-8c17-a7bfd3479ca1}</Project>
86115
<Name>itext.html2pdf</Name>

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
23
<PropertyGroup Label="Configuration">
34
<SignAssembly>True</SignAssembly>
45
<DelaySign>False</DelaySign>
@@ -44,15 +45,18 @@
4445
<Reference Include="System.Core" />
4546
</ItemGroup>
4647
<ItemGroup>
47-
<ProjectReference Include="..\..\..\itextcore\itext\itext.io\itext.io.netstandard.csproj" />
48-
<ProjectReference Include="..\..\..\itextcore\itext\itext.kernel\itext.kernel.netstandard.csproj" />
49-
<ProjectReference Include="..\..\..\itextcore\itext\itext.layout\itext.layout.netstandard.csproj" />
50-
<ProjectReference Include="..\..\..\itextcore\itext\itext.forms\itext.forms.netstandard.csproj" />
51-
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.netstandard.csproj" />
52-
<ProjectReference Include="..\..\..\itextcore\itext\itext.hyph\itext.hyph.netstandard.csproj" />
53-
<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" />
48+
<ProjectReference Include="..\..\..\itextcore\itext\itext.io\itext.io.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.io\itext.io.netstandard.csproj')" />
49+
<PackageReference Include="itext7" Version="7.1.4" Condition="!Exists('..\..\..\itextcore\itext\itext.io\itext.io.netstandard.csproj')" />
50+
<ProjectReference Include="..\..\..\itextcore\itext\itext.kernel\itext.kernel.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.kernel\itext.kernel.netstandard.csproj')" />
51+
<ProjectReference Include="..\..\..\itextcore\itext\itext.layout\itext.layout.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.layout\itext.layout.netstandard.csproj')" />
52+
<ProjectReference Include="..\..\..\itextcore\itext\itext.forms\itext.forms.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.forms\itext.forms.netstandard.csproj')" />
53+
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.pdfa\itext.pdfa.netstandard.csproj')" />
54+
<ProjectReference Include="..\..\..\itextcore\itext\itext.hyph\itext.hyph.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.hyph\itext.hyph.netstandard.csproj')" />
55+
<PackageReference Include="itext7.hyph" Version="7.1.4" Condition="!Exists('..\..\..\itextcore\itext\itext.hyph\itext.hyph.netstandard.csproj')" />
56+
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.netstandard.csproj')" />
57+
<PackageReference Include="itext7.pdftest" Version="7.1.4" Condition="!Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.netstandard.csproj')" />
58+
<ProjectReference Include="..\..\..\itextcore\itext\itext.styledxmlparser\itext.styledxmlparser.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.styledxmlparser\itext.styledxmlparser.netstandard.csproj')" />
59+
<ProjectReference Include="..\..\..\itextcore\itext\itext.svg\itext.svg.netstandard.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.svg\itext.svg.netstandard.csproj')" />
5660
<ProjectReference Include="..\..\itext\itext.html2pdf\itext.html2pdf.netstandard.csproj" />
5761
</ItemGroup>
5862
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text;
5+
using iText.IO.Util;
6+
using iText.Kernel.Pdf;
7+
using iText.Kernel.Utils;
8+
using iText.Layout;
9+
using iText.Layout.Element;
10+
using iText.Test;
11+
12+
namespace iText.Html2pdf {
13+
public class ExtendedFontPropertiesTest : ExtendedITextTest {
14+
private const String HTML_TOP = "<html><head>";
15+
16+
private const String HTML_BEGIN_BODY = "</head><body>";
17+
18+
private const String HTML_BOTTOM = "</body></html>";
19+
20+
private const String TR_OPEN = "<tr>";
21+
22+
private const String TD_OPEN = "<td>";
23+
24+
private const String TD_CLOSE = "</td>";
25+
26+
private const String TR_CLOSE = "</tr>";
27+
28+
private const String TABLE_OPEN = "<table>";
29+
30+
private const String TABLE_CLOSE = "</table>";
31+
32+
private const String DOCUMENT_PREFIX = "FOR_VISUAL_CMP_";
33+
34+
private const String COLUMN_DECLARATIONS = "<col width='50'><col width='50'><col width='50'><col width='300'>";
35+
36+
private const String TH_FONT_FAMILY = "<th scope='col'>Font-family</th>";
37+
38+
private const String TH_FONT_WEIGHT = "<th scope='col'>Font-weight</th>";
39+
40+
private const String TH_FONT_STYLE = "<th scope='col'>Font-style</th>";
41+
42+
private const String TH_RESULT = "<th scope='col' >Result</th>";
43+
44+
private const String TITLE_TAG = "<title>Font Family Test</title>";
45+
46+
private const String HTML_TITLE = "<h1>Font Family Test</h1>";
47+
48+
private const String TD_STYLE = "<td style = \"";
49+
50+
private const String FONT_FAMILY = " font-family: '";
51+
52+
private const String FONT_STYLE = "; font-style: ";
53+
54+
private const String FONT_WEIGHT = "'; font-weight: ";
55+
56+
/// <exception cref="System.IO.IOException"/>
57+
/// <exception cref="System.Exception"/>
58+
public virtual void RunTest(String htmlString, String sourceFolder, String destinationFolder, String fileName
59+
, String testName) {
60+
String outPdf = destinationFolder + fileName + ".pdf";
61+
String cmpPdf = sourceFolder + "cmp_" + fileName + ".pdf";
62+
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outPdf));
63+
Document doc = new Document(pdfDoc);
64+
byte[] bytes = htmlString.GetBytes(Encoding.UTF8);
65+
// save to html
66+
GenerateTestHtml(destinationFolder, fileName, bytes);
67+
// Convert to elements
68+
WriteToDocument(doc, bytes);
69+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, destinationFolder, "diff_"
70+
+ testName + "_"));
71+
}
72+
73+
/// <exception cref="System.IO.IOException"/>
74+
private void WriteToDocument(Document doc, byte[] bytes) {
75+
Stream @in = new MemoryStream(bytes);
76+
IList<IElement> arrayList = HtmlConverter.ConvertToElements(@in);
77+
foreach (IElement element in arrayList) {
78+
if (element is IBlockElement) {
79+
doc.Add((IBlockElement)element);
80+
}
81+
}
82+
doc.Close();
83+
}
84+
85+
/// <exception cref="System.IO.IOException"/>
86+
private void GenerateTestHtml(String destinationFolder, String fileName, byte[] bytes) {
87+
String htmlPath = destinationFolder + DOCUMENT_PREFIX + fileName + ".html";
88+
FileStream @out = new FileStream(htmlPath, FileMode.Create);
89+
System.Console.Out.WriteLine("html: file:///" + UrlUtil.ToNormalizedURI(htmlPath).AbsolutePath + "\n");
90+
@out.Dispose();
91+
}
92+
93+
public virtual String BuildDocumentTree(String[] fontFamilies, String[] fontWeights, String[] fontStyles,
94+
String[] cssFiles, String text) {
95+
StringBuilder builder = new StringBuilder();
96+
builder.Append(HTML_TOP);
97+
if (cssFiles != null) {
98+
foreach (String css in cssFiles) {
99+
builder.Append(" <link href='").Append(css).Append("' rel='stylesheet' type='text/css'>\n ");
100+
}
101+
}
102+
//Build Html top
103+
String styleTag = "<style>\n" + " th, td {text-align: center;\n" + " height: 45px; border: 1px solid black; }\n"
104+
+ " table {font-family: Courier; }" + " </style>\n";
105+
builder.Append(TITLE_TAG);
106+
builder.Append(styleTag);
107+
builder.Append(HTML_BEGIN_BODY);
108+
builder.Append(HTML_TITLE);
109+
builder.Append(TABLE_OPEN);
110+
builder.Append(COLUMN_DECLARATIONS);
111+
builder.Append(TR_OPEN);
112+
builder.Append(TH_FONT_FAMILY);
113+
builder.Append(TH_FONT_WEIGHT);
114+
builder.Append(TH_FONT_STYLE);
115+
builder.Append(TH_RESULT);
116+
builder.Append(TR_CLOSE);
117+
//Build body content
118+
foreach (String name in fontFamilies) {
119+
foreach (String weight in fontWeights) {
120+
foreach (String style in fontStyles) {
121+
// the tr
122+
builder.Append(TR_OPEN);
123+
// the first td
124+
builder.Append(TD_OPEN).Append(name).Append(TD_CLOSE);
125+
// the second td
126+
builder.Append(TD_OPEN).Append(weight).Append(TD_CLOSE);
127+
// the third td
128+
builder.Append(TD_OPEN).Append(style).Append(TD_CLOSE);
129+
// the fourth td
130+
builder.Append(TD_STYLE).Append(FONT_FAMILY).Append(name).Append(FONT_WEIGHT).Append(weight).Append(FONT_STYLE
131+
).Append(style).Append("\";>").Append(text).Append(TD_CLOSE);
132+
// the tr
133+
builder.Append(TR_CLOSE);
134+
}
135+
}
136+
}
137+
builder.Append(TABLE_CLOSE);
138+
builder.Append(HTML_BOTTOM);
139+
return builder.ToString();
140+
}
141+
}
142+
}

0 commit comments

Comments
 (0)