Skip to content

Commit e113e20

Browse files
committed
[RELEASE] iText pdfHtml 6.3.0
2 parents 5c9b665 + cf60344 commit e113e20

File tree

2,798 files changed

+33835
-499
lines changed

Some content is hidden

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

2,798 files changed

+33835
-499
lines changed

pom.xml

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>com.itextpdf</groupId>
77
<artifactId>root</artifactId>
8-
<version>9.3.0</version>
8+
<version>9.4.0</version>
99
<relativePath />
1010
</parent>
1111

1212
<artifactId>html2pdf</artifactId>
13-
<version>6.2.1</version>
13+
<version>6.3.0</version>
1414

1515
<name>pdfHTML</name>
1616
<description>pdfHTML is an iText add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
@@ -23,6 +23,12 @@
2323

2424
<properties>
2525
<itext.version>${project.parent.version}</itext.version>
26+
27+
<sharpen.phase>install</sharpen.phase>
28+
<sharpen.projectName>html2pdf</sharpen.projectName>
29+
<sharpen.cSharpTargetFolder>./../../sharp/html2pdf</sharpen.cSharpTargetFolder>
30+
<sharpen.cSharpSourceCodeDestination>itext/itext.html2pdf</sharpen.cSharpSourceCodeDestination>
31+
<sharpen.cSharpTestCodeDestination>itext.tests/itext.html2pdf.tests</sharpen.cSharpTestCodeDestination>
2632
</properties>
2733

2834
<dependencies>
@@ -129,50 +135,7 @@
129135
</plugin>
130136
</plugins>
131137
</build>
132-
133138
<profiles>
134-
<profile>
135-
<id>with-sharpen</id>
136-
<build>
137-
<plugins>
138-
<plugin>
139-
<groupId>sharpen</groupId>
140-
<artifactId>sharpen-maven-plugin</artifactId>
141-
<version>1.0-SNAPSHOT</version>
142-
<executions>
143-
<execution>
144-
<phase>install</phase>
145-
<goals>
146-
<goal>sharpen</goal>
147-
</goals>
148-
</execution>
149-
</executions>
150-
<dependencies>
151-
<dependency>
152-
<groupId>sharpen</groupId>
153-
<artifactId>standard-framework-mapping</artifactId>
154-
<version>1.0-SNAPSHOT</version>
155-
</dependency>
156-
</dependencies>
157-
<configuration>
158-
<projectName>html2pdf</projectName>
159-
<cSharpTargetFolder>./../../sharp/html2pdf</cSharpTargetFolder>
160-
<cSharpSourceCodeDestination>itext/itext.html2pdf</cSharpSourceCodeDestination>
161-
<cSharpTestCodeDestination>itext.tests/itext.html2pdf.tests</cSharpTestCodeDestination>
162-
<buildDotnet>${sharpen.builddotnet}</buildDotnet>
163-
<showDiff>${sharpen.showdiff}</showDiff>
164-
<sourceCodeFiles>
165-
<file>**/src/main/java/**/*.java</file>
166-
</sourceCodeFiles>
167-
<testCodeFiles>
168-
<file>**/src/test/java/**/*.java</file>
169-
</testCodeFiles>
170-
</configuration>
171-
</plugin>
172-
</plugins>
173-
</build>
174-
</profile>
175-
176139
<profile>
177140
<id>native</id>
178141
<dependencies>

src/main/java/com/itextpdf/html2pdf/actions/data/PdfHtmlProductData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This file is part of the iText (R) project.
3030
*/
3131
public final class PdfHtmlProductData {
3232
private static final String PDF_HTML_PUBLIC_PRODUCT_NAME = "pdfHTML";
33-
private static final String PDF_HTML_VERSION = "6.2.1";
33+
private static final String PDF_HTML_VERSION = "6.3.0";
3434
private static final int PDF_HTML_COPYRIGHT_SINCE = 2000;
3535
private static final int PDF_HTML_COPYRIGHT_TO = 2025;
3636

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2025 Apryse Group NV
4+
Authors: Apryse 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.attach;
24+
25+
import com.itextpdf.styledxmlparser.node.INode;
26+
27+
import java.util.List;
28+
import java.util.Stack;
29+
30+
/**
31+
* Utility class for document tree operations.
32+
*/
33+
public final class DocumentTreeUtil {
34+
35+
private DocumentTreeUtil() {
36+
//Utility class should not be instantiated
37+
}
38+
39+
/**
40+
* Traverses a document tree starting from a specified node and performs a collection of jobs on each node.
41+
*
42+
* @param node node of the document tree to traverse
43+
* @param jobs a collection of jobs to be executed on each node during the traversal
44+
*/
45+
public static void traverse(INode node, List<IDocumentTreeJob> jobs) {
46+
Stack<INode> stk = new Stack<>();
47+
stk.push(node);
48+
while (!stk.isEmpty()) {
49+
INode n = stk.pop();
50+
for (IDocumentTreeJob job : jobs) {
51+
job.process(n, stk.size());
52+
}
53+
if (!n.childNodes().isEmpty()) {
54+
for (int i = n.childNodes().size() - 1; i >= 0; i--) {
55+
stk.push(n.childNodes().get(i));
56+
}
57+
}
58+
}
59+
}
60+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2025 Apryse Group NV
4+
Authors: Apryse 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.attach;
24+
25+
import com.itextpdf.styledxmlparser.node.INode;
26+
27+
/**
28+
* Interface for document tree jobs.
29+
*/
30+
@FunctionalInterface
31+
public interface IDocumentTreeJob {
32+
/**
33+
* Processes a node within a document tree structure at a given level.
34+
* <br>
35+
* This method is used to perform specific operations on an {@link INode}
36+
* based on the context of its hierarchical position in the document tree.
37+
*
38+
* @param node the node to process
39+
* @param level the hierarchical level of the node in the document tree structure
40+
*/
41+
void process(INode node, int level);
42+
}

src/main/java/com/itextpdf/html2pdf/attach/ProcessorContext.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This file is part of the iText (R) project.
2727
import com.itextpdf.html2pdf.ConverterProperties;
2828
import com.itextpdf.html2pdf.attach.impl.DefaultTagWorkerFactory;
2929
import com.itextpdf.html2pdf.attach.impl.HtmlMetaInfoContainer;
30+
import com.itextpdf.html2pdf.attach.impl.LabelContext;
3031
import com.itextpdf.html2pdf.attach.impl.LinkContext;
3132
import com.itextpdf.html2pdf.attach.impl.OutlineHandler;
3233
import com.itextpdf.html2pdf.css.apply.ICssApplierFactory;
@@ -138,6 +139,11 @@ public class ProcessorContext {
138139
*/
139140
private LinkContext linkContext;
140141

142+
/**
143+
* The label context
144+
*/
145+
private LabelContext labelContext;
146+
141147
/**
142148
* The PDF document.
143149
*/
@@ -212,6 +218,7 @@ public ProcessorContext(ConverterProperties converterProperties) {
212218
cssContext = new CssContext();
213219
cssStyleSheet = null;
214220
linkContext = new LinkContext();
221+
labelContext = new LabelContext();
215222

216223
createAcroForm = converterProperties.isCreateAcroForm();
217224
formFieldNameResolver = new FormFieldNameResolver();
@@ -342,6 +349,15 @@ public LinkContext getLinkContext() {
342349
return linkContext;
343350
}
344351

352+
/**
353+
* Gets the label context.
354+
*
355+
* @return the label context
356+
*/
357+
public LabelContext getLabelContext() {
358+
return labelContext;
359+
}
360+
345361
/**
346362
* Checks if is an AcroForm needs to be created.
347363
*
@@ -443,6 +459,7 @@ public void reset() {
443459
this.cssContext = new CssContext();
444460
this.cssStyleSheet = null;
445461
this.linkContext = new LinkContext();
462+
this.labelContext = new LabelContext();
446463
this.formFieldNameResolver.reset();
447464
//Reset font provider. PdfFonts shall be reseted.
448465
this.fontProvider.reset();

src/main/java/com/itextpdf/html2pdf/attach/impl/DefaultHtmlProcessor.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ This file is part of the iText (R) project.
3131
import com.itextpdf.html2pdf.ConverterProperties;
3232
import com.itextpdf.html2pdf.ProcessorContextCreator;
3333
import com.itextpdf.html2pdf.actions.events.PdfHtmlProductEvent;
34-
import com.itextpdf.html2pdf.attach.IHtmlProcessor;
35-
import com.itextpdf.html2pdf.attach.ITagWorker;
36-
import com.itextpdf.html2pdf.attach.ProcessorContext;
34+
import com.itextpdf.html2pdf.attach.*;
3735
import com.itextpdf.html2pdf.attach.impl.layout.HtmlDocument;
3836
import com.itextpdf.html2pdf.attach.impl.layout.HtmlDocumentRenderer;
3937
import com.itextpdf.html2pdf.attach.impl.layout.RunningElementContainer;
4038
import com.itextpdf.html2pdf.attach.impl.tags.HtmlTagWorker;
4139
import com.itextpdf.html2pdf.attach.impl.tags.RunningElementTagWorker;
40+
import com.itextpdf.html2pdf.attach.util.AlternateDescriptionResolver;
4241
import com.itextpdf.html2pdf.attach.util.LinkHelper;
4342
import com.itextpdf.html2pdf.css.CssConstants;
4443
import com.itextpdf.html2pdf.css.apply.ICssApplier;
@@ -64,6 +63,7 @@ This file is part of the iText (R) project.
6463
import com.itextpdf.layout.properties.RenderingMode;
6564
import com.itextpdf.layout.renderer.DocumentRenderer;
6665
import com.itextpdf.layout.renderer.MetaInfoContainer;
66+
import com.itextpdf.layout.tagging.IAccessibleElement;
6767
import com.itextpdf.styledxmlparser.css.CssDeclaration;
6868
import com.itextpdf.styledxmlparser.css.CssFontFaceRule;
6969
import com.itextpdf.styledxmlparser.css.ICssResolver;
@@ -185,11 +185,7 @@ public List<com.itextpdf.layout.element.IElement> processElements(INode root) {
185185
context.getMetaInfoContainer().getMetaInfo()));
186186

187187
context.reset();
188-
roots = new ArrayList<>();
189-
cssResolver = new DefaultCssResolver(root, context);
190-
context.setCssStyleSheet(((DefaultCssResolver) cssResolver).getCssStyleSheet());
191-
context.getLinkContext().scanForIds(root);
192-
addFontFaceFonts();
188+
initContext(root);
193189
IElementNode html = findHtmlNode(root);
194190
IElementNode body = findBodyNode(root);
195191

@@ -229,11 +225,7 @@ public Document processDocument(INode root, PdfDocument pdfDocument) {
229225
if (!context.hasFonts()) {
230226
throw new Html2PdfException(Html2PdfException.FONT_PROVIDER_CONTAINS_ZERO_FONTS);
231227
}
232-
roots = new ArrayList<>();
233-
cssResolver = new DefaultCssResolver(root, context);
234-
context.setCssStyleSheet(((DefaultCssResolver) cssResolver).getCssStyleSheet());
235-
context.getLinkContext().scanForIds(root);
236-
addFontFaceFonts();
228+
initContext(root);
237229
root = findHtmlNode(root);
238230

239231
if (context.getCssContext().isNonPagesTargetCounterPresent()) {
@@ -265,6 +257,18 @@ public Document processDocument(INode root, PdfDocument pdfDocument) {
265257
return doc;
266258
}
267259

260+
private void initContext(INode root) {
261+
roots = new ArrayList<>();
262+
cssResolver = new DefaultCssResolver(root, context);
263+
context.setCssStyleSheet(((DefaultCssResolver) cssResolver).getCssStyleSheet());
264+
//Not using Arrays.asList because it can't derive types correctly in .NET
265+
List<IDocumentTreeJob> jobs = new ArrayList<>();
266+
jobs.add(context.getLinkContext());
267+
jobs.add(context.getLabelContext());
268+
DocumentTreeUtil.traverse(root, jobs);
269+
addFontFaceFonts();
270+
}
271+
268272
/**
269273
* Recursively processes a node to preprocess target-counters.
270274
*
@@ -367,6 +371,11 @@ private void visit(INode node) {
367371
tagWorker.getElementResult().setProperty(Property.COLLAPSING_MARGINS, Boolean.FALSE);
368372
tagWorker.getElementResult().setProperty(Property.TREAT_AS_CONTINUOUS_CONTAINER, true);
369373
}
374+
IPropertyContainer result = tagWorker.getElementResult();
375+
if (result instanceof IAccessibleElement) {
376+
context.getDIContainer().getInstance(AlternateDescriptionResolver.class)
377+
.resolveLabelableElement((IAccessibleElement) result, element, context);
378+
}
370379
}
371380

372381
element.setStyles(null);

src/main/java/com/itextpdf/html2pdf/attach/impl/DefaultTagWorkerMapping.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class DefaultTagWorkerMapping {
9090
workerMapping.putMapping(TagConstants.ABBR, (lhs, rhs) -> new AbbrTagWorker(lhs, rhs));
9191
workerMapping.putMapping(TagConstants.ADDRESS, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
9292
workerMapping.putMapping(TagConstants.ARTICLE, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
93+
workerMapping.putMapping(TagConstants.ARTICLE, CssConstants.FLEX,
94+
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
9395
workerMapping.putMapping(TagConstants.ASIDE, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
9496
workerMapping.putMapping(TagConstants.B, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
9597
workerMapping.putMapping(TagConstants.BDI, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
@@ -114,16 +116,23 @@ class DefaultTagWorkerMapping {
114116
workerMapping.putMapping(TagConstants.FIELDSET, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
115117
workerMapping.putMapping(TagConstants.FIGCAPTION, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
116118
workerMapping.putMapping(TagConstants.FIGURE, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
119+
workerMapping.putMapping(TagConstants.FIGURE, CssConstants.FLEX,
120+
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
117121
workerMapping.putMapping(TagConstants.FONT, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
118122
workerMapping.putMapping(TagConstants.FOOTER, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
123+
workerMapping.putMapping(TagConstants.FOOTER, CssConstants.FLEX,
124+
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
119125
workerMapping.putMapping(TagConstants.FORM, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
126+
workerMapping.putMapping(TagConstants.FORM, CssConstants.FLEX, (lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
120127
workerMapping.putMapping(TagConstants.H1, (lhs, rhs) -> new HTagWorker(lhs, rhs));
121128
workerMapping.putMapping(TagConstants.H2, (lhs, rhs) -> new HTagWorker(lhs, rhs));
122129
workerMapping.putMapping(TagConstants.H3, (lhs, rhs) -> new HTagWorker(lhs, rhs));
123130
workerMapping.putMapping(TagConstants.H4, (lhs, rhs) -> new HTagWorker(lhs, rhs));
124131
workerMapping.putMapping(TagConstants.H5, (lhs, rhs) -> new HTagWorker(lhs, rhs));
125132
workerMapping.putMapping(TagConstants.H6, (lhs, rhs) -> new HTagWorker(lhs, rhs));
126133
workerMapping.putMapping(TagConstants.HEADER, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
134+
workerMapping.putMapping(TagConstants.HEADER, CssConstants.FLEX,
135+
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
127136
workerMapping.putMapping(TagConstants.HR, (lhs, rhs) -> new HrTagWorker(lhs, rhs));
128137
workerMapping.putMapping(TagConstants.HTML, (lhs, rhs) -> new HtmlTagWorker(lhs, rhs));
129138
workerMapping.putMapping(TagConstants.I, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
@@ -149,6 +158,8 @@ class DefaultTagWorkerMapping {
149158
workerMapping.putMapping(TagConstants.S, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
150159
workerMapping.putMapping(TagConstants.SAMP, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
151160
workerMapping.putMapping(TagConstants.SECTION, (lhs, rhs) -> new DivTagWorker(lhs, rhs));
161+
workerMapping.putMapping(TagConstants.SECTION, CssConstants.FLEX,
162+
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
152163
workerMapping.putMapping(TagConstants.SELECT, (lhs, rhs) -> new SelectTagWorker(lhs, rhs));
153164
workerMapping.putMapping(TagConstants.SMALL, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
154165
workerMapping.putMapping(TagConstants.SPAN, (lhs, rhs) -> new SpanTagWorker(lhs, rhs));
@@ -257,9 +268,11 @@ TagProcessorMapping<ITagWorkerCreator> getDefaultTagWorkerMapping() {
257268
public interface ITagWorkerCreator {
258269
/**
259270
* Creates an {@link ITagWorker} instance.
260-
* @param elementNode tag worker element node.
261-
* @param processorContext processor context.
262-
* @return {@link ITagWorker} instance.
271+
*
272+
* @param elementNode tag worker element node
273+
* @param processorContext processor context
274+
*
275+
* @return {@link ITagWorker} instance
263276
*/
264277
ITagWorker create(IElementNode elementNode, ProcessorContext processorContext);
265278
}

0 commit comments

Comments
 (0)