Skip to content

Commit

Permalink
[RELEASE] iText pdfHtml 5.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
iText-CI committed Jul 12, 2024
2 parents d6a4e89 + a979e82 commit 913de2b
Show file tree
Hide file tree
Showing 1,578 changed files with 30,649 additions and 2,978 deletions.
42 changes: 21 additions & 21 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>8.0.4</version>
<version>8.0.5</version>
<relativePath />
</parent>

<artifactId>html2pdf</artifactId>
<version>5.0.4</version>
<version>5.0.5</version>

<name>pdfHTML</name>
<description>pdfHTML is an iText add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
Expand All @@ -25,25 +25,6 @@
<itext.version>${project.parent.version}</itext.version>
</properties>

<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>itext-snapshot</id>
<name>iText Repository - snapshots</name>
<url>https://repo.itextsupport.com/snapshot</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>itext-releases</id>
<name>iText Repository - releases</name>
<url>https://repo.itextsupport.com/releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
Expand Down Expand Up @@ -79,6 +60,25 @@
</dependency>
</dependencies>

<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>itext-snapshot</id>
<name>iText Repository - snapshots</name>
<url>https://repo.itextsupport.com/snapshot</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>itext-releases</id>
<name>iText Repository - releases</name>
<url>https://repo.itextsupport.com/releases</url>
</repository>
</repositories>

<build>
<resources>
<resource>
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 = "5.0.4";
private static final String PDF_HTML_VERSION = "5.0.5";
private static final int PDF_HTML_COPYRIGHT_SINCE = 2000;
private static final int PDF_HTML_COPYRIGHT_TO = 2024;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This file is part of the iText (R) project.
import com.itextpdf.html2pdf.attach.impl.tags.ColTagWorker;
import com.itextpdf.html2pdf.attach.impl.tags.ColgroupTagWorker;
import com.itextpdf.html2pdf.attach.impl.tags.DisplayFlexTagWorker;
import com.itextpdf.html2pdf.attach.impl.tags.DisplayGridTagWorker;
import com.itextpdf.html2pdf.attach.impl.tags.DisplayTableRowTagWorker;
import com.itextpdf.html2pdf.attach.impl.tags.DisplayTableTagWorker;
import com.itextpdf.html2pdf.attach.impl.tags.DivTagWorker;
Expand Down Expand Up @@ -204,6 +205,8 @@ class DefaultTagWorkerMapping {
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
workerMapping.putMapping(TagConstants.SPAN, CssConstants.FLEX,
(lhs, rhs) -> new DisplayFlexTagWorker(lhs, rhs));
workerMapping.putMapping(TagConstants.DIV, CssConstants.GRID,
(lhs, rhs) -> new DisplayGridTagWorker(lhs, rhs));

// pseudo elements mapping
String beforePseudoElemName = CssPseudoElementUtil.createPseudoElementTagName(CssConstants.BEFORE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itextpdf.html2pdf.attach.impl.tags;

import com.itextpdf.html2pdf.attach.ITagWorker;
import com.itextpdf.html2pdf.attach.ProcessorContext;
import com.itextpdf.layout.IPropertyContainer;
import com.itextpdf.layout.element.GridContainer;
import com.itextpdf.layout.element.IElement;
import com.itextpdf.styledxmlparser.node.IElementNode;

/**
* {@link ITagWorker} implementation for elements with {@code display: grid}.
*/
public class DisplayGridTagWorker extends DivTagWorker {

/**
* Creates a new {@link DisplayGridTagWorker} instance.
*
* @param element the element
* @param context the context
*/
public DisplayGridTagWorker(IElementNode element, ProcessorContext context) {
super(element, context, new GridContainer());
}

/**
* {@inheritDoc}
*/
@Override
public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext context) {
final IPropertyContainer element = childTagWorker.getElementResult();
if (childTagWorker instanceof BrTagWorker) {
return super.processTagChild(childTagWorker, context);
} else {
return addBlockChild((IElement) element);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,18 @@ public class DivTagWorker implements ITagWorker, IDisplayAware {
* @param context the context
*/
public DivTagWorker(IElementNode element, ProcessorContext context) {
div = new Div();
this(element, context, new Div());
}

/**
* Creates a new {@link DivTagWorker} instance.
*
* @param element the element
* @param context the context
* @param container div element container
*/
protected DivTagWorker(IElementNode element, ProcessorContext context, Div container) {
div = container;
Map<String, String> styles = element.getStyles();
if (styles != null && (styles.containsKey(CssConstants.COLUMN_COUNT) || styles.containsKey(CssConstants.COLUMN_WIDTH))) {
multicolContainer = new MulticolContainer();
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/com/itextpdf/html2pdf/css/CssConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ This file is part of the iText (R) project.

public class CssConstants extends CommonCssConstants {

/** The Constant AUTO_FIT. */
public static final String AUTO_FIT = "auto-fit";

/** The Constant AUTO_FILL. */
public static final String AUTO_FILL = "auto-fill";

/** The Constant BLEED. */
public static final String BLEED = "bleed";

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

/** The Constant MIN_MAX. */
public static final String MINMAX = "minmax";

/**
* The Constant OBJECT_FIT.
*/
Expand Down Expand Up @@ -138,8 +147,8 @@ public class CssConstants extends CommonCssConstants {
/** The Constant FIRST_EXCEPT. */
public static final String FIRST_EXCEPT = "first-except";

/** The Constant GRID. */
public static final String GRID = "grid";
/** The Constant GRID_AREA. */
public static final String GRID_AREA = "grid-area";

/** The Constant INLINE. */
public static final String INLINE = "inline";
Expand Down Expand Up @@ -223,6 +232,9 @@ public class CssConstants extends CommonCssConstants {
/** The Constant SUB. */
public static final String SUB = "sub";

/** The Constant SUBGRID. */
public static final String SUBGRID = "subgrid";

/** The Constant SUPER. */
public static final String SUPER = "super";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ This file is part of the iText (R) project.
import com.itextpdf.html2pdf.css.apply.util.FlexApplierUtil;
import com.itextpdf.html2pdf.css.apply.util.FloatApplierUtil;
import com.itextpdf.html2pdf.css.apply.util.FontStyleApplierUtil;
import com.itextpdf.html2pdf.css.apply.util.GridApplierUtil;
import com.itextpdf.html2pdf.css.apply.util.HyphenationApplierUtil;
import com.itextpdf.html2pdf.css.apply.util.MarginApplierUtil;
import com.itextpdf.html2pdf.css.apply.util.OpacityApplierUtil;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
OrphansWidowsApplierUtil.applyOrphansAndWidows(cssProps, container);
VerticalAlignmentApplierUtil.applyVerticalAlignmentForBlocks(cssProps, container, isInlineItem(tagWorker));
MultiColumnCssApplierUtil.applyMultiCol(cssProps, context, container);
GridApplierUtil.applyGridItemProperties(cssProps, stylesContainer, container);
if (isFlexItem(stylesContainer)) {
FlexApplierUtil.applyFlexItemProperties(cssProps, context, container);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class DefaultTagCssApplierMapping {
mapping.putMapping(TagConstants.DIV, CssConstants.TABLE_ROW, () -> new DisplayTableRowTagCssApplier());
mapping.putMapping(TagConstants.DIV, CssConstants.FLEX, () -> new DisplayFlexTagCssApplier());
mapping.putMapping(TagConstants.SPAN, CssConstants.FLEX, () -> new DisplayFlexTagCssApplier());
mapping.putMapping(TagConstants.DIV, CssConstants.GRID, () -> new DisplayGridTagCssApplier());

// pseudo elements mapping
String beforePseudoElemName = CssPseudoElementUtil.createPseudoElementTagName(CssConstants.BEFORE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
container.deleteOwnProperty(Property.OVERFLOW_X);
container.deleteOwnProperty(Property.OVERFLOW_Y);
}
MultiColumnCssApplierUtil.applyMultiCol(stylesContainer.getStyles(), context, container);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itextpdf.html2pdf.css.apply.impl;

import com.itextpdf.html2pdf.attach.ITagWorker;
import com.itextpdf.html2pdf.attach.ProcessorContext;
import com.itextpdf.html2pdf.css.apply.ICssApplier;
import com.itextpdf.html2pdf.css.apply.util.GridApplierUtil;
import com.itextpdf.layout.IPropertyContainer;
import com.itextpdf.styledxmlparser.node.IStylesContainer;

import java.util.Map;

/**
* {@link ICssApplier} implementation for elements with display grid.
*/
public class DisplayGridTagCssApplier extends BlockCssApplier {

/**
* {@inheritDoc}
*/
@Override
public void apply(ProcessorContext context, IStylesContainer stylesContainer, ITagWorker tagWorker) {
super.apply(context, stylesContainer, tagWorker);
final IPropertyContainer container = tagWorker.getElementResult();
if (container != null) {
Map<String, String> cssProps = stylesContainer.getStyles();
GridApplierUtil.applyGridContainerProperties(cssProps, container, context);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public static void applyMultiCol(Map<String, String> cssProps, ProcessorContext
element.setProperty(Property.COLUMN_WIDTH, width.getValue());
}

if (!element.hasProperty(Property.COLUMN_WIDTH) && !element.hasProperty(Property.COLUMN_COUNT)) {
if (CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_COUNT))
|| CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_WIDTH))) {
element.setProperty(Property.COLUMN_COUNT, 1);
} else {
return;
}
}

final UnitValue gap = CssDimensionParsingUtils.parseLengthValueToPt(cssProps.get(CssConstants.COLUMN_GAP),
emValue, remValue);
if (gap != null) {
Expand All @@ -74,11 +83,6 @@ public static void applyMultiCol(Map<String, String> cssProps, ProcessorContext
if (!element.hasProperty(Property.COLUMN_GAP)) {
element.setProperty(Property.COLUMN_GAP, CssDimensionParsingUtils.parseRelativeValue("1em", emValue));
}
if (!element.hasProperty(Property.COLUMN_COUNT) && !element.hasProperty(Property.COLUMN_WIDTH)
&& (CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_COUNT))
|| CommonCssConstants.AUTO.equals(cssProps.get(CssConstants.COLUMN_WIDTH)))) {
element.setProperty(Property.COLUMN_COUNT, 1);
}

final Border borderFromCssProperties = BorderStyleApplierUtil.getCertainBorder(
cssProps.get(CssConstants.COLUMN_RULE_WIDTH), cssProps.get(CssConstants.COLUMN_RULE_STYLE),
Expand Down
Loading

0 comments on commit 913de2b

Please sign in to comment.