Skip to content

Commit 353b122

Browse files
committed
[RELEASE] iText pdfHTML 5.0.1
2 parents b128b3d + bd7af94 commit 353b122

File tree

2,662 files changed

+59184
-372
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,662 files changed

+59184
-372
lines changed

pom.xml

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

1212
<artifactId>html2pdf</artifactId>
13-
<version>5.0.0</version>
13+
<version>5.0.1</version>
1414

1515
<name>pdfHTML</name>
16-
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
16+
<description>pdfHTML is an iText add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
1717
them to PDF.</description>
1818

1919
<scm>

sharpenConfiguration.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<configuration>
3+
<ignored>
4+
<java>
5+
<fileset reason="The Iterator pattern in Java is equivalent to IEnumerable in .NET, but we cannot map them on each other.">
6+
<file path="com/itextpdf/html2pdf/css/resolve/CssContentElementNode.java"/>
7+
</fileset>
8+
<fileset reason="The ignore is added here because the work with absolute path and URI is not autoportable.">
9+
<file path="com/itextpdf/html2pdf/resolver/resource/PathUtil.java"/>
10+
</fileset>
11+
<fileset reason="Added mto ignored because ExecutorService and usage of Futures are not autoportable">
12+
<file path="com/itextpdf/html2pdf/HtmlConverterMultiThreadedTest.java"/>
13+
</fileset>
14+
</java>
15+
<resource>
16+
<file path="com/itextpdf/html2pdf/css/w3c/css21/text/text-transform-uppercase-002.pdf" />
17+
</resource>
18+
</ignored>
19+
</configuration>

src/main/java/com/itextpdf/html2pdf/ConverterProperties.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ public class ConverterProperties {
100100
*/
101101
private IMetaInfo metaInfo;
102102

103+
/**
104+
* enables continuous container for all elements.
105+
*/
106+
private boolean continuousContainerEnabled;
107+
103108
/**
104109
* Instantiates a new {@link ConverterProperties} instance.
105110
*/
@@ -125,6 +130,7 @@ public ConverterProperties(ConverterProperties other) {
125130
this.metaInfo = other.metaInfo;
126131
this.limitOfLayouts = other.limitOfLayouts;
127132
this.immediateFlush = other.immediateFlush;
133+
this.continuousContainerEnabled = other.continuousContainerEnabled;
128134
}
129135

130136
/**
@@ -440,4 +446,24 @@ public ConverterProperties setEventMetaInfo(IMetaInfo metaInfo) {
440446
this.metaInfo = metaInfo;
441447
return this;
442448
}
449+
450+
/**
451+
* check if continuous container is enabled.
452+
*
453+
* @return true if enabled, false otherwise
454+
*/
455+
public boolean isContinuousContainerEnabled() {
456+
return continuousContainerEnabled;
457+
}
458+
459+
/**
460+
* Sets continuous container support.
461+
*
462+
* @param value true to set continuous container, false otherwise
463+
* @return the {@link ConverterProperties} instance
464+
*/
465+
public ConverterProperties setContinuousContainerEnabled(boolean value) {
466+
continuousContainerEnabled = value;
467+
return this;
468+
}
443469
}

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

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ public class ProcessorContext {
143143

144144
private final int limitOfLayouts;
145145

146+
/**
147+
* enables continuous container for all elements.
148+
*/
149+
private boolean continuousContainerEnabled;
150+
146151
/**
147152
* Instantiates a new {@link ProcessorContext} instance.
148153
*
@@ -195,6 +200,7 @@ public ProcessorContext(ConverterProperties converterProperties) {
195200
radioCheckResolver = new RadioCheckResolver();
196201
immediateFlush = converterProperties.isImmediateFlush();
197202
processingInlineSvg = false;
203+
continuousContainerEnabled = converterProperties.isContinuousContainerEnabled();
198204
}
199205

200206
/**
@@ -484,4 +490,14 @@ public void startProcessingInlineSvg() {
484490
public void endProcessingInlineSvg(){
485491
processingInlineSvg = false;
486492
}
493+
494+
495+
/**
496+
* check if continuous container is enabled.
497+
*
498+
* @return true if enabled, false otherwise
499+
*/
500+
public boolean isContinuousContainerEnabled() {
501+
return continuousContainerEnabled;
502+
}
487503
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ private void visit(INode node) {
360360
} else if (tagWorker.getElementResult() != null) {
361361
roots.add(tagWorker.getElementResult());
362362
}
363+
364+
if (tagWorker.getElementResult() != null && context.isContinuousContainerEnabled()) {
365+
tagWorker.getElementResult().setProperty(Property.COLLAPSING_MARGINS, Boolean.FALSE);
366+
tagWorker.getElementResult().setProperty(Property.TREAT_AS_CONTINUOUS_CONTAINER, true);
367+
}
363368
}
364369

365370
element.setStyles(null);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ This file is part of the iText (R) project.
2626
import com.itextpdf.html2pdf.attach.ITagWorkerFactory;
2727
import com.itextpdf.html2pdf.attach.ProcessorContext;
2828
import com.itextpdf.html2pdf.attach.impl.DefaultTagWorkerMapping.ITagWorkerCreator;
29-
import com.itextpdf.html2pdf.util.TagProcessorMapping;
3029
import com.itextpdf.html2pdf.css.CssConstants;
30+
import com.itextpdf.html2pdf.util.TagProcessorMapping;
3131
import com.itextpdf.styledxmlparser.node.IElementNode;
3232

3333
/**

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This file is part of the iText (R) project.
3535
import com.itextpdf.layout.element.IElement;
3636
import com.itextpdf.layout.element.ILeafElement;
3737
import com.itextpdf.layout.element.Image;
38+
import com.itextpdf.layout.element.MulticolContainer;
3839
import com.itextpdf.styledxmlparser.node.IElementNode;
3940

4041
import java.util.Map;
@@ -44,6 +45,11 @@ This file is part of the iText (R) project.
4445
*/
4546
public class DivTagWorker implements ITagWorker, IDisplayAware {
4647

48+
/**
49+
* Column container element.
50+
*/
51+
protected MulticolContainer multicolContainer;
52+
4753
/** The div element. */
4854
private Div div;
4955

@@ -62,6 +68,10 @@ public class DivTagWorker implements ITagWorker, IDisplayAware {
6268
public DivTagWorker(IElementNode element, ProcessorContext context) {
6369
div = new Div();
6470
Map<String, String> styles = element.getStyles();
71+
if (styles != null && (styles.containsKey(CssConstants.COLUMN_COUNT) || styles.containsKey(CssConstants.COLUMN_WIDTH))) {
72+
multicolContainer = new MulticolContainer();
73+
multicolContainer.add(div);
74+
}
6575
inlineHelper = new WaitingInlineElementsHelper(styles == null ? null : styles.get(CssConstants.WHITE_SPACE),
6676
styles == null ? null : styles.get(CssConstants.TEXT_TRANSFORM));
6777
display = element.getStyles() != null ? element.getStyles().get(CssConstants.DISPLAY) : null;
@@ -132,7 +142,7 @@ public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext conte
132142
*/
133143
@Override
134144
public IPropertyContainer getElementResult() {
135-
return div;
145+
return multicolContainer == null ? div : multicolContainer;
136146
}
137147

138148
/* (non-Javadoc)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public boolean processContent(String content, ProcessorContext context) {
9595
super.processContent(content, context);
9696
}
9797
if (!fakedContent) {
98-
actualOptionTextContent.append(content); // TODO DEVSIX-1901: spaces are not collapsed according to white-space property in here
98+
// TODO DEVSIX-2443: spaces are not collapsed according to white-space property in here
99+
actualOptionTextContent.append(content);
99100
}
100101
return true;
101102
}

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

Lines changed: 19 additions & 1 deletion
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.layout.element.IElement;
3434
import com.itextpdf.layout.element.ILeafElement;
3535
import com.itextpdf.layout.element.Image;
36+
import com.itextpdf.layout.element.MulticolContainer;
3637
import com.itextpdf.layout.element.Paragraph;
3738
import com.itextpdf.styledxmlparser.node.IElementNode;
3839

@@ -57,6 +58,11 @@ public class PTagWorker implements ITagWorker, IDisplayAware {
5758
/** The container which handles the elements that are present in the &lt;p&gt; tag. */
5859
private Div elementsContainer;
5960

61+
/**
62+
* Container for the result in case of multicol layouting
63+
*/
64+
protected MulticolContainer multicolContainer;
65+
6066
/** Helper class for waiting inline elements. */
6167
private WaitingInlineElementsHelper inlineHelper;
6268

@@ -71,6 +77,11 @@ public class PTagWorker implements ITagWorker, IDisplayAware {
7177
*/
7278
public PTagWorker(IElementNode element, ProcessorContext context) {
7379
lastParagraph = new Paragraph();
80+
81+
if (element.getStyles().get(CssConstants.COLUMN_COUNT) != null || element.getStyles().get(CssConstants.COLUMN_WIDTH) != null) {
82+
multicolContainer = new MulticolContainer();
83+
multicolContainer.add(lastParagraph);
84+
}
7485
inlineHelper = new WaitingInlineElementsHelper(element.getStyles().get(CssConstants.WHITE_SPACE),
7586
element.getStyles().get(CssConstants.TEXT_TRANSFORM));
7687
display = element.getStyles() != null ? element.getStyles().get(CssConstants.DISPLAY) : null;
@@ -151,7 +162,10 @@ public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext conte
151162
*/
152163
@Override
153164
public IPropertyContainer getElementResult() {
154-
return null == elementsContainer ? (IPropertyContainer) lastParagraph : (IPropertyContainer) elementsContainer;
165+
if (multicolContainer == null) {
166+
return null == elementsContainer ? (IPropertyContainer) lastParagraph : (IPropertyContainer) elementsContainer;
167+
}
168+
return multicolContainer;
155169
}
156170

157171
@Override
@@ -163,6 +177,10 @@ private void processBlockElement(IElement propertyContainer) {
163177
if (elementsContainer == null) {
164178
elementsContainer = new Div();
165179
elementsContainer.add(lastParagraph);
180+
if (multicolContainer != null) {
181+
multicolContainer.getChildren().clear();
182+
multicolContainer.add(elementsContainer);
183+
}
166184
}
167185
inlineHelper.flushHangingLeaves(lastParagraph);
168186

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

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,35 @@ This file is part of the iText (R) project.
2626
import com.itextpdf.forms.form.element.AbstractSelectField;
2727
import com.itextpdf.forms.form.element.ComboBoxField;
2828
import com.itextpdf.forms.form.element.ListBoxField;
29+
import com.itextpdf.forms.form.element.SelectFieldItem;
2930
import com.itextpdf.html2pdf.attach.ITagWorker;
3031
import com.itextpdf.html2pdf.attach.ProcessorContext;
32+
import com.itextpdf.html2pdf.css.CssConstants;
33+
import com.itextpdf.html2pdf.html.AttributeConstants;
34+
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
3135
import com.itextpdf.layout.IPropertyContainer;
3236
import com.itextpdf.layout.element.IBlockElement;
33-
import com.itextpdf.html2pdf.html.AttributeConstants;
34-
import com.itextpdf.html2pdf.css.CssConstants;
37+
import com.itextpdf.layout.properties.Property;
3538
import com.itextpdf.styledxmlparser.css.util.CssDimensionParsingUtils;
3639
import com.itextpdf.styledxmlparser.node.IElementNode;
3740

41+
import org.slf4j.Logger;
42+
import org.slf4j.LoggerFactory;
43+
3844
/**
3945
* TagWorker class for the {@code select} element.
4046
*/
4147
public class SelectTagWorker implements ITagWorker, IDisplayAware {
4248

43-
/** The form element. */
49+
private static final Logger LOGGER = LoggerFactory.getLogger(SelectTagWorker.class);
50+
/**
51+
* The form element.
52+
*/
4453
private AbstractSelectField selectElement;
4554

46-
/** The display. */
55+
/**
56+
* The display.
57+
*/
4758
private String display;
4859

4960
/**
@@ -61,6 +72,12 @@ public SelectTagWorker(IElementNode element, ProcessorContext context) {
6172

6273
if (size > 1 || multipleAttr) {
6374
selectElement = new ListBoxField(name, size, multipleAttr);
75+
76+
// Remove some properties which are set in ListBoxField constructor
77+
selectElement.deleteOwnProperty(Property.PADDING_LEFT);
78+
selectElement.deleteOwnProperty(Property.PADDING_RIGHT);
79+
selectElement.deleteOwnProperty(Property.PADDING_TOP);
80+
selectElement.deleteOwnProperty(Property.PADDING_BOTTOM);
6481
} else {
6582
selectElement = new ComboBoxField(name);
6683
}
@@ -84,7 +101,16 @@ public boolean processContent(String content, ProcessorContext context) {
84101
public boolean processTagChild(ITagWorker childTagWorker, ProcessorContext context) {
85102
if (childTagWorker instanceof OptionTagWorker || childTagWorker instanceof OptGroupTagWorker) {
86103
if (childTagWorker.getElementResult() instanceof IBlockElement) {
87-
selectElement.addOption((IBlockElement) childTagWorker.getElementResult());
104+
IBlockElement blockElement = (IBlockElement) childTagWorker.getElementResult();
105+
String label = blockElement.<String>getProperty(FormProperty.FORM_FIELD_LABEL);
106+
SelectFieldItem item = new SelectFieldItem(label, blockElement);
107+
selectElement.addOption(item);
108+
109+
Boolean isFlattenFromProperty = selectElement.<Boolean>getProperty(FormProperty.FORM_FIELD_FLATTEN);
110+
if (childTagWorker instanceof OptGroupTagWorker && !Boolean.TRUE.equals(isFlattenFromProperty)) {
111+
LOGGER.warn(Html2PdfLogMessageConstant.OPTGROUP_NOT_SUPPORTED_IN_INTERACTIVE_SELECT);
112+
}
113+
88114
return true;
89115
}
90116
}

0 commit comments

Comments
 (0)