Skip to content

Commit 14c54b2

Browse files
committed
[RELEASE] iText 7 pdfHTML 4.0.3
2 parents a02011a + dabd0f9 commit 14c54b2

File tree

11 files changed

+58
-7
lines changed

11 files changed

+58
-7
lines changed

pom.xml

Lines changed: 2 additions & 2 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>7.2.2</version>
8+
<version>7.2.3</version>
99
<relativePath />
1010
</parent>
1111

1212
<artifactId>html2pdf</artifactId>
13-
<version>4.0.2</version>
13+
<version>4.0.3</version>
1414

1515
<name>pdfHTML</name>
1616
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts

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 = "4.0.2";
33+
private static final String PDF_HTML_VERSION = "4.0.3";
3434
private static final int PDF_HTML_COPYRIGHT_SINCE = 2000;
3535
private static final int PDF_HTML_COPYRIGHT_TO = 2022;
3636

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
9595
}
9696
}
9797

98-
// TODO as for now spans are flattened, let's at least make kids of floating spans floating too
9998
String floatVal = cssStyles.get(CssConstants.FLOAT);
10099
if (floatVal != null && !CssConstants.NONE.equals(floatVal)) {
101100
for (IPropertyContainer elem : spanTagWorker.getAllElements()) {

src/main/java/com/itextpdf/html2pdf/css/resolve/CssContentPropertyResolver.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ static List<INode> resolveContent(Map<String, String> styles, INode contentConta
222222
} else if (token.getValue().startsWith("url(")) {
223223
Map<String, String> attributes = new HashMap<>();
224224
attributes.put(AttributeConstants.SRC, CssUtils.extractUrl(token.getValue()));
225-
//TODO: probably should add user agent styles on CssContentElementNode creation, not here.
226225
attributes.put(AttributeConstants.STYLE, CssConstants.DISPLAY + ":" + CssConstants.INLINE_BLOCK);
227226
result.add(new CssContentElementNode(contentContainer, TagConstants.IMG, attributes));
228227
} else if (CssGradientUtil.isCssLinearGradientValue(token.getValue())) {

src/main/java/com/itextpdf/html2pdf/css/resolve/DefaultCssResolver.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,12 @@ private Map<String, String> resolveStyles(INode element, CssContext context) {
202202
CommonCssConstants.FONT_SIZE), inheritanceRules);
203203

204204
// If the parent has display: flex, the flex item is blockified
205-
// no matter what display value is set for it.
205+
// no matter what display value is set for it (except 'none' value).
206206
// See CSS Flexible Box Layout Module Level 1,
207207
// W3C Candidate Recommendation, 19 November 2018: 4. Flex Items.
208-
if (isFlexItem(entry, elementStyles.get(CssConstants.DISPLAY))) {
208+
final String currentElementDisplay = elementStyles.get(CssConstants.DISPLAY);
209+
if (isFlexItem(entry, currentElementDisplay) &&
210+
!CommonCssConstants.NONE.equals(currentElementDisplay)) {
209211
elementStyles.put(CssConstants.DISPLAY, CssConstants.BLOCK);
210212
}
211213
}

src/test/java/com/itextpdf/html2pdf/css/DisplayFlexTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ public void marginsCollapseInsideFlexItemTest() throws IOException, InterruptedE
485485
convertToPdfAndCompare("marginsCollapseInsideFlexItem", SOURCE_FOLDER, DESTINATION_FOLDER);
486486
}
487487

488+
@Test
489+
public void resolveStylesIfParentHasDisplayFlexStyleTest() throws IOException, InterruptedException {
490+
convertToPdfAndCompare("displayNoneTest", SOURCE_FOLDER, DESTINATION_FOLDER);
491+
}
492+
488493
private static void assertDiv(IElement element, String text) {
489494
Assert.assertTrue(element instanceof Div);
490495
Assert.assertEquals(1, ((Div) element).getChildren().size());

src/test/java/com/itextpdf/html2pdf/css/MarginTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ public void marginAutoImageInsideDiv02Test() throws IOException, InterruptedExce
7474
convertToPdfAndCompare("marginAutoImageInsideDiv02", SOURCE_FOLDER, DESTINATION_FOLDER);
7575
}
7676

77+
@Test
78+
//TODO DEVSIX-5002 pdfHTML: support 'margin: auto'
79+
public void autoMarginTest() throws IOException, InterruptedException {
80+
convertToPdfAndCompare("autoMargin", SOURCE_FOLDER, DESTINATION_FOLDER);
81+
}
82+
7783
@Test
7884
//TODO DEVSIX-1101 Layout + Html2pdf: Support margin value in percents
7985
@LogMessages(messages = @LogMessage(messageTemplate = Html2PdfLogMessageConstant.MARGIN_VALUE_IN_PERCENT_NOT_SUPPORTED))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<style>
5+
*[parent]:not([parent~="z"]) {
6+
display: flex;
7+
}
8+
*[child1]:not([child1~="z"]) {
9+
display: none;
10+
}
11+
*[child2]:not([child2~="z"]) {
12+
display: block;
13+
}
14+
</style>
15+
<meta charset="UTF-8">
16+
<title>Title</title>
17+
</head>
18+
<body>
19+
<div class="fieldLabel" parent="v"> FlexParent
20+
<div class="fieldLabe2" child1="w"> , NoneChild </div>
21+
<div class="fieldLabe2" child2="x"> , BlockChild </div>
22+
</div>
23+
<div class="fieldLabe3"> NoneChild should be unvisible </div>
24+
</body>
25+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
</head>
5+
<body>
6+
<div style="background-color: blue; position: absolute">
7+
<div style="background-color: yellow; width: 100px; margin-left: auto">
8+
should aligned right cause of margins<br/>
9+
</div>
10+
<div style="background-color: yellow; width: 200px">
11+
should aligned left as default
12+
</div>
13+
</div>
14+
</body>
15+
</html>

0 commit comments

Comments
 (0)