Skip to content

Commit 913de2b

Browse files
committed
[RELEASE] iText pdfHtml 5.0.5
2 parents d6a4e89 + a979e82 commit 913de2b

File tree

1,578 files changed

+30649
-2978
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,578 files changed

+30649
-2978
lines changed

pom.xml

+21-21
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>8.0.4</version>
8+
<version>8.0.5</version>
99
<relativePath />
1010
</parent>
1111

1212
<artifactId>html2pdf</artifactId>
13-
<version>5.0.4</version>
13+
<version>5.0.5</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
@@ -25,25 +25,6 @@
2525
<itext.version>${project.parent.version}</itext.version>
2626
</properties>
2727

28-
<repositories>
29-
<repository>
30-
<snapshots>
31-
<enabled>true</enabled>
32-
</snapshots>
33-
<id>itext-snapshot</id>
34-
<name>iText Repository - snapshots</name>
35-
<url>https://repo.itextsupport.com/snapshot</url>
36-
</repository>
37-
<repository>
38-
<snapshots>
39-
<enabled>false</enabled>
40-
</snapshots>
41-
<id>itext-releases</id>
42-
<name>iText Repository - releases</name>
43-
<url>https://repo.itextsupport.com/releases</url>
44-
</repository>
45-
</repositories>
46-
4728
<dependencies>
4829
<dependency>
4930
<groupId>com.itextpdf</groupId>
@@ -79,6 +60,25 @@
7960
</dependency>
8061
</dependencies>
8162

63+
<repositories>
64+
<repository>
65+
<snapshots>
66+
<enabled>true</enabled>
67+
</snapshots>
68+
<id>itext-snapshot</id>
69+
<name>iText Repository - snapshots</name>
70+
<url>https://repo.itextsupport.com/snapshot</url>
71+
</repository>
72+
<repository>
73+
<snapshots>
74+
<enabled>false</enabled>
75+
</snapshots>
76+
<id>itext-releases</id>
77+
<name>iText Repository - releases</name>
78+
<url>https://repo.itextsupport.com/releases</url>
79+
</repository>
80+
</repositories>
81+
8282
<build>
8383
<resources>
8484
<resource>

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

+1-1
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 = "5.0.4";
33+
private static final String PDF_HTML_VERSION = "5.0.5";
3434
private static final int PDF_HTML_COPYRIGHT_SINCE = 2000;
3535
private static final int PDF_HTML_COPYRIGHT_TO = 2024;
3636

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

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This file is part of the iText (R) project.
3434
import com.itextpdf.html2pdf.attach.impl.tags.ColTagWorker;
3535
import com.itextpdf.html2pdf.attach.impl.tags.ColgroupTagWorker;
3636
import com.itextpdf.html2pdf.attach.impl.tags.DisplayFlexTagWorker;
37+
import com.itextpdf.html2pdf.attach.impl.tags.DisplayGridTagWorker;
3738
import com.itextpdf.html2pdf.attach.impl.tags.DisplayTableRowTagWorker;
3839
import com.itextpdf.html2pdf.attach.impl.tags.DisplayTableTagWorker;
3940
import com.itextpdf.html2pdf.attach.impl.tags.DivTagWorker;
@@ -204,6 +205,8 @@ class DefaultTagWorkerMapping {
204205
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
205206
workerMapping.putMapping(TagConstants.SPAN, CssConstants.FLEX,
206207
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
208+
workerMapping.putMapping(TagConstants.DIV, CssConstants.GRID,
209+
(lhs, rhs) -> new DisplayGridTagWorker(lhs, rhs));
207210

208211
// pseudo elements mapping
209212
String beforePseudoElemName = CssPseudoElementUtil.createPseudoElementTagName(CssConstants.BEFORE);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2024 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.impl.tags;
24+
25+
import com.itextpdf.html2pdf.attach.ITagWorker;
26+
import com.itextpdf.html2pdf.attach.ProcessorContext;
27+
import com.itextpdf.layout.IPropertyContainer;
28+
import com.itextpdf.layout.element.GridContainer;
29+
import com.itextpdf.layout.element.IElement;
30+
import com.itextpdf.styledxmlparser.node.IElementNode;
31+
32+
/**
33+
* {@link ITagWorker} implementation for elements with {@code display: grid}.
34+
*/
35+
public class DisplayGridTagWorker extends DivTagWorker {
36+
37+
/**
38+
* Creates a new {@link DisplayGridTagWorker} instance.
39+
*
40+
* @param element the element
41+
* @param context the context
42+
*/
43+
public DisplayGridTagWorker(IElementNode element, ProcessorContext context) {
44+
super(element, context, new GridContainer());
45+
}
46+
47+
/**
48+
* {@inheritDoc}
49+
*/
50+
@Override
51+
public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext context) {
52+
final IPropertyContainer element = childTagWorker.getElementResult();
53+
if (childTagWorker instanceof BrTagWorker) {
54+
return super.processTagChild(childTagWorker, context);
55+
} else {
56+
return addBlockChild((IElement) element);
57+
}
58+
}
59+
}

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,18 @@ public class DivTagWorker implements ITagWorker, IDisplayAware {
6666
* @param context the context
6767
*/
6868
public DivTagWorker(IElementNode element, ProcessorContext context) {
69-
div = new Div();
69+
this(element, context, new Div());
70+
}
71+
72+
/**
73+
* Creates a new {@link DivTagWorker} instance.
74+
*
75+
* @param element the element
76+
* @param context the context
77+
* @param container div element container
78+
*/
79+
protected DivTagWorker(IElementNode element, ProcessorContext context, Div container) {
80+
div = container;
7081
Map<String, String> styles = element.getStyles();
7182
if (styles != null && (styles.containsKey(CssConstants.COLUMN_COUNT) || styles.containsKey(CssConstants.COLUMN_WIDTH))) {
7283
multicolContainer = new MulticolContainer();

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ This file is part of the iText (R) project.
3131

3232
public class CssConstants extends CommonCssConstants {
3333

34+
/** The Constant AUTO_FIT. */
35+
public static final String AUTO_FIT = "auto-fit";
36+
37+
/** The Constant AUTO_FILL. */
38+
public static final String AUTO_FILL = "auto-fill";
39+
3440
/** The Constant BLEED. */
3541
public static final String BLEED = "bleed";
3642

@@ -71,6 +77,9 @@ public class CssConstants extends CommonCssConstants {
7177
/** The Constant MIN_WIDTH. */
7278
public static final String MIN_WIDTH = "min-width";
7379

80+
/** The Constant MIN_MAX. */
81+
public static final String MINMAX = "minmax";
82+
7483
/**
7584
* The Constant OBJECT_FIT.
7685
*/
@@ -138,8 +147,8 @@ public class CssConstants extends CommonCssConstants {
138147
/** The Constant FIRST_EXCEPT. */
139148
public static final String FIRST_EXCEPT = "first-except";
140149

141-
/** The Constant GRID. */
142-
public static final String GRID = "grid";
150+
/** The Constant GRID_AREA. */
151+
public static final String GRID_AREA = "grid-area";
143152

144153
/** The Constant INLINE. */
145154
public static final String INLINE = "inline";
@@ -223,6 +232,9 @@ public class CssConstants extends CommonCssConstants {
223232
/** The Constant SUB. */
224233
public static final String SUB = "sub";
225234

235+
/** The Constant SUBGRID. */
236+
public static final String SUBGRID = "subgrid";
237+
226238
/** The Constant SUPER. */
227239
public static final String SUPER = "super";
228240

src/main/java/com/itextpdf/html2pdf/css/apply/impl/BlockCssApplier.java

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This file is part of the iText (R) project.
3333
import com.itextpdf.html2pdf.css.apply.util.FlexApplierUtil;
3434
import com.itextpdf.html2pdf.css.apply.util.FloatApplierUtil;
3535
import com.itextpdf.html2pdf.css.apply.util.FontStyleApplierUtil;
36+
import com.itextpdf.html2pdf.css.apply.util.GridApplierUtil;
3637
import com.itextpdf.html2pdf.css.apply.util.HyphenationApplierUtil;
3738
import com.itextpdf.html2pdf.css.apply.util.MarginApplierUtil;
3839
import com.itextpdf.html2pdf.css.apply.util.OpacityApplierUtil;
@@ -81,6 +82,7 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
8182
OrphansWidowsApplierUtil.applyOrphansAndWidows(cssProps, container);
8283
VerticalAlignmentApplierUtil.applyVerticalAlignmentForBlocks(cssProps, container, isInlineItem(tagWorker));
8384
MultiColumnCssApplierUtil.applyMultiCol(cssProps, context, container);
85+
GridApplierUtil.applyGridItemProperties(cssProps, stylesContainer, container);
8486
if (isFlexItem(stylesContainer)) {
8587
FlexApplierUtil.applyFlexItemProperties(cssProps, context, container);
8688
} else {

src/main/java/com/itextpdf/html2pdf/css/apply/impl/DefaultTagCssApplierMapping.java

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class DefaultTagCssApplierMapping {
152152
mapping.putMapping(TagConstants.DIV, CssConstants.TABLE_ROW, () -> new DisplayTableRowTagCssApplier());
153153
mapping.putMapping(TagConstants.DIV, CssConstants.FLEX, () -> new DisplayFlexTagCssApplier());
154154
mapping.putMapping(TagConstants.SPAN, CssConstants.FLEX, () -> new DisplayFlexTagCssApplier());
155+
mapping.putMapping(TagConstants.DIV, CssConstants.GRID, () -> new DisplayGridTagCssApplier());
155156

156157
// pseudo elements mapping
157158
String beforePseudoElemName = CssPseudoElementUtil.createPseudoElementTagName(CssConstants.BEFORE);

src/main/java/com/itextpdf/html2pdf/css/apply/impl/DisplayFlexTagCssApplier.java

-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,5 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
4646
container.deleteOwnProperty(Property.OVERFLOW_X);
4747
container.deleteOwnProperty(Property.OVERFLOW_Y);
4848
}
49-
MultiColumnCssApplierUtil.applyMultiCol(stylesContainer.getStyles(), context, container);
5049
}
5150
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2024 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.css.apply.impl;
24+
25+
import com.itextpdf.html2pdf.attach.ITagWorker;
26+
import com.itextpdf.html2pdf.attach.ProcessorContext;
27+
import com.itextpdf.html2pdf.css.apply.ICssApplier;
28+
import com.itextpdf.html2pdf.css.apply.util.GridApplierUtil;
29+
import com.itextpdf.layout.IPropertyContainer;
30+
import com.itextpdf.styledxmlparser.node.IStylesContainer;
31+
32+
import java.util.Map;
33+
34+
/**
35+
* {@link ICssApplier} implementation for elements with display grid.
36+
*/
37+
public class DisplayGridTagCssApplier extends BlockCssApplier {
38+
39+
/**
40+
* {@inheritDoc}
41+
*/
42+
@Override
43+
public void apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker) {
44+
super.apply(context, stylesContainer, tagWorker);
45+
final IPropertyContainer container = tagWorker.getElementResult();
46+
if (container != null) {
47+
Map<String, String> cssProps = stylesContainer.getStyles();
48+
GridApplierUtil.applyGridContainerProperties(cssProps, container, context);
49+
}
50+
}
51+
}

src/main/java/com/itextpdf/html2pdf/css/apply/impl/MultiColumnCssApplierUtil.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ public static void applyMultiCol(Map<String, String> cssProps, ProcessorContext
6464
element.setProperty(Property.COLUMN_WIDTH, width.getValue());
6565
}
6666

67+
if (!element.hasProperty(Property.COLUMN_WIDTH) && !element.hasProperty(Property.COLUMN_COUNT)) {
68+
if (CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_COUNT))
69+
|| CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_WIDTH))) {
70+
element.setProperty(Property.COLUMN_COUNT, 1);
71+
} else {
72+
return;
73+
}
74+
}
75+
6776
final UnitValue gap = CssDimensionParsingUtils.parseLengthValueToPt(cssProps.get(CssConstants.COLUMN_GAP),
6877
emValue, remValue);
6978
if (gap != null) {
@@ -74,11 +83,6 @@ public static void applyMultiCol(Map<String, String> cssProps, ProcessorContext
7483
if (!element.hasProperty(Property.COLUMN_GAP)) {
7584
element.setProperty(Property.COLUMN_GAP, CssDimensionParsingUtils.parseRelativeValue("1em", emValue));
7685
}
77-
if (!element.hasProperty(Property.COLUMN_COUNT) && !element.hasProperty(Property.COLUMN_WIDTH)
78-
&& (CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_COUNT))
79-
|| CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_WIDTH)))) {
80-
element.setProperty(Property.COLUMN_COUNT, 1);
81-
}
8286

8387
final Border borderFromCssProperties = BorderStyleApplierUtil.getCertainBorder(
8488
cssProps.get(CssConstants.COLUMN_RULE_WIDTH), cssProps.get(CssConstants.COLUMN_RULE_STYLE),

0 commit comments

Comments
 (0)