Skip to content

Commit f96f0f1

Browse files
committed
[RELEASE] iText pdfHtml 5.0.2
2 parents 353b122 + d0c13e2 commit f96f0f1

File tree

192 files changed

+9908
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+9908
-177
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Contributing to iText 7 Community
1+
# Contributing to iText Community
22

3-
We'd love for you to contribute to our source code and to make **iText 7 Community** even better than it is
3+
We'd love for you to contribute to our source code and to make **iText Community** even better than it is
44
today! Here are the guidelines we'd like you to follow:
55

66
- [Question or Problem?](#question)
@@ -15,7 +15,7 @@ today! Here are the guidelines we'd like you to follow:
1515

1616
## <a name="question">Got a Question or Problem?</a>
1717

18-
If you have questions about how to use **iText 7 Community**, please direct these to [Stack Overflow][stackoverflow].
18+
If you have questions about how to use **iText Community**, please direct these to [Stack Overflow][stackoverflow].
1919

2020
If you are a customer with a [support agreement][support], you also have direct access to our JIRA and our developers.
2121

@@ -55,7 +55,7 @@ chances of your issue being dealt with quickly:
5555
* **Related Issues** - has a similar issue been reported before?
5656
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
5757
causing the problem (line of code or commit)
58-
* **Tag the question** - add the tag `itext7` to your question so we can find it.
58+
* **Tag the question** - add the tag `itext` to your question so we can find it.
5959

6060
**If you get help, help others. Good karma rulez!**
6161

@@ -79,7 +79,7 @@ Before you submit your pull request consider the following guidelines:
7979
* Build your changes locally to ensure all the tests pass.
8080
* Push your changes to your GitHub account.
8181
* Create a pull request in GitHub.
82-
"Head fork" should be your repository, and the "base fork" should be the iText7 official repository.
82+
"Head fork" should be your repository, and the "base fork" should be the iText official repository.
8383
* If we suggest changes then:
8484
* Make the required updates.
8585
* Fix up your commits if needed, with an interactive rebase.
@@ -111,7 +111,7 @@ To ensure consistency throughout the source code, keep these rules in mind as yo
111111

112112
We have guidelines on how our git commit messages should be formatted. This leads to **more
113113
readable messages** that are easy to follow when looking through the **project history**. But also,
114-
we use the git commit messages to **generate the iText 7 Community change log**.
114+
we use the git commit messages to **generate the iText Community change log**.
115115

116116
These guidelines were taken from Chris Beams' blog post [How to Write a Git Commit Message][git-commit].
117117

@@ -169,7 +169,7 @@ We use the [Stack Exchange][stackoverflow] network for free support and [GitHub]
169169
[javadocs]: https://itextpdf.com/api
170170
[pull]: https://github.com/itext/i7j-pdfhtml/pulls
171171
[sscce]: http://sscce.org/
172-
[stackoverflow]: https://stackoverflow.com/questions/tagged/itext7
172+
[stackoverflow]: https://stackoverflow.com/questions/tagged/itext
173173
[good-questions]: https://stackoverflow.com/help/how-to-ask
174174
[mcve]: https://stackoverflow.com/help/mcve
175175
[support]: https://itextpdf.com/support

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**[pdfHtml][pdfHtml]** is an [iText 7][itext] add on.
1+
**[pdfHtml][pdfHtml]** is an [iText][itext] add on.
22

33
This add on will allow you to easily convert HTML to PDF or iText objects.
44

@@ -35,4 +35,4 @@ Contact [sales] for more info.
3535
[latest]: https://github.com/itext/i7j-pdfhtml/releases/latest
3636
[sales]: http://itextpdf.com/sales
3737
[gratis]: https://en.wikipedia.org/wiki/Gratis_versus_libre
38-
[pdfHtml]: http://itextpdf.com/itext7/pdfHtml
38+
[pdfHtml]: https://itextpdf.com/products/convert-html-css-to-pdf-pdfhtml

pom.xml

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

1212
<artifactId>html2pdf</artifactId>
13-
<version>5.0.1</version>
13+
<version>5.0.2</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
1717
them to PDF.</description>
1818

1919
<scm>
20-
<connection>scm:git:ssh://[email protected].com:7999/i7j/html2pdf.git</connection>
21-
<url>https://git.itextsupport.com/projects/I7J/repos/html2pdf</url>
20+
<connection>git@github.com:itext/i7j-pdfhtml.git</connection>
21+
<url>https://github.com/itext/i7j-pdfhtml</url>
2222
</scm>
2323

2424
<properties>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.html2pdf;
2424

25+
import com.itextpdf.commons.actions.contexts.IMetaInfo;
2526
import com.itextpdf.html2pdf.attach.ITagWorkerFactory;
2627
import com.itextpdf.html2pdf.attach.impl.OutlineHandler;
2728
import com.itextpdf.html2pdf.css.apply.ICssApplierFactory;
28-
import com.itextpdf.commons.actions.contexts.IMetaInfo;
2929
import com.itextpdf.layout.font.FontProvider;
3030
import com.itextpdf.styledxmlparser.css.media.MediaDeviceDescription;
3131
import com.itextpdf.styledxmlparser.resolver.resource.IResourceRetriever;
@@ -326,8 +326,11 @@ public boolean isCreateAcroForm() {
326326
* If createAcroForm is set, then when the form is encountered in HTML, AcroForm will be created, otherwise
327327
* a visually identical, but not functional element will be created. Please bare in mind that the created
328328
* Acroform may visually differ a bit from the HTML one.
329+
* <p>
330+
* When enabling this acroform creation, it will disable the immediateFlushing property.
329331
*
330332
* @param createAcroForm true if an AcroForm needs to be created
333+
*
331334
* @return the {@link ConverterProperties} instance
332335
*/
333336
public ConverterProperties setCreateAcroForm(boolean createAcroForm) {

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.1";
33+
private static final String PDF_HTML_VERSION = "5.0.2";
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/impl/tags/HtmlTagWorker.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ This file is part of the iText (R) project.
3131
import com.itextpdf.html2pdf.attach.util.WaitingInlineElementsHelper;
3232
import com.itextpdf.html2pdf.css.CssConstants;
3333
import com.itextpdf.html2pdf.html.AttributeConstants;
34+
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
3435
import com.itextpdf.io.font.PdfEncodings;
3536
import com.itextpdf.kernel.pdf.PdfDocument;
3637
import com.itextpdf.kernel.pdf.PdfString;
@@ -45,15 +46,24 @@ This file is part of the iText (R) project.
4546
import com.itextpdf.styledxmlparser.node.IElementNode;
4647
import com.itextpdf.styledxmlparser.node.INode;
4748

49+
import org.slf4j.Logger;
50+
import org.slf4j.LoggerFactory;
51+
4852
/**
4953
* TagWorker class for the {@code html} element.
5054
*/
5155
public class HtmlTagWorker implements ITagWorker {
5256

53-
/** The iText document instance. */
57+
private static final Logger LOGGER = LoggerFactory.getLogger(HtmlTagWorker.class);
58+
59+
/**
60+
* The iText document instance.
61+
*/
5462
private Document document;
5563

56-
/** Helper class for waiting inline elements. */
64+
/**
65+
* Helper class for waiting inline elements.
66+
*/
5767
private WaitingInlineElementsHelper inlineHelper;
5868

5969
/**
@@ -65,14 +75,19 @@ public class HtmlTagWorker implements ITagWorker {
6575
public HtmlTagWorker(IElementNode element, ProcessorContext context) {
6676
// TODO DEVSIX-4261 more precise check if a counter was actually added to the document
6777
boolean immediateFlush =
68-
context.isImmediateFlush() && !context.getCssContext().isPagesCounterPresent();
78+
context.isImmediateFlush() && !context.getCssContext().isPagesCounterPresent()
79+
&& !context.isCreateAcroForm();
80+
if (context.isImmediateFlush() && context.isCreateAcroForm()) {
81+
LOGGER.info(Html2PdfLogMessageConstant.IMMEDIATE_FLUSH_DISABLED);
82+
}
6983
PdfDocument pdfDocument = context.getPdfDocument();
7084
document = new HtmlDocument(pdfDocument, pdfDocument.getDefaultPageSize(), immediateFlush);
7185
document.setRenderer(new HtmlDocumentRenderer(document, immediateFlush));
7286

7387
DefaultHtmlProcessor.setConvertedRootElementProperties(element.getStyles(), context, document);
7488

75-
inlineHelper = new WaitingInlineElementsHelper(element.getStyles().get(CssConstants.WHITE_SPACE), element.getStyles().get(CssConstants.TEXT_TRANSFORM));
89+
inlineHelper = new WaitingInlineElementsHelper(element.getStyles().get(CssConstants.WHITE_SPACE),
90+
element.getStyles().get(CssConstants.TEXT_TRANSFORM));
7691

7792
String lang = element.getAttribute(AttributeConstants.LANG);
7893
if (lang != null) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ This file is part of the iText (R) project.
3636
import com.itextpdf.layout.element.Image;
3737
import com.itextpdf.layout.properties.ObjectFit;
3838
import com.itextpdf.styledxmlparser.node.IElementNode;
39+
import com.itextpdf.svg.element.SvgImage;
40+
import com.itextpdf.svg.xobject.SvgImageXObject;
3941
import org.slf4j.Logger;
4042
import org.slf4j.LoggerFactory;
4143

@@ -71,6 +73,8 @@ public ImgTagWorker(IElementNode element, ProcessorContext context) {
7173
if (imageXObject != null) {
7274
if (imageXObject instanceof PdfImageXObject) {
7375
image = new HtmlImage((PdfImageXObject) imageXObject);
76+
} else if (imageXObject instanceof SvgImageXObject) {
77+
image = new SvgImage((SvgImageXObject) imageXObject);
7478
} else if (imageXObject instanceof PdfFormXObject) {
7579
image = new HtmlImage((PdfFormXObject) imageXObject);
7680
} else {

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ This file is part of the iText (R) project.
3131
import com.itextpdf.html2pdf.util.SvgProcessingUtil;
3232
import com.itextpdf.commons.utils.FileUtil;
3333
import com.itextpdf.commons.utils.MessageFormatUtil;
34-
import com.itextpdf.kernel.pdf.PdfDocument;
3534
import com.itextpdf.layout.IPropertyContainer;
3635
import com.itextpdf.layout.element.Image;
3736
import com.itextpdf.styledxmlparser.node.IElementNode;
@@ -117,17 +116,10 @@ private boolean isSvgImage(String typeAttribute) {
117116

118117
@Override
119118
public void processEnd(IElementNode element, ProcessorContext context) {
120-
if (context.getPdfDocument() != null) {
121-
PdfDocument document = context.getPdfDocument();
122-
//Create Image object
123-
124-
if (res != null) {
125-
image = processUtil.createImageFromProcessingResult(res, document);
126-
AccessiblePropHelper.trySetLangAttribute(image, element);
127-
}
128-
129-
} else {
130-
LOGGER.error(Html2PdfLogMessageConstant.PDF_DOCUMENT_NOT_PRESENT);
119+
// Create Image object
120+
if (res != null) {
121+
image = processUtil.createSvgImageFromProcessingResult(res);
122+
AccessiblePropHelper.trySetLangAttribute(image, element);
131123
}
132124
}
133125

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public SvgTagWorker(IElementNode element, ProcessorContext context) {
6868

6969
@Override
7070
public void processEnd(IElementNode element, ProcessorContext context) {
71-
if (context.getPdfDocument() != null && processingResult != null) {
71+
if (processingResult != null) {
7272
SvgProcessingUtil util = new SvgProcessingUtil(context.getResourceResolver());
73-
svgImage = util.createImageFromProcessingResult(processingResult, context.getPdfDocument());
73+
svgImage = util.createSvgImageFromProcessingResult(processingResult);
7474

7575
AccessiblePropHelper.trySetLangAttribute(svgImage, element);
7676
context.endProcessingInlineSvg();

src/main/java/com/itextpdf/html2pdf/css/apply/util/BackgroundApplierUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ This file is part of the iText (R) project.
2626
import com.itextpdf.html2pdf.attach.ProcessorContext;
2727
import com.itextpdf.html2pdf.css.CssConstants;
2828
import com.itextpdf.commons.utils.MessageFormatUtil;
29-
import com.itextpdf.kernel.colors.Color;
30-
import com.itextpdf.kernel.colors.DeviceRgb;
3129
import com.itextpdf.kernel.colors.gradients.StrategyBasedLinearGradientBuilder;
3230
import com.itextpdf.kernel.pdf.xobject.PdfFormXObject;
3331
import com.itextpdf.kernel.pdf.xobject.PdfImageXObject;

src/main/java/com/itextpdf/html2pdf/css/apply/util/ListStyleApplierUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ This file is part of the iText (R) project.
5353
import com.itextpdf.styledxmlparser.node.IElementNode;
5454
import com.itextpdf.styledxmlparser.node.IStylesContainer;
5555

56+
import com.itextpdf.svg.element.SvgImage;
57+
import com.itextpdf.svg.xobject.SvgImageXObject;
5658
import org.slf4j.Logger;
5759
import org.slf4j.LoggerFactory;
5860

@@ -145,6 +147,8 @@ public static void applyListStyleImageProperty(Map<String, String> cssProps, Pro
145147
Image image = null;
146148
if (imageXObject instanceof PdfImageXObject) {
147149
image = new Image((PdfImageXObject) imageXObject);
150+
} else if (imageXObject instanceof SvgImageXObject) {
151+
image = new SvgImage((SvgImageXObject) imageXObject);
148152
} else if (imageXObject instanceof PdfFormXObject) {
149153
image = new Image((PdfFormXObject) imageXObject);
150154
} else {

src/main/java/com/itextpdf/html2pdf/css/apply/util/VerticalAlignmentApplierUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public static void applyVerticalAlignmentForInlines(Map<String, String> cssProps
141141
String vAlignVal = cssProps.get(CssConstants.VERTICAL_ALIGN);
142142
if (vAlignVal != null) {
143143

144-
// TODO DEVSIX-1750 for inline images and tables (inline-blocks) v-align is not supported
144+
// TODO DEVSIX-1961 for inline images and tables (inline-blocks) v-align is not supported
145145

146146
float textRise = 0;
147147

src/main/java/com/itextpdf/html2pdf/logs/Html2PdfLogMessageConstant.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ public final class Html2PdfLogMessageConstant {
119119
public static final String PAGE_SIZE_VALUE_IS_INVALID = "Page size value {0} is invalid.";
120120

121121
/** The Constant PDF_DOCUMENT_NOT_PRESENT. */
122+
@Deprecated
122123
public static final String PDF_DOCUMENT_NOT_PRESENT = "PdfDocument is not present";
123124

124125
/** The Constant QUOTES_PROPERTY_INVALID. */
@@ -171,6 +172,7 @@ public final class Html2PdfLogMessageConstant {
171172
public static final String ELEMENT_DOES_NOT_FIT_CURRENT_AREA = "Element does not fit current area";
172173
public static final String OPTGROUP_NOT_SUPPORTED_IN_INTERACTIVE_SELECT = "Option groups are not supported in "
173174
+ "interactive mode";
175+
public static final String IMMEDIATE_FLUSH_DISABLED = "Setting createAcroForm disables immediateFlush property";
174176

175177
private Html2PdfLogMessageConstant() {
176178
//Private constructor will prevent the instantiation of this class directly

src/main/java/com/itextpdf/html2pdf/resolver/font/DefaultFontProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This file is part of the iText (R) project.
3838

3939
/**
4040
* The default {@link BasicFontProvider} for pdfHTML, that, as opposed to
41-
* the font provider in iText 7's styled-xml-parser, also includes a
41+
* the font provider in iText's styled-xml-parser, also includes a
4242
* series of fonts that are shipped with the add-on.
4343
*/
4444
public class DefaultFontProvider extends BasicFontProvider {

src/main/java/com/itextpdf/html2pdf/resolver/resource/HtmlResourceResolver.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This file is part of the iText (R) project.
3232
import com.itextpdf.styledxmlparser.resolver.resource.IResourceRetriever;
3333
import com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver;
3434
import com.itextpdf.svg.converter.SvgConverter;
35+
import com.itextpdf.svg.element.SvgImage;
3536
import com.itextpdf.svg.processors.ISvgProcessorResult;
3637
import com.itextpdf.svg.processors.impl.SvgConverterProperties;
3738

@@ -49,7 +50,7 @@ public class HtmlResourceResolver extends ResourceResolver {
4950
private static final String SVG_PREFIX = "data:image/svg+xml";
5051
private static final Pattern SVG_IDENTIFIER_PATTERN = Pattern.compile(",[\\s]*(<svg )");
5152

52-
private ProcessorContext context;
53+
private final ProcessorContext context;
5354

5455
/**
5556
* Creates a new {@link HtmlResourceResolver} instance.
@@ -108,7 +109,7 @@ protected PdfXObject tryResolveBase64ImageSource(String src) {
108109
if (fixedSrc.startsWith(SVG_PREFIX)) {
109110
fixedSrc = fixedSrc.substring(fixedSrc.indexOf(BASE64_IDENTIFIER) + BASE64_IDENTIFIER.length() + 1);
110111
try (ByteArrayInputStream stream = new ByteArrayInputStream(Base64.decode(fixedSrc))) {
111-
PdfFormXObject xObject = processAsSvg(stream, context, null);
112+
PdfFormXObject xObject = HtmlResourceResolver.processAsSvg(stream, context, null);
112113
if (xObject != null) {
113114
return xObject;
114115
}
@@ -131,7 +132,7 @@ protected PdfXObject createImageByUrl(URL url) throws Exception {
131132

132133
private PdfXObject tryResolveSvgImageSource(String src) {
133134
try (ByteArrayInputStream stream = new ByteArrayInputStream(src.getBytes(StandardCharsets.UTF_8))) {
134-
PdfFormXObject xObject = processAsSvg(stream, context, null);
135+
PdfFormXObject xObject = HtmlResourceResolver.processAsSvg(stream, context, null);
135136
if (xObject != null) {
136137
return xObject;
137138
}
@@ -147,11 +148,7 @@ private static PdfFormXObject processAsSvg(InputStream stream, ProcessorContext
147148
svgConverterProperties.setBaseUri(parentDir);
148149
}
149150
ISvgProcessorResult res = SvgConverter.parseAndProcess(stream, svgConverterProperties);
150-
if (context.getPdfDocument() != null) {
151-
SvgProcessingUtil processingUtil = new SvgProcessingUtil(context.getResourceResolver());
152-
return processingUtil.createXObjectFromProcessingResult(res, context.getPdfDocument());
153-
} else {
154-
return null;
155-
}
151+
SvgProcessingUtil processingUtil = new SvgProcessingUtil(context.getResourceResolver());
152+
return processingUtil.createXObjectFromProcessingResult(res, context.getPdfDocument());
156153
}
157154
}

0 commit comments

Comments
 (0)