Skip to content

Commit

Permalink
[RELEASE] iText 7 pdfHTML 4.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
iText-CI committed Jun 20, 2022
2 parents a02011a + dabd0f9 commit 14c54b2
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.2.2</version>
<version>7.2.3</version>
<relativePath />
</parent>

<artifactId>html2pdf</artifactId>
<version>4.0.2</version>
<version>4.0.3</version>

<name>pdfHTML</name>
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This file is part of the iText (R) project.
*/
public final class PdfHtmlProductData {
private static final String PDF_HTML_PUBLIC_PRODUCT_NAME = "pdfHTML";
private static final String PDF_HTML_VERSION = "4.0.2";
private static final String PDF_HTML_VERSION = "4.0.3";
private static final int PDF_HTML_COPYRIGHT_SINCE = 2000;
private static final int PDF_HTML_COPYRIGHT_TO = 2022;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
}
}

// TODO as for now spans are flattened, let's at least make kids of floating spans floating too
String floatVal = cssStyles.get(CssConstants.FLOAT);
if (floatVal != null && !CssConstants.NONE.equals(floatVal)) {
for (IPropertyContainer elem : spanTagWorker.getAllElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ static List<INode> resolveContent(Map<String, String> styles, INode contentConta
} else if (token.getValue().startsWith("url(")) {
Map<String, String> attributes = new HashMap<>();
attributes.put(AttributeConstants.SRC, CssUtils.extractUrl(token.getValue()));
//TODO: probably should add user agent styles on CssContentElementNode creation, not here.
attributes.put(AttributeConstants.STYLE, CssConstants.DISPLAY + ":" + CssConstants.INLINE_BLOCK);
result.add(new CssContentElementNode(contentContainer, TagConstants.IMG, attributes));
} else if (CssGradientUtil.isCssLinearGradientValue(token.getValue())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ private Map<String, String> resolveStyles(INode element, CssContext context) {
CommonCssConstants.FONT_SIZE), inheritanceRules);

// If the parent has display: flex, the flex item is blockified
// no matter what display value is set for it.
// no matter what display value is set for it (except 'none' value).
// See CSS Flexible Box Layout Module Level 1,
// W3C Candidate Recommendation, 19 November 2018: 4. Flex Items.
if (isFlexItem(entry, elementStyles.get(CssConstants.DISPLAY))) {
final String currentElementDisplay = elementStyles.get(CssConstants.DISPLAY);
if (isFlexItem(entry, currentElementDisplay) &&
!CommonCssConstants.NONE.equals(currentElementDisplay)) {
elementStyles.put(CssConstants.DISPLAY, CssConstants.BLOCK);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/itextpdf/html2pdf/css/DisplayFlexTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,11 @@ public void marginsCollapseInsideFlexItemTest() throws IOException, InterruptedE
convertToPdfAndCompare("marginsCollapseInsideFlexItem", SOURCE_FOLDER, DESTINATION_FOLDER);
}

@Test
public void resolveStylesIfParentHasDisplayFlexStyleTest() throws IOException, InterruptedException {
convertToPdfAndCompare("displayNoneTest", SOURCE_FOLDER, DESTINATION_FOLDER);
}

private static void assertDiv(IElement element, String text) {
Assert.assertTrue(element instanceof Div);
Assert.assertEquals(1, ((Div) element).getChildren().size());
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/com/itextpdf/html2pdf/css/MarginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public void marginAutoImageInsideDiv02Test() throws IOException, InterruptedExce
convertToPdfAndCompare("marginAutoImageInsideDiv02", SOURCE_FOLDER, DESTINATION_FOLDER);
}

@Test
//TODO DEVSIX-5002 pdfHTML: support 'margin: auto'
public void autoMarginTest() throws IOException, InterruptedException {
convertToPdfAndCompare("autoMargin", SOURCE_FOLDER, DESTINATION_FOLDER);
}

@Test
//TODO DEVSIX-1101 Layout + Html2pdf: Support margin value in percents
@LogMessages(messages = @LogMessage(messageTemplate = Html2PdfLogMessageConstant.MARGIN_VALUE_IN_PERCENT_NOT_SUPPORTED))
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style>
*[parent]:not([parent~="z"]) {
display: flex;
}
*[child1]:not([child1~="z"]) {
display: none;
}
*[child2]:not([child2~="z"]) {
display: block;
}
</style>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="fieldLabel" parent="v"> FlexParent
<div class="fieldLabe2" child1="w"> , NoneChild </div>
<div class="fieldLabe2" child2="x"> , BlockChild </div>
</div>
<div class="fieldLabe3"> NoneChild should be unvisible </div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="background-color: blue; position: absolute">
<div style="background-color: yellow; width: 100px; margin-left: auto">
should aligned right cause of margins<br/>
</div>
<div style="background-color: yellow; width: 200px">
should aligned left as default
</div>
</div>
</body>
</html>
Binary file not shown.

0 comments on commit 14c54b2

Please sign in to comment.