Skip to content

Commit 741932c

Browse files
committed
[RELEASE] iText 7 pdfHTML - 2.1.0
https://github.com/itext/i7j-pdfhtml/releases/tag/2.1.0 * release/2.1.0: [RELEASE] 2.1.0-SNAPSHOT -> 2.1.0 Add missing copyright headers Implement unicode-range processing. Process li's inline children as inline elements. Process br inside oi correctly. Create test for DEVSIX-2002 SvgDrawContext: add ResourceResolver and FontProvider to constructor Remove collectCssDeclarations form ICssResolver interface RND-1056 Fix typo in test Inline svg integration Add tests for border radius Fix style inheritance change not applied Delete duplicate package that were moved to SXP Add test. DEVSIX-2024 Support event meta info Add a new border radius related test. Update cmps related to span's border radius. Add some new border radius tests. Update cmps. Change placeholder's default font color. Fix some cmps. Add a new test. Add generic event Fix applying page-break-before and page-break-after to tables Refactor time-based system utils to better represent there purpose Updates for autoport Support SVG processing in pdfHTML Update cmp files. DEVSIX-1966 Add ExtendedHtmlConversionITextTest class, refactor html2pdf tests Add missed @category Support placeholder for textarea tag. Add support for display:block of `label` HTML element Process white-space css property for page margin boxes content Apply font styles in BodyTagCssApplier Remove body font-size from default.css Support background for <html> and <body> tags Fix bug in if-condition for align attribute resolving Implement placeholder. Add new input tests. Add new test for inline elements with border-radius Unignore test Update cmp file [RELEASE] 2.0.2-SNAPSHOT -> 2.0.3-SNAPSHOT
2 parents 1364dfb + 3a2033b commit 741932c

File tree

1,395 files changed

+7540
-52255
lines changed

Some content is hidden

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

1,395 files changed

+7540
-52255
lines changed

pom.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
54
<parent>
65
<groupId>com.itextpdf</groupId>
76
<artifactId>root</artifactId>
8-
<version>7.1.2</version>
9-
<relativePath />
7+
<version>7.1.3</version>
8+
<relativePath/>
109
</parent>
11-
1210
<artifactId>html2pdf</artifactId>
13-
<version>2.0.2</version>
14-
11+
<version>2.1.0</version>
1512
<name>pdfHTML</name>
1613
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
1714
them to PDF.</description>
1815
<url>http://itextpdf.com/</url>
19-
2016
<properties>
2117
<itext.version>${project.parent.version}</itext.version>
2218
<javadoc.version>3.0.0</javadoc.version>
2319
</properties>
24-
2520
<repositories>
2621
<repository>
2722
<snapshots>
@@ -40,7 +35,6 @@
4035
<url>https://repo.itextsupport.com/releases</url>
4136
</repository>
4237
</repositories>
43-
4438
<dependencies>
4539
<dependency>
4640
<groupId>com.itextpdf</groupId>
@@ -52,6 +46,11 @@
5246
<artifactId>layout</artifactId>
5347
<version>${itext.version}</version>
5448
</dependency>
49+
<dependency>
50+
<groupId>com.itextpdf</groupId>
51+
<artifactId>svg</artifactId>
52+
<version>${itext.version}</version>
53+
</dependency>
5554
<dependency>
5655
<groupId>com.itextpdf</groupId>
5756
<artifactId>hyph</artifactId>
@@ -71,7 +70,6 @@
7170
<scope>test</scope>
7271
</dependency>
7372
</dependencies>
74-
7573
<build>
7674
<resources>
7775
<resource>

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
55
66
This program is free software; you can redistribute it and/or modify
@@ -45,9 +45,11 @@ This file is part of the iText (R) project.
4545

4646
import com.itextpdf.html2pdf.attach.ITagWorkerFactory;
4747
import com.itextpdf.html2pdf.attach.impl.OutlineHandler;
48+
import com.itextpdf.html2pdf.css.CssConstants;
4849
import com.itextpdf.html2pdf.css.apply.ICssApplierFactory;
49-
import com.itextpdf.html2pdf.css.media.MediaDeviceDescription;
50+
import com.itextpdf.kernel.counter.event.IMetaInfo;
5051
import com.itextpdf.layout.font.FontProvider;
52+
import com.itextpdf.styledxmlparser.css.media.MediaDeviceDescription;
5153

5254
/**
5355
* Properties that will be used by the converter.
@@ -81,6 +83,9 @@ public class ConverterProperties {
8183
/** Indicates whether the document should be opened in immediate flush or not **/
8284
private boolean immediateFlush = true;
8385

86+
/** Meta info that will be added to the events thrown by html2Pdf */
87+
private IMetaInfo metaInfo;
88+
8489
/**
8590
* Instantiates a new {@link ConverterProperties} instance.
8691
*/
@@ -102,6 +107,7 @@ public ConverterProperties(ConverterProperties other) {
102107
this.createAcroForm = other.createAcroForm;
103108
this.outlineHandler = other.outlineHandler;
104109
this.charset = other.charset;
110+
this.metaInfo = other.metaInfo;
105111
}
106112

107113
/**
@@ -289,4 +295,26 @@ public ConverterProperties setImmediateFlush(boolean immediateFlush){
289295
this.immediateFlush = immediateFlush;
290296
return this;
291297
}
298+
299+
/**
300+
* Gets html meta info. This meta info will be passed with to {@link com.itextpdf.kernel.counter.EventCounter}
301+
* with {@link com.itextpdf.html2pdf.events.PdfHtmlEvent} and can be used to determine event origin.
302+
*
303+
* @return converter's {@link IMetaInfo}
304+
*/
305+
public IMetaInfo getEventCountingMetaInfo() {
306+
return metaInfo;
307+
}
308+
309+
/**
310+
* Sets html meta info. This meta info will be passed with to {@link com.itextpdf.kernel.counter.EventCounter}
311+
* with {@link com.itextpdf.html2pdf.events.PdfHtmlEvent} and can be used to determine event origin.
312+
*
313+
* @param metaInfo meta info to set
314+
* @return this {@link ConverterProperties} instance
315+
*/
316+
public ConverterProperties setEventCountingMetaInfo(IMetaInfo metaInfo) {
317+
this.metaInfo = metaInfo;
318+
return this;
319+
}
292320
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
55
66
This program is free software; you can redistribute it and/or modify

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
55
66
This program is free software; you can redistribute it and/or modify
@@ -45,10 +45,9 @@ This file is part of the iText (R) project.
4545

4646
import com.itextpdf.html2pdf.attach.Attacher;
4747
import com.itextpdf.html2pdf.exception.Html2PdfException;
48-
import com.itextpdf.html2pdf.html.IHtmlParser;
49-
import com.itextpdf.html2pdf.html.impl.jsoup.JsoupHtmlParser;
50-
import com.itextpdf.html2pdf.html.node.IDocumentNode;
5148
import com.itextpdf.io.util.FileUtil;
49+
import com.itextpdf.kernel.counter.event.IMetaInfo;
50+
import com.itextpdf.kernel.pdf.DocumentProperties;
5251
import com.itextpdf.kernel.pdf.PdfDocument;
5352
import com.itextpdf.kernel.pdf.PdfWriter;
5453
import com.itextpdf.layout.Document;
@@ -57,6 +56,9 @@ This file is part of the iText (R) project.
5756
import java.lang.reflect.Constructor;
5857
import java.lang.reflect.Method;
5958
import com.itextpdf.kernel.Version;
59+
import com.itextpdf.styledxmlparser.IXmlParser;
60+
import com.itextpdf.styledxmlparser.node.IDocumentNode;
61+
import com.itextpdf.styledxmlparser.node.impl.jsoup.JsoupHtmlParser;
6062

6163
import java.io.File;
6264
import java.io.FileInputStream;
@@ -132,7 +134,7 @@ public static void convertToPdf(String html, PdfWriter pdfWriter) throws IOExcep
132134
* @throws IOException Signals that an I/O exception has occurred.
133135
*/
134136
public static void convertToPdf(String html, PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException {
135-
convertToPdf(html, new PdfDocument(pdfWriter), converterProperties);
137+
convertToPdf(html, new PdfDocument(pdfWriter, new DocumentProperties().setEventCountingMetaInfo(new HtmlMetaInfo())), converterProperties);
136138
}
137139

138140
/**
@@ -227,7 +229,7 @@ public static void convertToPdf(InputStream htmlStream, PdfDocument pdfDocument)
227229
* @throws IOException Signals that an I/O exception has occurred.
228230
*/
229231
public static void convertToPdf(InputStream htmlStream, PdfWriter pdfWriter) throws IOException {
230-
convertToPdf(htmlStream, new PdfDocument(pdfWriter));
232+
convertToPdf(htmlStream, new PdfDocument(pdfWriter, new DocumentProperties().setEventCountingMetaInfo(new HtmlMetaInfo())));
231233
}
232234

233235
/**
@@ -241,7 +243,7 @@ public static void convertToPdf(InputStream htmlStream, PdfWriter pdfWriter) thr
241243
* @throws IOException Signals that an I/O exception has occurred.
242244
*/
243245
public static void convertToPdf(InputStream htmlStream, PdfWriter pdfWriter, ConverterProperties converterProperties) throws IOException {
244-
convertToPdf(htmlStream, new PdfDocument(pdfWriter), converterProperties);
246+
convertToPdf(htmlStream, new PdfDocument(pdfWriter, new DocumentProperties().setEventCountingMetaInfo(new HtmlMetaInfo())), converterProperties);
245247
}
246248

247249
/**
@@ -365,7 +367,7 @@ public static Document convertToDocument(String html, PdfDocument pdfDocument, C
365367
if (pdfDocument.getReader() != null) {
366368
throw new Html2PdfException(Html2PdfException.PdfDocumentShouldBeInWritingMode);
367369
}
368-
IHtmlParser parser = new JsoupHtmlParser();
370+
IXmlParser parser = new JsoupHtmlParser();
369371
IDocumentNode doc = parser.parse(html);
370372
return Attacher.attach(doc, pdfDocument, converterProperties);
371373
}
@@ -421,7 +423,7 @@ public static Document convertToDocument(InputStream htmlStream, PdfDocument pdf
421423
if (pdfDocument.getReader() != null) {
422424
throw new Html2PdfException(Html2PdfException.PdfDocumentShouldBeInWritingMode);
423425
}
424-
IHtmlParser parser = new JsoupHtmlParser();
426+
IXmlParser parser = new JsoupHtmlParser();
425427
IDocumentNode doc = parser.parse(htmlStream, converterProperties != null ? converterProperties.getCharset() : null);
426428
return Attacher.attach(doc, pdfDocument, converterProperties);
427429
}
@@ -497,7 +499,7 @@ public static List<IElement> convertToElements(String html, ConverterProperties
497499
}
498500
}
499501

500-
IHtmlParser parser = new JsoupHtmlParser();
502+
IXmlParser parser = new JsoupHtmlParser();
501503
IDocumentNode doc = parser.parse(html);
502504
return Attacher.attach(doc, converterProperties);
503505
}
@@ -549,8 +551,13 @@ public static List<IElement> convertToElements(InputStream htmlStream, Converter
549551
}
550552
}
551553

552-
IHtmlParser parser = new JsoupHtmlParser();
554+
IXmlParser parser = new JsoupHtmlParser();
553555
IDocumentNode doc = parser.parse(htmlStream, converterProperties != null ? converterProperties.getCharset() : null);
554556
return Attacher.attach(doc, converterProperties);
555557
}
558+
559+
private static class HtmlMetaInfo implements IMetaInfo {
560+
561+
private static final long serialVersionUID = -295587336698550627L;
562+
}
556563
}

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
55
66
This program is free software; you can redistribute it and/or modify
@@ -96,8 +96,6 @@ public final class LogMessageConstant {
9696
public static final String PAGE_SIZE_VALUE_IS_INVALID = "Page size value {0} is invalid.";
9797
/** The Constant QUOTES_PROPERTY_INVALID. */
9898
public static final String QUOTES_PROPERTY_INVALID = "Quote property \"{0}\" is invalid. It should contain even number of <string> values.";
99-
/** The Constant QUOTE_IS_NOT_CLOSED_IN_CSS_EXPRESSION. */
100-
public static final String QUOTE_IS_NOT_CLOSED_IN_CSS_EXPRESSION = "The quote is not closed in css expression: {0}";
10199
/** The Constant RULE_IS_NOT_SUPPORTED. */
102100
public static final String RULE_IS_NOT_SUPPORTED = "The rule @{0} is unsupported. All selectors in this rule will be ignored.";
103101
/** The Constant TEXT_DECORATION_BLINK_NOT_SUPPORTED. */
@@ -106,32 +104,26 @@ public final class LogMessageConstant {
106104
public static final String TEXT_WAS_NOT_PROCESSED = "Text was not processed: {0}";
107105
/** The Constant UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE. */
108106
public static final String UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE = "Unable to process external css file";
107+
/** The Constant UNABLE_TO_PROCESS_IMAGE_AS_SVG*/
108+
public static final String UNABLE_TO_PROCESS_IMAGE_AS_SVG="Unable to process image found at {0} as an SVG";
109109
/** The Constant UNABLE_TO_RESOLVE_COUNTER. */
110110
public static final String UNABLE_TO_RESOLVE_COUNTER = "Unable to resolve counter \"{0}\"";
111111
/** The Constant UNABLE_TO_RESOLVE_FONT. */
112112
public static final String UNABLE_TO_RESOLVE_FONT = "Unable to resolve font: {0}. The default one will be used instead";
113113
/** The Constant UNABLE_TO_RETRIEVE_FONT. */
114114
public static final String UNABLE_TO_RETRIEVE_FONT = "Unable to retrieve font:\n {0}";
115-
/** The Constant UNABLE_TO_RETRIEVE_IMAGE_FROM_BASE64_SOURCE. */
116-
public static final String UNABLE_TO_RETRIEVE_IMAGE_FROM_BASE64_SOURCE = "Unable to retrieve image from given base64 source string";
117115
/** The Constant UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI. */
118116
public static final String UNABLE_TO_RETRIEVE_IMAGE_WITH_GIVEN_BASE_URI = "Unable to retrieve image with given base URI ({0}) and image source path ({1})";
119117
/** The Constant UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI. */
120118
public static final String UNABLE_TO_RETRIEVE_STREAM_WITH_GIVEN_BASE_URI = "Unable to retrieve stream with given base URI ({0}) and source path ({1})";
121-
/** The Constant UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED. */
122-
public static final String UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED = "Unknown absolute metric length parsed \"{0}\".";
123119
/** The Constant UNKNOWN_MARGIN_BOX_CHILD. */
124120
public static final String UNKNOWN_MARGIN_BOX_CHILD = "Unknown margin box child";
125-
public static final String UNSUPPORTED_PSEUDO_CSS_SELECTOR = "Unsupported pseudo css selector: {0}";
126-
public static final String URL_IS_EMPTY_IN_CSS_EXPRESSION = "url function is empty in expression:{0}";
127-
public static final String URL_IS_NOT_CLOSED_IN_CSS_EXPRESSION = "url function is not properly closed in expression:{0}";
128-
/** The Constant WAS_NOT_ABLE_TO_DEFINE_BACKGROUND_CSS_SHORTHAND_PROPERTIES. */
129-
public static final String WAS_NOT_ABLE_TO_DEFINE_BACKGROUND_CSS_SHORTHAND_PROPERTIES = "Was not able to define one of the background CSS shorthand properties: {0}";
130121
/** The Constant WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT. */
131122
public static final String WORKER_UNABLE_TO_PROCESS_IT_S_TEXT_CONTENT = "Worker of type {0} unable to process it's text content";
132123
/** The Constant WORKER_UNABLE_TO_PROCESS_OTHER_WORKER. */
133124
public static final String WORKER_UNABLE_TO_PROCESS_OTHER_WORKER = "Worker of type {0} unable to process {1}";
134-
125+
/** The Constant PDF_DOCUMENT_NOT_PRESENT */
126+
public static final String PDF_DOCUMENT_NOT_PRESENT = "PdfDocument is not present";
135127
/**
136128
* Instantiates a new log message constant.
137129
*/

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

Lines changed: 0 additions & 69 deletions
This file was deleted.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
55
66
This program is free software; you can redistribute it and/or modify
@@ -44,10 +44,10 @@ This file is part of the iText (R) project.
4444

4545
import com.itextpdf.html2pdf.ConverterProperties;
4646
import com.itextpdf.html2pdf.attach.impl.DefaultHtmlProcessor;
47-
import com.itextpdf.html2pdf.html.node.IDocumentNode;
4847
import com.itextpdf.kernel.pdf.PdfDocument;
4948
import com.itextpdf.layout.Document;
5049
import com.itextpdf.layout.element.IElement;
50+
import com.itextpdf.styledxmlparser.node.IDocumentNode;
5151

5252
import java.util.List;
5353

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
This file is part of the iText (R) project.
3-
Copyright (c) 1998-2017 iText Group NV
3+
Copyright (c) 1998-2018 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
55
66
This program is free software; you can redistribute it and/or modify
@@ -42,10 +42,10 @@ This file is part of the iText (R) project.
4242
*/
4343
package com.itextpdf.html2pdf.attach;
4444

45-
import com.itextpdf.html2pdf.html.node.INode;
4645
import com.itextpdf.kernel.pdf.PdfDocument;
4746
import com.itextpdf.layout.Document;
4847
import com.itextpdf.layout.element.IElement;
48+
import com.itextpdf.styledxmlparser.node.INode;
4949

5050
import java.util.List;
5151

0 commit comments

Comments
 (0)