Skip to content

Commit 2f40ee8

Browse files
committed
[RELEASE] iText 7 pdfHTML - 2.1.6
https://github.com/itext/i7j-pdfhtml/releases/tag/2.1.6 * release/2.1.6: [RELEASE] 2.1.6-SNAPSHOT -> 2.1.6 Unignore tests, update cmp files and add TODO Exclude internal classes from public javadocs. Remove subpackages from the html2pdf pom file. Update cmp files Deprecate VISIBLE and OVERFLOW in CssConstants Add test demonstrating the problem of baseline alignment of checkboxes Upload spotbugs report to SonarQube Allow overriding default font family easier for DefaultFontProvider Make html2pdf tests extend ExtendedITextTest Add missing copyright headers Add new test demonstrating pdfHTML being too lenient when treating font CSS property Move most of CssStyleSheetParserTest from pdfHTML to SXP Add missing copyright headers Add langAttributeHtmlForTaggedPdfTest Add missing copyright headers Add tests in html2pdf for surrogate pairs. DEVSIX-3301 Update cmp-s Update License.md for all AGPL products Update cmp files Add missing copyright headers Add new tests: visibleAndHiddenPropertyCssTest Improve javadocs. Unignore test and update cmp-file Remove ToDo remark Refresh cmp files and ToDos Remove 7.0 related branches from Jenkinsfile Refactor code, add comments Make substitutional addFont method for addCalligraphFonts Override addFont method in DefaultfontProvide Change the order of font loading in DefaultFontProvider Change font loading order [RELEASE] Update dependency versions
2 parents d0a9a2d + 0f3bf4e commit 2f40ee8

File tree

147 files changed

+1483
-480
lines changed

Some content is hidden

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

147 files changed

+1483
-480
lines changed

Jenkinsfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pipeline {
6161
steps {
6262
withMaven(jdk: "${JDK_VERSION}", maven: 'M3', mavenLocalRepo: '.repository') {
6363
withSonarQubeEnv('Sonar') {
64-
sh 'mvn --activate-profiles test -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report sonar:sonar ' + sonarBranchName + ' ' + sonarBranchTarget
64+
sh 'mvn --activate-profiles test -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent verify org.jacoco:jacoco-maven-plugin:report -Dsonar.java.spotbugs.reportPaths="target/spotbugs.xml" sonar:sonar ' + sonarBranchName + ' ' + sonarBranchTarget
6565
}
6666
}
6767
}
@@ -91,8 +91,6 @@ pipeline {
9191
anyOf {
9292
branch "master"
9393
branch "develop"
94-
branch "7.0"
95-
branch "7.0-master"
9694
}
9795
}
9896
steps {

LICENSE.md

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,16 @@
1-
This program is free software; you can redistribute it and/or modify
2-
it under the terms of the GNU Affero General Public License version 3
3-
as published by the Free Software Foundation with the addition of the
4-
following permission added to Section 15 as permitted in Section 7(a):
5-
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
6-
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
7-
OF THIRD PARTY RIGHTS
1+
This program is offered under a commercial and under the AGPL license.
2+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
83

9-
This program is distributed in the hope that it will be useful, but
10-
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11-
or FITNESS FOR A PARTICULAR PURPOSE.
12-
See the GNU Affero General Public License for more details.
13-
You should have received a copy of the GNU Affero General Public License
14-
along with this program; if not, see http://www.gnu.org/licenses or write to
15-
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16-
Boston, MA, 02110-1301 USA, or download the license from the following URL:
17-
http://itextpdf.com/terms-of-use/
18-
19-
The interactive user interfaces in modified source and object code versions
20-
of this program must display Appropriate Legal Notices, as required under
21-
Section 5 of the GNU Affero General Public License.
4+
AGPL licensing:
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU Affero General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
229

23-
In accordance with Section 7(b) of the GNU Affero General Public License,
24-
a covered work must retain the producer line in every PDF that is created
25-
or manipulated using iText.
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU Affero General Public License for more details.
2614

27-
You can be released from the requirements of the license by purchasing
28-
a commercial license. Buying such a license is mandatory as soon as you
29-
develop commercial activities involving the iText software without
30-
disclosing the source code of your own applications.
31-
These activities include: offering paid services to customers as an ASP,
32-
serving PDFs on the fly in a web application, shipping iText with a closed
33-
source product.
34-
35-
For more information, please contact iText Software Corp. at this
36-
15+
You should have received a copy of the GNU Affero General Public License
16+
along with this program. If not, see <https://www.gnu.org/licenses/>.

findbugs-filter.xml

Lines changed: 0 additions & 30 deletions
This file was deleted.

pom.xml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.8</version>
7+
<version>7.1.9</version>
88
<relativePath/>
99
</parent>
1010
<artifactId>html2pdf</artifactId>
11-
<version>2.1.5</version>
11+
<version>2.1.6</version>
1212
<name>pdfHTML</name>
1313
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
1414
them to PDF.</description>
@@ -89,16 +89,6 @@
8989
</resource>
9090
</resources>
9191
<plugins>
92-
<plugin>
93-
<groupId>com.github.spotbugs</groupId>
94-
<artifactId>spotbugs-maven-plugin</artifactId>
95-
<version>${spotbugs.version}</version>
96-
<configuration>
97-
<threshold>High</threshold>
98-
<failOnError>true</failOnError>
99-
<excludeFilterFile>findbugs-filter.xml</excludeFilterFile>
100-
</configuration>
101-
</plugin>
10292
<plugin>
10393
<groupId>external.atlassian.jgitflow</groupId>
10494
<artifactId>jgitflow-maven-plugin</artifactId>
@@ -120,7 +110,12 @@
120110
<artifactId>maven-javadoc-plugin</artifactId>
121111
<version>${javadoc.version}</version>
122112
<configuration>
123-
<subpackages>com.itextpdf.html2pdf</subpackages>
113+
<sourceFileExcludes>
114+
<sourceFileExclude>com/itextpdf/html2pdf/attach/impl/layout/BodyHtmlStylesContainer.java</sourceFileExclude>
115+
116+
<!-- ProductInfo -->
117+
<sourceFileExclude>**/Html2PdfProductInfo.java</sourceFileExclude>
118+
</sourceFileExcludes>
124119
<groups>
125120
<group>
126121
<title>pdfHTML</title>

src/main/java/com/itextpdf/html2pdf/attach/impl/tags/PTagWorker.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,11 @@ This file is part of the iText (R) project.
6565
* This is how this worker processes the &lt;p&gt; tag:
6666
* <ul>
6767
* <li> if the worker meets a text or an inline element, it processes them with a help of
68-
* the {@link com.itextpdf.html2pdf.attach.util.WaitingInlineElementsHelper} instance</li>
68+
* the {@link com.itextpdf.html2pdf.attach.util.WaitingInlineElementsHelper} instance
6969
*
7070
* <li> if the worker meets a block element without inline displaying or
7171
* an inline element with the {@code display: block} style, it wraps all the content which hasn't been handled yet
7272
* into a {@code com.itextpdf.layout.element.Paragraph} object and adds this paragraph to the resultant {@code com.itextpdf.layout.element.Div} object
73-
* </li>
7473
* </ul>
7574
*/
7675
public class PTagWorker implements ITagWorker, IDisplayAware {

src/main/java/com/itextpdf/html2pdf/attach/util/WaitingInlineElementsHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ This file is part of the iText (R) project.
5656
import com.itextpdf.layout.element.ListItem;
5757
import com.itextpdf.layout.element.Paragraph;
5858
import com.itextpdf.layout.element.Text;
59+
import com.itextpdf.styledxmlparser.css.CommonCssConstants;
5960
import com.itextpdf.styledxmlparser.util.WhiteSpaceUtil;
6061

6162
import java.util.ArrayList;
@@ -178,7 +179,7 @@ public void flushHangingLeaves(IPropertyContainer container) {
178179
Paragraph p = createLeavesContainer();
179180
if (p != null) {
180181
Map<String, String> map = new HashMap<>();
181-
map.put(CssConstants.OVERFLOW, CssConstants.VISIBLE);
182+
map.put(CssConstants.OVERFLOW, CommonCssConstants.VISIBLE);
182183
OverflowApplierUtil.applyOverflow(map, p);
183184
if (container instanceof Document) {
184185
((Document) container).add(p);

src/main/java/com/itextpdf/html2pdf/css/CssConstants.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public class CssConstants extends CommonCssConstants {
9494
/** The Constant OUTLINE_OFFSET. */
9595
public static final String OUTLINE_OFFSET = "outline-offset";
9696

97-
/** The Constant OVERFLOW. */
97+
/** The Constant OVERFLOW. @Deprecated in favour of CommonCssConstants.OVERFLOW */
98+
@Deprecated
9899
public static final String OVERFLOW = "overflow";
99100

100101
/** The Constant OVERFLOW_X. */
@@ -121,7 +122,10 @@ public class CssConstants extends CommonCssConstants {
121122
/** The Constant VERTICAL_ALIGN. */
122123
public static final String VERTICAL_ALIGN = "vertical-align";
123124

124-
/** The Constant VISIBLE. */
125+
/** The Constant VISIBLE.
126+
* @deprecated in favour of StyledXmlParser
127+
*/
128+
@Deprecated
125129
public static final String VISIBLE = "visible";
126130

127131
// property values
@@ -262,7 +266,7 @@ public class CssConstants extends CommonCssConstants {
262266

263267
/** The Constant OVERFLOW_VALUES. */
264268
public static final Set<String> OVERFLOW_VALUES = new HashSet<>(
265-
Arrays.asList(new String[] {VISIBLE, HIDDEN, SCROLL, AUTO}));
269+
Arrays.asList(new String[] {CommonCssConstants.VISIBLE, HIDDEN, SCROLL, AUTO}));
266270

267271
// pseudo-elements
268272

src/main/java/com/itextpdf/html2pdf/resolver/font/DefaultFontProvider.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ This file is part of the iText (R) project.
5353
import java.io.InputStream;
5454
import java.lang.reflect.Method;
5555
import java.util.ArrayList;
56+
import java.util.List;
5657

5758
/**
5859
* The default {@link BasicFontProvider} for pdfHTML, that, as opposed to
@@ -66,6 +67,8 @@ public class DefaultFontProvider extends BasicFontProvider {
6667
*/
6768
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(DefaultFontProvider.class);
6869

70+
private static final String DEFAULT_FONT_FAMILY = "Times";
71+
6972
/** The path to the shipped fonts. */
7073
private static final String SHIPPED_FONT_RESOURCE_PATH = "com/itextpdf/html2pdf/font/";
7174

@@ -92,6 +95,12 @@ public class DefaultFontProvider extends BasicFontProvider {
9295
private static final Range FREE_FONT_RANGE = new RangeBuilder()
9396
.addRange(0, 0x058F).addRange(0x0E80, Integer.MAX_VALUE).create();
9497

98+
99+
//we want to add free fonts to font provider before calligraph fonts. However, the existing public API states
100+
// that addCalligraphFonts() should be used first to load calligraph fonts and to define the range for loading free fonts.
101+
// In order to maintain backward compatibility, this temporary field is used to stash calligraph fonts before free fonts are loaded.
102+
private List<byte[]> calligraphyFontsTempList = new ArrayList<>();
103+
95104
/**
96105
* Creates a new {@link DefaultFontProvider} instance.
97106
*/
@@ -107,10 +116,30 @@ public DefaultFontProvider() {
107116
* @param registerSystemFonts use true if you want to register the system fonts (can require quite some resources)
108117
*/
109118
public DefaultFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFreeFonts, boolean registerSystemFonts) {
110-
super(registerStandardPdfFonts, registerSystemFonts);
119+
this(registerStandardPdfFonts, registerShippedFreeFonts, registerSystemFonts, DEFAULT_FONT_FAMILY);
120+
}
121+
122+
/**
123+
* Creates a new {@link DefaultFontProvider} instance.
124+
*
125+
* @param registerStandardPdfFonts use true if you want to register the standard Type 1 fonts (can't be embedded)
126+
* @param registerShippedFreeFonts use true if you want to register the shipped fonts (can be embedded)
127+
* @param registerSystemFonts use true if you want to register the system fonts (can require quite some resources)
128+
* @param defaultFontFamily default font family
129+
*/
130+
public DefaultFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFreeFonts, boolean registerSystemFonts, String defaultFontFamily) {
131+
super(registerStandardPdfFonts, registerSystemFonts, defaultFontFamily);
111132
if (registerShippedFreeFonts) {
112-
addShippedFreeFonts(addCalligraphFonts());
133+
addAllAvailableFonts(addCalligraphFonts());
134+
}
135+
}
136+
137+
private void addAllAvailableFonts(Range rangeToLoad) {
138+
addShippedFreeFonts(rangeToLoad);
139+
for(byte[] fontData : calligraphyFontsTempList) {
140+
addFont(fontData, null);
113141
}
142+
calligraphyFontsTempList = null;
114143
}
115144

116145
/**
@@ -148,8 +177,9 @@ protected Range addCalligraphFonts() {
148177
try {
149178
Method m = klass.getMethod(methodName);
150179
ArrayList<byte[]> fontStreams = (ArrayList<byte[]>) m.invoke(null, null);
151-
for (byte[] font : fontStreams)
152-
addFont(font);
180+
for (byte[] font : fontStreams) {
181+
this.calligraphyFontsTempList.add(font);
182+
}
153183
// here we return a unicode range that excludes the loaded from the calligraph module fonts
154184
// i.e. the unicode range that is to be rendered with standard or shipped free fonts
155185
return FREE_FONT_RANGE;
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2019 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
package com.itextpdf.html2pdf;
24+
25+
import com.itextpdf.io.LogMessageConstant;
26+
import com.itextpdf.kernel.utils.CompareTool;
27+
import com.itextpdf.test.ExtendedITextTest;
28+
import com.itextpdf.test.annotations.LogMessage;
29+
import com.itextpdf.test.annotations.LogMessages;
30+
import com.itextpdf.test.annotations.type.IntegrationTest;
31+
import org.junit.Assert;
32+
import org.junit.BeforeClass;
33+
import org.junit.Test;
34+
import org.junit.experimental.categories.Category;
35+
36+
import java.io.File;
37+
import java.io.IOException;
38+
39+
@Category(IntegrationTest.class)
40+
public class SurrogatePairsTests extends ExtendedITextTest {
41+
public static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/SurrogatePairsTests/";
42+
public static final String destinationFolder = "./target/test/com/itextpdf/html2pdf/SurrogatePairsTests/";
43+
private static final String TYPOGRAPHY_WARNING = "Cannot find pdfCalligraph module, which was implicitly required by one of the layout properties";
44+
45+
@BeforeClass
46+
public static void beforeClass() {
47+
createOrClearDestinationFolder(destinationFolder);
48+
}
49+
50+
@Test
51+
@LogMessages(messages = {
52+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
53+
public void surrogatePairFrom2Chars() throws IOException, InterruptedException {
54+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairFrom2Chars.html"),
55+
new File(destinationFolder + "surrogatePairFrom2Chars.pdf"));
56+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairFrom2Chars.pdf",
57+
sourceFolder + "cmp_surrogatePairFrom2Chars.pdf", destinationFolder));
58+
}
59+
60+
@Test
61+
@LogMessages(messages = {
62+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
63+
public void surrogatePair2Pairs() throws IOException, InterruptedException {
64+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePair2Pairs.html"),
65+
new File(destinationFolder + "surrogatePair2Pairs.pdf"));
66+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePair2Pairs.pdf",
67+
sourceFolder + "cmp_surrogatePair2Pairs.pdf", destinationFolder));
68+
}
69+
70+
@Test
71+
@LogMessages(messages = {
72+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
73+
public void surrogatePairFullCharacter() throws IOException, InterruptedException {
74+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairFullCharacter.html"),
75+
new File(destinationFolder + "surrogatePairFullCharacter.pdf"));
76+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairFullCharacter.pdf",
77+
sourceFolder + "cmp_surrogatePairFullCharacter.pdf", destinationFolder));
78+
}
79+
80+
@Test
81+
//TODO DEVSIX-3307
82+
@LogMessages(messages = {
83+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2),
84+
@LogMessage(messageTemplate = LogMessageConstant.FONT_SUBSET_ISSUE)})
85+
public void surrogatePairCombingFullSurrs() throws IOException, InterruptedException {
86+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairCombingFullSurrs.html"),
87+
new File(destinationFolder + "surrogatePairCombingFullSurrs.pdf"));
88+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairCombingFullSurrs.pdf",
89+
sourceFolder + "cmp_surrogatePairCombingFullSurrs.pdf", destinationFolder));
90+
}
91+
92+
@Test
93+
//TODO DEVSIX-3307
94+
@LogMessages(messages = {
95+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2),
96+
@LogMessage(messageTemplate = LogMessageConstant.FONT_SUBSET_ISSUE)})
97+
public void surrogatePairCombingFullSurrsWithNoSurrs() throws IOException, InterruptedException {
98+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairCombingFullSurrsWithNoSurrs.html"),
99+
new File(destinationFolder + "surrogatePairCombingFullSurrsWithNoSurrs.pdf"));
100+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairCombingFullSurrsWithNoSurrs.pdf",
101+
sourceFolder + "cmp_surrogatePairCombingFullSurrsWithNoSurrs.pdf", destinationFolder));
102+
}
103+
104+
@Test
105+
//TODO DEVSIX-3307
106+
@LogMessages(messages = {
107+
@LogMessage(messageTemplate = TYPOGRAPHY_WARNING, count = 2)})
108+
public void surrogatePairCombinationOf3TypesPairs() throws IOException, InterruptedException {
109+
HtmlConverter.convertToPdf(new File(sourceFolder + "surrogatePairCombinationOf3TypesPairs.html"),
110+
new File(destinationFolder + "surrogatePairCombinationOf3TypesPairs.pdf"));
111+
Assert.assertNull(new CompareTool().compareByContent(destinationFolder + "surrogatePairCombinationOf3TypesPairs.pdf",
112+
sourceFolder + "cmp_surrogatePairCombinationOf3TypesPairs.pdf", destinationFolder));
113+
}
114+
}

0 commit comments

Comments
 (0)