Skip to content

Commit bcd7d39

Browse files
committed
[RELEASE] iText 7 pdfHTML - 2.1.3
https://github.com/itext/i7j-pdfhtml/releases/tag/2.1.3 * release/2.1.3: [RELEASE] 2.1.3-SNAPSHOT -> 2.1.3 Update cmp-files for closepath linejoin Do not reset the alignment for RTL elements if it's present. Fix anchor links handling with destinations on elements handled by SpanTagWorker Set correct scm links Set correct packages group for javadoc plugin Remove pom entries that are duplicated from the parent pom Update cmps related to bold style detection. Default input tags with invalid types. Improve processing of block elements / images inside of a paragraph. Add some new tests for the table's fixed-layout algorithm in case of a negative width remained. Improve contribution guidelines Restore page counter renderer's text after it has been layouted. Update cmp file for rgba opacity test Remove unused imports and add @category for tests Use whitespace-related utility methods from SXP to avoid duplication Fix javadoc errors Upgrade Surefire and Failsafe Change tests to avoid external resources dependencies Handle inline blocks with display: block style Update cmp-s [RELEASE] 2.1.2-SNAPSHOT -> 2.1.3-SNAPSHOT Do not create a new FontProvider instance on ProcessorContext#reset. Reset the existed one instead.
2 parents 0b5f10c + d7af7c4 commit bcd7d39

File tree

129 files changed

+1000
-305
lines changed

Some content is hidden

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

129 files changed

+1000
-305
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -70,83 +70,29 @@ Before you submit your pull request consider the following guidelines:
7070
* Please sign the [iText Contributor License Agreement (iCLA)](#cla) before sending pull
7171
requests for any change of more than 20 significant lines of code (we're not counting curly braces and other syntactical sugar).
7272
We cannot accept code without this agreement.
73-
* Clone **iText 7 Community** to your local machine.
74-
75-
```shell
76-
git clone git@github.com:itext/itext7.git
77-
cd itext7
78-
git fetch origin
79-
git checkout -b develop origin/develop
80-
```
81-
82-
* Make your changes in a new git branch based off the develop branch:
83-
84-
```shell
85-
git checkout -b my-fix-branch develop
86-
```
87-
88-
* Create your patch, **including appropriate test cases**.
73+
* Fork the iText repository on GitHub.
74+
* Clone your iText fork to your local machine.
75+
* Make your changes, **including appropriate test cases**.
8976
* Follow our [Coding Rules](#rules).
90-
* Run the full **iText 7 Community** test suite and ensure that all tests pass.
9177
* Commit your changes using a descriptive commit message that follows our
9278
[commit message conventions](#commit-message-format).
93-
94-
```shell
95-
git commit -a
96-
```
97-
Note: the optional commit `-a` command line option will automatically `add` and `rm` edited files.
98-
9979
* Now would be a good time to fix up your commits (if you want or need to) with `git rebase --interactive`.
10080
* Build your changes locally to ensure all the tests pass.
101-
* Push your branch to your GitHub account:
102-
103-
```shell
104-
git remote add my-remote git@github.com:my-remote/itext7.git
105-
git push my-remote my-fix-branch
106-
```
107-
108-
* In GitHub, send a pull request to `itext7:develop`.
81+
* Push your changes to your GitHub account.
82+
* Create a pull request in GitHub.
83+
"Head fork" should be your repository, and the "base fork" should be the iText7 official repository.
10984
* If we suggest changes then:
11085
* Make the required updates.
111-
* Re-run the **iText 7 Community** test suite to ensure tests are still passing.
112-
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
113-
114-
```shell
115-
git fetch origin
116-
git rebase develop -i
117-
git push my-remote my-fix-branch -f
118-
```
86+
* Fix up your commits if needed, with an interactive rebase.
87+
* Re-run the tests and make sure that they are still passing.
88+
* Force push to your GitHub repository. This will update your Pull Request.
11989

12090
That's it! Thank you for your contribution!
12191

12292
#### After your pull request is merged
12393

124-
After your pull request is merged, you can safely delete your branch and pull the changes
125-
from the main (upstream) repository:
126-
127-
* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
128-
129-
```shell
130-
git push my-remote --delete my-fix-branch
131-
```
132-
133-
* Check out the develop branch:
134-
135-
```shell
136-
git checkout develop -f
137-
```
138-
139-
* Delete the local branch:
140-
141-
```shell
142-
git branch -D my-fix-branch
143-
```
144-
145-
* Update your develop with the latest upstream version:
146-
147-
```shell
148-
git pull --ff upstream develop
149-
```
94+
After your pull request is merged, you can safely delete your fork and pull the changes
95+
from the main (upstream) repository.
15096

15197

15298
## <a name="rules">Coding Rules</a>

pom.xml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.1.5</version>
7+
<version>7.1.6</version>
88
<relativePath/>
99
</parent>
1010
<artifactId>html2pdf</artifactId>
11-
<version>2.1.2</version>
11+
<version>2.1.3</version>
1212
<name>pdfHTML</name>
1313
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
1414
them to PDF.</description>
15-
<url>http://itextpdf.com/</url>
15+
<scm>
16+
<connection>scm:git:ssh://git@git.itextsupport.com:7999/i7j/html2pdf.git</connection>
17+
<url>https://git.itextsupport.com/projects/I7J/repos/html2pdf</url>
18+
</scm>
1619
<properties>
1720
<itext.version>${project.parent.version}</itext.version>
18-
<javadoc.version>3.0.0</javadoc.version>
1921
</properties>
2022
<repositories>
2123
<repository>
@@ -95,7 +97,7 @@
9597
<plugin>
9698
<groupId>org.apache.maven.plugins</groupId>
9799
<artifactId>maven-failsafe-plugin</artifactId>
98-
<version>2.19.1</version>
100+
<version>${failsafe.version}</version>
99101
<configuration>
100102
<includes>
101103
<include>**/*Test.java</include>
@@ -107,37 +109,20 @@
107109
<groupId>org.apache.maven.plugins</groupId>
108110
<artifactId>maven-javadoc-plugin</artifactId>
109111
<version>${javadoc.version}</version>
110-
<executions>
111-
<execution>
112-
<id>attach-javadocs</id>
113-
<goals>
114-
<goal>jar</goal>
115-
</goals>
116-
</execution>
117-
</executions>
118112
<configuration>
119-
<quiet>true</quiet>
120-
<failOnError>true</failOnError>
113+
<subpackages>com.itextpdf.html2pdf</subpackages>
114+
<groups>
115+
<group>
116+
<title>pdfHTML</title>
117+
<packages>com.itextpdf.html2pdf*</packages>
118+
</group>
119+
</groups>
121120
</configuration>
122121
</plugin>
123-
<plugin>
124-
<groupId>org.apache.maven.plugins</groupId>
125-
<artifactId>maven-source-plugin</artifactId>
126-
<version>3.0.1</version>
127-
<executions>
128-
<execution>
129-
<id>attach-sources</id>
130-
<phase>verify</phase>
131-
<goals>
132-
<goal>jar-no-fork</goal>
133-
</goals>
134-
</execution>
135-
</executions>
136-
</plugin>
137122
<plugin>
138123
<groupId>org.apache.maven.plugins</groupId>
139124
<artifactId>maven-surefire-plugin</artifactId>
140-
<version>2.19.1</version>
125+
<version>${surefire.version}</version>
141126
<configuration>
142127
<groups>${unittests}</groups>
143128
</configuration>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ 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;
4948
import com.itextpdf.html2pdf.css.apply.ICssApplierFactory;
5049
import com.itextpdf.kernel.counter.event.IMetaInfo;
5150
import com.itextpdf.layout.font.FontProvider;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ This file is part of the iText (R) project.
6666
import java.io.IOException;
6767
import java.io.InputStream;
6868
import java.io.OutputStream;
69-
import java.nio.file.Paths;
7069
import java.util.List;
7170

7271
/**

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public final class LogMessageConstant {
4949

5050
/** The Constant ACROFORM_NOT_SUPPORTED_FOR_SELECT. */
5151
public static final String ACROFORM_NOT_SUPPORTED_FOR_SELECT = "AcroForm fields creation for select fields (ComboBoxField and ListBoxField) is not supported. They will be flattened instead.";
52+
public static final String ANCHOR_LINK_NOT_HANDLED = "The anchor link was not handled. Could not create a destination for element \"{0}\" with ID \"{1}\", which is processed by \"{2}\" tag worker class.";
5253
/** The Constant CONTENT_PROPERTY_INVALID. */
5354
public static final String CONTENT_PROPERTY_INVALID = "Content property \"{0}\" is either invalid or uses unsupported function.";
5455
/** The Constant CSS_PROPERTY_IN_PERCENTS_NOT_SUPPORTED. */
@@ -72,6 +73,8 @@ public final class LogMessageConstant {
7273
/** The Constant INPUT_SUPPORTS_ONLY_POINT_WIDTH. */
7374
@Deprecated
7475
public static final String INPUT_SUPPORTS_ONLY_POINT_WIDTH = "Input field supports only point width";
76+
/** The Constant INPUT_TYPE_IS_INVALID. */
77+
public static final String INPUT_TYPE_IS_INVALID = "Input type {0} is invalid. The default text type will be used instead.";
7578
/** The Constant INPUT_TYPE_IS_NOT_SUPPORTED. */
7679
public static final String INPUT_TYPE_IS_NOT_SUPPORTED = "Input type {0} is not supported";
7780
/** The Constant INVALID_CSS_PROPERTY_DECLARATION. */
@@ -109,7 +112,7 @@ public final class LogMessageConstant {
109112
public static final String TEXT_WAS_NOT_PROCESSED = "Text was not processed: {0}";
110113
/** The Constant UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE. */
111114
public static final String UNABLE_TO_PROCESS_EXTERNAL_CSS_FILE = "Unable to process external css file";
112-
/** The Constant UNABLE_TO_PROCESS_IMAGE_AS_SVG*/
115+
/** The Constant UNABLE_TO_PROCESS_IMAGE_AS_SVG */
113116
public static final String UNABLE_TO_PROCESS_IMAGE_AS_SVG = "Unable to process image found at {0} as an SVG";
114117
/** The Constant UNABLE_TO_RESOLVE_COUNTER. */
115118
public static final String UNABLE_TO_RESOLVE_COUNTER = "Unable to resolve counter \"{0}\"";

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ This file is part of the iText (R) project.
6161
import com.itextpdf.layout.font.FontSet;
6262
import com.itextpdf.layout.font.Range;
6363
import com.itextpdf.styledxmlparser.css.media.MediaDeviceDescription;
64-
import com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider;
6564
import com.itextpdf.styledxmlparser.resolver.resource.ResourceResolver;
6665

6766
/**
@@ -416,7 +415,7 @@ public void reset() {
416415
this.linkContext = new LinkContext();
417416
this.formFieldNameResolver.reset();
418417
//Reset font provider. PdfFonts shall be reseted.
419-
this.fontProvider = new BasicFontProvider(this.fontProvider.getFontSet(), this.fontProvider.getDefaultFontFamily());
418+
this.fontProvider.reset();
420419
this.tempFonts = null;
421420
this.outlineHandler.reset();
422421
this.processingInlineSvg = false;

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ This file is part of the iText (R) project.
4343
package com.itextpdf.html2pdf.attach.impl;
4444

4545
import com.itextpdf.html2pdf.html.AttributeConstants;
46+
import com.itextpdf.html2pdf.html.TagConstants;
4647
import com.itextpdf.styledxmlparser.node.IElementNode;
4748
import com.itextpdf.styledxmlparser.node.INode;
4849

@@ -91,9 +92,12 @@ public LinkContext scanForIds(INode root) {
9192
while (!stk.isEmpty()) {
9293
INode n = stk.pop();
9394
if (n instanceof IElementNode) {
94-
IElementNode n2 = (IElementNode) n;
95-
if (n2.name().equals(AttributeConstants.a) && n2.getAttribute(AttributeConstants.HREF) != null && n2.getAttribute(AttributeConstants.HREF).startsWith("#")) {
96-
linkDestinations.add(n2.getAttribute(AttributeConstants.HREF).substring(1));
95+
IElementNode elem = (IElementNode) n;
96+
if (TagConstants.A.equals(elem.name())) {
97+
String href = elem.getAttribute(AttributeConstants.HREF);
98+
if (href != null && href.startsWith("#")){
99+
linkDestinations.add(href.substring(1));
100+
}
97101
}
98102
}
99103
if (!n.childNodes().isEmpty()) {

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/BodyHtmlStylesContainer.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ This file is part of the iText (R) project.
6060
*/
6161
public class BodyHtmlStylesContainer implements IPropertyContainer {
6262

63-
/**
64-
* {@inheritDoc}
65-
*/
6663
protected Map<Integer, Object> properties = new HashMap<>();
6764

6865
/**

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/HeightDimensionContainer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ This file is part of the iText (R) project.
4747
import com.itextpdf.layout.layout.LayoutArea;
4848
import com.itextpdf.layout.layout.LayoutContext;
4949
import com.itextpdf.layout.layout.LayoutResult;
50-
import com.itextpdf.layout.minmaxwidth.MinMaxWidthUtils;
5150
import com.itextpdf.layout.renderer.IRenderer;
5251
import com.itextpdf.styledxmlparser.css.CssContextNode;
5352

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/PageCountRenderer.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,33 @@ class PageCountRenderer extends TextRenderer {
7474
@Override
7575
public LayoutResult layout(LayoutContext layoutContext) {
7676
PageCountType pageCountType = (PageCountType)this.<PageCountType>getProperty(Html2PdfProperty.PAGE_COUNT_TYPE);
77+
String previousText = getText().toString();
78+
// If typography is enabled and the page counter element has a non-default direction,
79+
// iText processes its content (see LineRenderer#updateBidiLevels) before layouting it.
80+
// This might result in an ArrayIndexOutOfBounds exception, because currently iText updates the page counter's content on layout.
81+
// To solve this, this workaround has been implemented: the renderer's strToBeConverted shouldn't be updated by layout.
82+
boolean textHasBeenReplaced = false;
7783
if (pageCountType == PageCountType.CURRENT_PAGE_NUMBER) {
7884
setText(String.valueOf(layoutContext.getArea().getPageNumber()));
85+
textHasBeenReplaced = true;
7986
} else if (pageCountType == PageCountType.TOTAL_PAGE_COUNT) {
8087
IRenderer rootRenderer = this;
8188
while (rootRenderer instanceof AbstractRenderer && ((AbstractRenderer) rootRenderer).getParent() != null) {
8289
rootRenderer = ((AbstractRenderer) rootRenderer).getParent();
8390
}
8491
if (rootRenderer instanceof HtmlDocumentRenderer && ((HtmlDocumentRenderer) rootRenderer).getEstimatedNumberOfPages() > 0) {
8592
setText(String.valueOf(((HtmlDocumentRenderer) rootRenderer).getEstimatedNumberOfPages()));
93+
textHasBeenReplaced = true;
8694
} else if (rootRenderer instanceof DocumentRenderer && rootRenderer.getModelElement() instanceof Document) {
8795
setText(String.valueOf(((Document) rootRenderer.getModelElement()).getPdfDocument().getNumberOfPages()));
96+
textHasBeenReplaced = true;
8897
}
8998
}
90-
return super.layout(layoutContext);
99+
LayoutResult result = super.layout(layoutContext);
100+
if (textHasBeenReplaced) {
101+
setText(previousText);
102+
}
103+
return result;
91104
}
92105

93106
/* (non-Javadoc)

0 commit comments

Comments
 (0)