Skip to content

Commit b942f42

Browse files
committed
[RELEASE] iText 7 pdfHTML - 2.1.4
https://github.com/itext/i7j-pdfhtml/releases/tag/2.1.4 * release/2.1.4: [RELEASE] 2.1.4-SNAPSHOT -> 2.1.4 Add a new test demonstrating the problem of total number of pages being displayed incorrectly Add test that illustrates table width problem Remove log messages Add test to reproduce the issue Activate SpotBugs and add exclusions for current errors Add Jenkinsfile Implement disabled pseudo class selector. Add some new tests. Adjust test and html file, add ToDo remark Update cmp files Update some more cmps. Update cmps related to correct default SVG font-size metric processing. Make addCalligraphFonts protected, add javadoc Add a test with a chain of css-imports. add test for DEVSIX-2231 Update cmp-files Add tests for thead, tbody and tfoot HTML elements Remove unnecessary log checks. Refactor font-size resolution methods. Add missing copyright headers Pass correct base url to SVG converter Minor refactoring: move some tests which do not use private resources to a public html2pdf repository. Fix processing inline-block images as children of <body> tag Add additional file types to .gitattributes Update cmp-s [RELEASE] 2.1.3-SNAPSHOT -> 2.1.4-SNAPSHOT
2 parents bcd7d39 + 34ee464 commit b942f42

File tree

154 files changed

+1298
-126
lines changed

Some content is hidden

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

154 files changed

+1298
-126
lines changed

.gitattributes

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,57 @@
55
# to LF line endings on checkout.
66
*.afm text eol=lf
77
*.cmap text eol=lf
8-
*.crt text eol=lf
9-
*.cs text eol=lf
8+
*.cs text eol=lf ident
9+
*.css text eol=lf
10+
*.htm text eol=lf
1011
*.html text eol=lf
1112
*.java text eol=lf ident
1213
*.lng text eol=lf
1314
*.md text eol=lf
1415
*.pom text eol=lf
1516
*.properties text eol=lf
17+
*.svg text eol=lf
1618
*.txt text eol=lf
1719
*.xfdf text eol=lf
20+
*.xht text eol=lf
21+
*.xhtml text eol=lf
1822
*.xml text eol=lf
23+
port-hash text eol=lf
1924

2025
# Declare files that will always have CRLF line endings on checkout.
2126
*.bat text eol=crlf
2227
*.csproj text eol=crlf
2328
*.sln text eol=crlf
2429

2530
# Denote all files that are truly binary and should not be modified.
31+
*.aif binary
32+
*.aiff binary
2633
*.bmp binary
34+
*.cer binary
2735
*.cmp binary
36+
*.crt binary
2837
*.dib binary
2938
*.gif binary
39+
*.icc binary
3040
*.j2k binary
3141
*.jb2 binary
3242
*.jp2 binary
43+
*.jpc binary
3344
*.jpg binary
3445
*.key binary
3546
*.otf binary
47+
*.p12 binary
3648
*.pdf binary
3749
*.pfb binary
50+
*.pfm binary
3851
*.png binary
52+
*.snd binary
3953
*.tif binary
4054
*.tiff binary
4155
*.ttc binary
4256
*.ttf binary
57+
*.u3d binary
58+
*.wav binary
4359
*.wmf binary
60+
*.woff binary
61+
*.woff2 binary

Jenkinsfile

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/usr/bin/env groovy
2+
3+
pipeline {
4+
5+
agent any
6+
7+
environment {
8+
JDK_VERSION = 'jdk-8-oracle'
9+
}
10+
11+
options {
12+
ansiColor('xterm')
13+
buildDiscarder(logRotator(artifactNumToKeepStr: '1'))
14+
parallelsAlwaysFailFast()
15+
retry(1)
16+
skipStagesAfterUnstable()
17+
timeout(time: 60, unit: 'MINUTES')
18+
timestamps()
19+
}
20+
21+
triggers {
22+
cron(env.BRANCH_NAME == 'develop' ? '@midnight' : '')
23+
}
24+
25+
tools {
26+
maven 'M3'
27+
jdk "${JDK_VERSION}"
28+
}
29+
30+
stages {
31+
stage('Clean workspace') {
32+
options {
33+
timeout(time: 5, unit: 'MINUTES')
34+
}
35+
steps {
36+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
37+
sh 'mvn clean'
38+
}
39+
}
40+
}
41+
stage('Compile') {
42+
options {
43+
timeout(time: 5, unit: 'MINUTES')
44+
}
45+
steps {
46+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
47+
sh 'mvn compile test-compile'
48+
}
49+
}
50+
}
51+
stage('Run Tests') {
52+
options {
53+
timeout(time: 30, unit: 'MINUTES')
54+
}
55+
environment {
56+
SONAR_BRANCH_TARGET= sh (returnStdout: true, script: '[ $BRANCH_NAME = master ] && echo master || echo develop').trim()
57+
}
58+
steps {
59+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
60+
withSonarQubeEnv('Sonar') {
61+
sh 'mvn --activate-profiles test verify -DgsExec="${gsExec}" -DcompareExec="${compareExec}" -Dmaven.test.skip=false -Dmaven.test.failure.ignore=false -Dmaven.javadoc.skip=true org.jacoco:jacoco-maven-plugin:prepare-agent org.jacoco:jacoco-maven-plugin:report sonar:sonar -Dsonar.branch.name="${BRANCH_NAME}" -Dsonar.branch.target="${SONAR_BRANCH_TARGET}"'
62+
}
63+
}
64+
}
65+
}
66+
stage('Static Code Analysis') {
67+
options {
68+
timeout(time: 30, unit: 'MINUTES')
69+
}
70+
steps {
71+
withMaven(jdk: "${JDK_VERSION}", maven: 'M3') {
72+
sh 'mvn --activate-profiles qa verify -Dpmd.analysisCache=true'
73+
}
74+
}
75+
}
76+
stage("Quality Gate") {
77+
steps {
78+
timeout(time: 1, unit: 'HOURS') {
79+
waitForQualityGate abortPipeline: true
80+
}
81+
}
82+
}
83+
stage('Artifactory Deploy') {
84+
options {
85+
timeout(time: 5, unit: 'MINUTES')
86+
}
87+
when {
88+
anyOf {
89+
branch "master"
90+
branch "develop"
91+
branch "7.0"
92+
branch "7.0-master"
93+
}
94+
}
95+
steps {
96+
script {
97+
def server = Artifactory.server('itext-artifactory')
98+
def rtMaven = Artifactory.newMavenBuild()
99+
rtMaven.deployer server: server, releaseRepo: 'releases', snapshotRepo: 'snapshot'
100+
rtMaven.tool = 'M3'
101+
def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'install -Dmaven.test.skip=true -Dspotbugs.skip=true -Dmaven.javadoc.failOnError=false'
102+
server.publishBuildInfo buildInfo
103+
}
104+
}
105+
}
106+
stage('Archive Artifacts') {
107+
options {
108+
timeout(time: 5, unit: 'MINUTES')
109+
}
110+
steps {
111+
archiveArtifacts allowEmptyArchive: true, artifacts: '**/*.jar'
112+
}
113+
}
114+
}
115+
116+
post {
117+
always {
118+
echo 'One way or another, I have finished \uD83E\uDD16'
119+
}
120+
success {
121+
echo 'I succeeeded! \u263A'
122+
}
123+
unstable {
124+
echo 'I am unstable \uD83D\uDE2E'
125+
}
126+
failure {
127+
echo 'I failed \uD83D\uDCA9'
128+
}
129+
changed {
130+
echo 'Things were different before... \uD83E\uDD14'
131+
}
132+
}
133+
134+
}

findbugs-filter.xml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<FindBugsFilter>
3+
<Match>
4+
<Class name="com.itextpdf.html2pdf.HtmlConverter"/>
5+
<Or>
6+
<Method
7+
name="convertToDocument"
8+
params="java.io.InputStream, com.itextpdf.kernel.pdf.PdfDocument, com.itextpdf.html2pdf.ConverterProperties"
9+
/>
10+
<Method
11+
name="convertToDocument"
12+
params="java.lang.String, com.itextpdf.kernel.pdf.PdfDocument, com.itextpdf.html2pdf.ConverterProperties"
13+
/>
14+
<Method
15+
name="convertToElements"
16+
params="java.io.InputStream, com.itextpdf.html2pdf.ConverterProperties"
17+
/>
18+
<Method
19+
name="convertToElements"
20+
params="java.lang.String, com.itextpdf.html2pdf.ConverterProperties"
21+
/>
22+
</Or>
23+
<Bug pattern="EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS"/>
24+
</Match>
25+
<Match>
26+
<Class name="com.itextpdf.html2pdf.attach.impl.DefaultHtmlProcessor"/>
27+
<Method name="visit" params="com.itextpdf.styledxmlparser.node.INode"/>
28+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
29+
</Match>
30+
<Match>
31+
<Class name="com.itextpdf.html2pdf.attach.impl.layout.HeightDimensionContainer"/>
32+
<Method
33+
name="&lt;init&gt;"
34+
params="com.itextpdf.styledxmlparser.css.CssContextNode, float, float, com.itextpdf.layout.renderer.IRenderer, float"
35+
/>
36+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
37+
</Match>
38+
<Match>
39+
<Class name="com.itextpdf.html2pdf.attach.impl.layout.WidthDimensionContainer"/>
40+
<Method
41+
name="&lt;init&gt;"
42+
params="com.itextpdf.styledxmlparser.css.CssContextNode, float, com.itextpdf.layout.renderer.IRenderer, float"
43+
/>
44+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
45+
</Match>
46+
<Match>
47+
<Class name="com.itextpdf.html2pdf.attach.impl.tags.ThTagWorker"/>
48+
<Method
49+
name="processEnd"
50+
params="com.itextpdf.styledxmlparser.node.IElementNode, com.itextpdf.html2pdf.attach.ProcessorContext"
51+
/>
52+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
53+
</Match>
54+
<Match>
55+
<Class name="com.itextpdf.html2pdf.attach.util.WaitingColgroupsHelper"/>
56+
<Or>
57+
<Method name="applyColStyles" params=""/>
58+
<Method
59+
name="applyColStyles"
60+
params="com.itextpdf.styledxmlparser.node.INode, com.itextpdf.html2pdf.attach.util.RowColHelper"
61+
/>
62+
</Or>
63+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
64+
</Match>
65+
<Match>
66+
<Class name="com.itextpdf.html2pdf.css.CssConstants"/>
67+
<Field name="OVERFLOW_VALUES"/>
68+
<Bug pattern="MS_MUTABLE_COLLECTION"/>
69+
</Match>
70+
<Match>
71+
<Class name="com.itextpdf.html2pdf.css.apply.util.BackgroundApplierUtil"/>
72+
<Method
73+
name="applyBackground"
74+
params="java.util.Map, com.itextpdf.html2pdf.attach.ProcessorContext, com.itextpdf.layout.IPropertyContainer"
75+
/>
76+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
77+
</Match>
78+
<Match>
79+
<Class name="com.itextpdf.html2pdf.css.apply.util.FontStyleApplierUtil"/>
80+
<Method
81+
name="applyFontStyles"
82+
params="java.util.Map, com.itextpdf.html2pdf.attach.ProcessorContext, com.itextpdf.styledxmlparser.node.IStylesContainer, com.itextpdf.layout.IPropertyContainer"
83+
/>
84+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
85+
</Match>
86+
<Match>
87+
<Class name="com.itextpdf.html2pdf.css.resolve.DefaultCssResolver"/>
88+
<Method
89+
name="collectCssDeclarations"
90+
params="com.itextpdf.styledxmlparser.node.INode, com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver, com.itextpdf.html2pdf.css.resolve.CssContext"
91+
/>
92+
<Or>
93+
<Bug pattern="DM_DEFAULT_ENCODING"/>
94+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
95+
</Or>
96+
</Match>
97+
<Match>
98+
<Class name="com.itextpdf.html2pdf.html.HtmlUtils"/>
99+
<Method name="isStyleSheetLink" params="com.itextpdf.styledxmlparser.node.IElementNode"/>
100+
<Bug pattern="LSC_LITERAL_STRING_COMPARISON"/>
101+
</Match>
102+
</FindBugsFilter>

pom.xml

Lines changed: 12 additions & 2 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.6</version>
7+
<version>7.1.7</version>
88
<relativePath/>
99
</parent>
1010
<artifactId>html2pdf</artifactId>
11-
<version>2.1.3</version>
11+
<version>2.1.4</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,6 +89,16 @@
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>
92102
<plugin>
93103
<groupId>external.atlassian.jgitflow</groupId>
94104
<artifactId>jgitflow-maven-plugin</artifactId>

src/main/java/com/itextpdf/html2pdf/LogMessageConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public final class LogMessageConstant {
128128
/** The Constant UNKNOWN_MARGIN_BOX_CHILD. */
129129
public static final String UNKNOWN_MARGIN_BOX_CHILD = "Unknown margin box child";
130130
/** The Constant WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT. */
131-
public static final String WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT = "Worker of type {0} unable to process it's text content";
131+
public static final String WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT = "Worker of type {0} unable to process it`s text content";
132132
/** The Constant WORKER_UNABLE_TO_PROCESS_OTHER_WORKER. */
133133
public static final String WORKER_UNABLE_TO_PROCESS_OTHER_WORKER = "Worker of type {0} unable to process {1}";
134134

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/DimensionContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ boolean isAutoDimension() {
7373
}
7474

7575
float parseDimension(CssContextNode node, String content, float maxAvailableDimension, float additionalWidthFix) {
76-
float fontSize = FontStyleApplierUtil.parseAbsoluteFontSize(node.getStyles().get(CssConstants.FONT_SIZE));
76+
float fontSize = CssUtils.parseAbsoluteFontSize(node.getStyles().get(CssConstants.FONT_SIZE));
7777
UnitValue unitValue = CssUtils.parseLengthValueToPt(content, fontSize, 0);
7878
if (unitValue == null) {
7979
return 0;

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,9 @@ public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext conte
135135
postProcessInlineGroup();
136136
div.add((AreaBreak) element);
137137
processed = true;
138-
} else if (childTagWorker instanceof ImgTagWorker && element instanceof IElement) {
139-
if (CssConstants.BLOCK.equals(((ImgTagWorker) childTagWorker).getDisplay())) {
140-
processed = addBlockChild((com.itextpdf.layout.element.IElement) element);
141-
} else if (childTagWorker.getElementResult() instanceof Image) {
142-
inlineHelper.add((ILeafElement) childTagWorker.getElementResult());
143-
processed = true;
144-
}
138+
} else if (childTagWorker instanceof ImgTagWorker && element instanceof IElement && !CssConstants.BLOCK.equals(((ImgTagWorker) childTagWorker).getDisplay())) {
139+
inlineHelper.add((ILeafElement) childTagWorker.getElementResult());
140+
processed = true;
145141
} else if (element instanceof com.itextpdf.layout.element.IElement) {
146142
processed = addBlockChild((com.itextpdf.layout.element.IElement) element);
147143
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,21 @@ This file is part of the iText (R) project.
4747
import com.itextpdf.html2pdf.attach.impl.layout.HtmlDocumentRenderer;
4848
import com.itextpdf.html2pdf.attach.impl.layout.form.element.IFormField;
4949
import com.itextpdf.html2pdf.attach.util.WaitingInlineElementsHelper;
50+
import com.itextpdf.html2pdf.css.CssConstants;
5051
import com.itextpdf.kernel.pdf.PdfDocument;
5152
import com.itextpdf.layout.Document;
5253
import com.itextpdf.layout.IPropertyContainer;
5354
import com.itextpdf.layout.element.AreaBreak;
5455
import com.itextpdf.layout.element.IBlockElement;
56+
import com.itextpdf.layout.element.IElement;
5557
import com.itextpdf.layout.element.ILeafElement;
5658
import com.itextpdf.layout.element.Image;
5759
import com.itextpdf.layout.font.FontFamilySplitter;
5860
import com.itextpdf.layout.property.Property;
59-
import com.itextpdf.html2pdf.css.CssConstants;
6061
import com.itextpdf.styledxmlparser.css.ICssResolver;
6162
import com.itextpdf.styledxmlparser.node.IElementNode;
6263
import com.itextpdf.styledxmlparser.node.INode;
64+
6365
import java.util.List;
6466

6567
/**
@@ -145,6 +147,9 @@ public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext conte
145147
} else if (childTagWorker instanceof BrTagWorker) {
146148
inlineHelper.add((ILeafElement) childTagWorker.getElementResult());
147149
processed = true;
150+
} else if (childTagWorker instanceof ImgTagWorker && childTagWorker.getElementResult() instanceof IElement && !CssConstants.BLOCK.equals(((ImgTagWorker) childTagWorker).getDisplay())) {
151+
inlineHelper.add((ILeafElement) childTagWorker.getElementResult());
152+
processed = true;
148153
} else if (childTagWorker.getElementResult() != null) {
149154
processed = processBlockChild(childTagWorker.getElementResult());
150155
}

0 commit comments

Comments
 (0)