Skip to content

Commit e1b5509

Browse files
committed
Merge branch '7.1' into develop
# Conflicts: # pom.xml # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest08.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest09.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest10.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest11.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest12.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest13.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest14.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest15.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest16.pdf # src/test/resources/com/itextpdf/html2pdf/css/HeightTest/cmp_heightTest17.pdf # src/test/resources/com/itextpdf/html2pdf/element/TtTest/cmp_TtTest01.pdf
2 parents f942189 + 3589c7c commit e1b5509

File tree

1,260 files changed

+4979
-1951
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,260 files changed

+4979
-1951
lines changed

pom.xml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<parent>
66
<groupId>com.itextpdf</groupId>
77
<artifactId>root</artifactId>
8-
<version>7.0.6-SNAPSHOT</version>
8+
<version>7.1.0-SNAPSHOT</version>
99
<relativePath/>
1010
</parent>
1111

1212
<artifactId>html2pdf</artifactId>
13-
<version>1.0.3-SNAPSHOT</version>
13+
<version>1.1.0-SNAPSHOT</version>
1414

1515
<name>pdfHTML</name>
1616
<description>pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
@@ -214,6 +214,60 @@
214214
</execution>
215215
</executions>
216216
</plugin>
217+
<plugin>
218+
<groupId>org.apache.felix</groupId>
219+
<artifactId>maven-bundle-plugin</artifactId>
220+
<version>3.2.0</version>
221+
<extensions>true</extensions>
222+
<executions>
223+
<execution>
224+
<id>bundle-manifest</id>
225+
<phase>process-classes</phase>
226+
<goals>
227+
<goal>manifest</goal>
228+
</goals>
229+
</execution>
230+
</executions>
231+
<configuration>
232+
<unpackBundle>true</unpackBundle>
233+
</configuration>
234+
</plugin>
235+
<plugin>
236+
<groupId>com.github.ekryd.sortpom</groupId>
237+
<artifactId>sortpom-maven-plugin</artifactId>
238+
<version>2.4.0</version>
239+
<executions>
240+
<execution>
241+
<phase>verify</phase>
242+
<goals>
243+
<goal>sort</goal>
244+
</goals>
245+
</execution>
246+
</executions>
247+
<configuration>
248+
<lineSeparator>\n</lineSeparator>
249+
<encoding>${project.build.sourceEncoding}</encoding>
250+
<sortProperties>true</sortProperties>
251+
<keepBlankLines>true</keepBlankLines>
252+
<expandEmptyElements>false</expandEmptyElements>
253+
<nrOfIndentSpace>2</nrOfIndentSpace>
254+
<sortDependencies>scope</sortDependencies>
255+
<skip>${skipSortPom}</skip>
256+
</configuration>
257+
</plugin>
258+
<plugin>
259+
<groupId>org.codehaus.mojo</groupId>
260+
<artifactId>tidy-maven-plugin</artifactId>
261+
<version>1.0.0</version>
262+
<executions>
263+
<execution>
264+
<phase>verify</phase>
265+
<goals>
266+
<goal>pom</goal>
267+
</goals>
268+
</execution>
269+
</executions>
270+
</plugin>
217271
</plugins>
218272
</build>
219273
</project>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ public final class LogMessageConstant {
151151
/** The Constant UNKNOWN_MARGIN_BOX_CHILD. */
152152
public static final String UNKNOWN_MARGIN_BOX_CHILD = "Unknown margin box child";
153153

154+
public static final String UNSUPPORTED_PSEUDO_CSS_SELECTOR = "Unsupported pseudo css selector: {0}";
155+
154156
public static final String URL_IS_NOT_CLOSED_IN_CSS_EXPRESSION = "url function is not properly closed in expression:{0}";
155157

156158
public static final String URL_IS_EMPTY_IN_CSS_EXPRESSION = "url function is empty in expression:{0}";

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
This file is part of the iText (R) project.
33
Copyright (c) 1998-2017 iText Group NV
44
Authors: Bruno Lowagie, Paulo Soares, et al.
5-
5+
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU Affero General Public License version 3
88
as published by the Free Software Foundation with the addition of the
99
following permission added to Section 15 as permitted in Section 7(a):
1010
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
1111
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
1212
OF THIRD PARTY RIGHTS
13-
13+
1414
This program is distributed in the hope that it will be useful, but
1515
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1616
or FITNESS FOR A PARTICULAR PURPOSE.
@@ -20,23 +20,23 @@ This file is part of the iText (R) project.
2020
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2121
Boston, MA, 02110-1301 USA, or download the license from the following URL:
2222
http://itextpdf.com/terms-of-use/
23-
23+
2424
The interactive user interfaces in modified source and object code versions
2525
of this program must display Appropriate Legal Notices, as required under
2626
Section 5 of the GNU Affero General Public License.
27-
27+
2828
In accordance with Section 7(b) of the GNU Affero General Public License,
2929
a covered work must retain the producer line in every PDF that is created
3030
or manipulated using iText.
31-
31+
3232
You can be released from the requirements of the license by purchasing
3333
a commercial license. Buying such a license is mandatory as soon as you
3434
develop commercial activities involving the iText software without
3535
disclosing the source code of your own applications.
3636
These activities include: offering paid services to customers as an ASP,
3737
serving PDFs on the fly in a web application, shipping iText with a closed
3838
source product.
39-
39+
4040
For more information, please contact iText Software Corp. at this
4141
address: sales@itextpdf.com
4242
*/
@@ -61,13 +61,13 @@ This file is part of the iText (R) project.
6161
import com.itextpdf.html2pdf.html.node.ITextNode;
6262
import com.itextpdf.kernel.geom.PageSize;
6363
import com.itextpdf.kernel.geom.Rectangle;
64-
import com.itextpdf.kernel.pdf.PdfName;
6564
import com.itextpdf.kernel.pdf.PdfPage;
6665
import com.itextpdf.kernel.pdf.canvas.CanvasArtifact;
6766
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
67+
import com.itextpdf.kernel.pdf.tagging.StandardRoles;
6868
import com.itextpdf.layout.Canvas;
6969
import com.itextpdf.layout.IPropertyContainer;
70-
import com.itextpdf.layout.border.Border;
70+
import com.itextpdf.layout.borders.Border;
7171
import com.itextpdf.layout.element.Div;
7272
import com.itextpdf.layout.element.IBlockElement;
7373
import com.itextpdf.layout.element.IElement;
@@ -80,8 +80,8 @@ This file is part of the iText (R) project.
8080
import com.itextpdf.layout.renderer.DocumentRenderer;
8181
import com.itextpdf.layout.renderer.DrawContext;
8282
import com.itextpdf.layout.renderer.IRenderer;
83-
import org.jsoup.nodes.Element;
84-
import org.jsoup.parser.Tag;
83+
import com.itextpdf.html2pdf.jsoup.nodes.Element;
84+
import com.itextpdf.html2pdf.jsoup.parser.Tag;
8585
import org.slf4j.LoggerFactory;
8686

8787
import java.util.Arrays;
@@ -517,7 +517,7 @@ private void createMarginBoxesElements(List<PageMarginBoxContextNode> resolvedPa
517517
}
518518
}
519519
}
520-
marginBox.setRole(PdfName.Artifact);
520+
marginBox.getAccessibilityProperties().setRole(StandardRoles.ARTIFACT);
521521
}
522522
}
523523

@@ -534,7 +534,7 @@ private Rectangle[] calculateMarginBoxRectangles(List<PageMarginBoxContextNode>
534534
float rightMargin = margins[1];
535535
float bottomMargin = margins[2];
536536
float leftMargin = margins[3];
537-
Rectangle withoutMargins = pageSize.clone().<Rectangle>applyMargins(topMargin, rightMargin, bottomMargin, leftMargin, false);
537+
Rectangle withoutMargins = pageSize.clone().applyMargins(topMargin, rightMargin, bottomMargin, leftMargin, false);
538538
float topBottomMarginWidth = withoutMargins.getWidth() / 3;
539539
float leftRightMarginHeight = withoutMargins.getHeight() / 3;
540540
Rectangle[] hardcodedBoxRectangles = new Rectangle[] {
@@ -572,7 +572,7 @@ private Rectangle calculateContainingBlockSizesForMarginBox(int marginBoxInd) {
572572
if (marginBoxInd == 0 || marginBoxInd == 4 || marginBoxInd == 8 || marginBoxInd == 12) {
573573
return marginBoxRectangles[marginBoxInd];
574574
}
575-
Rectangle withoutMargins = pageSize.clone().<Rectangle>applyMargins(margins[0], margins[1], margins[2], margins[3], false);
575+
Rectangle withoutMargins = pageSize.clone().applyMargins(margins[0], margins[1], margins[2], margins[3], false);
576576
if (marginBoxInd < 4) {
577577
return new Rectangle(withoutMargins.getWidth(), margins[0]);
578578
} else if (marginBoxInd < 8) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class PageSizeParser {
8484
* @return the page size
8585
*/
8686
static PageSize fetchPageSize(String pageSizeStr, float em, float rem, PageSize defaultPageSize) {
87-
PageSize pageSize = defaultPageSize.clone();
87+
PageSize pageSize = (PageSize) defaultPageSize.clone();
8888
if (pageSizeStr == null || CssConstants.AUTO.equals(pageSizeStr)) {
8989
return pageSize;
9090
}

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/AbstractFormFieldRenderer.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ This file is part of the iText (R) project.
5151
import com.itextpdf.layout.layout.LayoutResult;
5252
import com.itextpdf.layout.layout.MinMaxWidthLayoutResult;
5353
import com.itextpdf.layout.minmaxwidth.MinMaxWidth;
54+
import com.itextpdf.layout.minmaxwidth.MinMaxWidthUtils;
5455
import com.itextpdf.layout.property.FloatPropertyValue;
5556
import com.itextpdf.layout.property.Property;
5657
import com.itextpdf.layout.property.UnitValue;
@@ -134,9 +135,9 @@ public void drawChildren(DrawContext drawContext) {
134135
* @see com.itextpdf.layout.renderer.BlockRenderer#getMinMaxWidth(float)
135136
*/
136137
@Override
137-
protected MinMaxWidth getMinMaxWidth(float availableWidth) {
138-
MinMaxWidthLayoutResult result = (MinMaxWidthLayoutResult) layout(new LayoutContext(new LayoutArea(1, new Rectangle(availableWidth, AbstractRenderer.INF))), true);
139-
return result.getNotNullMinMaxWidth(availableWidth);
138+
protected MinMaxWidth getMinMaxWidth() {
139+
MinMaxWidthLayoutResult result = (MinMaxWidthLayoutResult) layout(new LayoutContext(new LayoutArea(1, new Rectangle(MinMaxWidthUtils.getInfWidth(), AbstractRenderer.INF))), true);
140+
return result.getMinMaxWidth();
140141
}
141142

142143
/**
@@ -251,7 +252,7 @@ private LayoutResult layout(LayoutContext layoutContext, boolean minMaxWidth) {
251252
occupiedArea.setBBox(flatRenderer.getOccupiedArea().getBBox().clone());
252253
}
253254

254-
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth(0, parentWidth));
255+
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth());
255256
}
256257
if (!childRenderers.isEmpty()) {
257258
flatRenderer = childRenderers.get(0);
@@ -271,15 +272,15 @@ private LayoutResult layout(LayoutContext layoutContext, boolean minMaxWidth) {
271272
if (!minMaxWidth) {
272273
setProperty(Property.FORCED_PLACEMENT, true);
273274
occupiedArea.getBBox().setWidth(0).setHeight(0);
274-
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth(0, parentWidth));
275+
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth());
275276
} else {
276-
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth(occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getWidth()));
277+
return new MinMaxWidthLayoutResult(LayoutResult.NOTHING, occupiedArea, null, this, this).setMinMaxWidth(new MinMaxWidth(occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getWidth(), 0));
277278
}
278279
}
279280
if (result.getStatus() != LayoutResult.FULL || !isRendererFit(parentWidth, parentHeight)) {
280281
LoggerFactory.getLogger(getClass()).warn(LogMessageConstant.INPUT_FIELD_DOES_NOT_FIT);
281282
}
282283
return new MinMaxWidthLayoutResult(LayoutResult.FULL, occupiedArea, this, null)
283-
.setMinMaxWidth(new MinMaxWidth(0, parentWidth, occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getWidth()));
284+
.setMinMaxWidth(new MinMaxWidth(occupiedArea.getBBox().getWidth(), occupiedArea.getBBox().getWidth(), 0));
284285
}
285286
}

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/ButtonRenderer.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ This file is part of the iText (R) project.
5454
import com.itextpdf.kernel.pdf.PdfPage;
5555
import com.itextpdf.layout.property.Background;
5656
import com.itextpdf.layout.property.Property;
57+
import com.itextpdf.layout.property.UnitValue;
5758
import com.itextpdf.layout.renderer.DrawContext;
5859
import com.itextpdf.layout.renderer.IRenderer;
5960
import com.itextpdf.layout.renderer.LineRenderer;
61+
import com.itextpdf.layout.renderer.ListItemRenderer;
6062
import com.itextpdf.layout.renderer.ParagraphRenderer;
63+
import org.slf4j.Logger;
6164
import org.slf4j.LoggerFactory;
6265

6366
import java.util.List;
@@ -129,12 +132,16 @@ protected IRenderer createFlatRenderer() {
129132
protected void applyAcroField(DrawContext drawContext) {
130133
String value = getDefaultValue();
131134
String name = getModelId();
132-
float fontSize = (float) this.getPropertyAsFloat(Property.FONT_SIZE);
135+
UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE);
136+
if (!fontSize.isPointValue()) {
137+
Logger logger = LoggerFactory.getLogger(ButtonRenderer.class);
138+
logger.error(MessageFormatUtil.format(com.itextpdf.io.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.FONT_SIZE));
139+
}
133140
PdfDocument doc = drawContext.getDocument();
134141
Rectangle area = flatRenderer.getOccupiedArea().getBBox().clone();
135142
applyPaddings(area, true);
136143
PdfPage page = doc.getPage(occupiedArea.getPageNumber());
137-
PdfButtonFormField button = PdfFormField.createPushButton(doc, area, name, value, font, fontSize);
144+
PdfButtonFormField button = PdfFormField.createPushButton(doc, area, name, value, font, fontSize.getValue());
138145
Background background = this.<Background>getProperty(Property.BACKGROUND);
139146
if (background != null && background.getColor() != null) {
140147
button.setBackgroundColor(background.getColor());

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/InputFieldRenderer.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,13 @@ This file is part of the iText (R) project.
5353
import com.itextpdf.kernel.pdf.PdfPage;
5454
import com.itextpdf.kernel.pdf.PdfString;
5555
import com.itextpdf.layout.property.Property;
56+
import com.itextpdf.layout.property.UnitValue;
5657
import com.itextpdf.layout.renderer.DrawContext;
5758
import com.itextpdf.layout.renderer.IRenderer;
5859
import com.itextpdf.layout.renderer.LineRenderer;
60+
import com.itextpdf.layout.renderer.ListItemRenderer;
5961
import com.itextpdf.layout.renderer.ParagraphRenderer;
62+
import org.slf4j.Logger;
6063
import org.slf4j.LoggerFactory;
6164

6265
import java.util.List;
@@ -144,15 +147,19 @@ protected void applyAcroField(DrawContext drawContext) {
144147
font.setSubset(false);
145148
String value = getDefaultValue();
146149
String name = getModelId();
147-
float fontSize = (float) this.getPropertyAsFloat(Property.FONT_SIZE);
150+
UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE);
151+
if (!fontSize.isPointValue()) {
152+
Logger logger = LoggerFactory.getLogger(InputFieldRenderer.class);
153+
logger.error(MessageFormatUtil.format(com.itextpdf.io.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.FONT_SIZE));
154+
}
148155
PdfDocument doc = drawContext.getDocument();
149156
Rectangle area = flatRenderer.getOccupiedArea().getBBox().clone();
150157
PdfPage page = doc.getPage(occupiedArea.getPageNumber());
151158
boolean password = isPassword();
152159
if (password) {
153160
value = "";
154161
}
155-
PdfFormField inputField = PdfFormField.createText(doc, area, name, value, font, fontSize);
162+
PdfFormField inputField = PdfFormField.createText(doc, area, name, value, font, fontSize.getValue());
156163
if (password) {
157164
inputField.setFieldFlag(PdfFormField.FF_PASSWORD, true);
158165
} else {
@@ -169,9 +176,13 @@ protected void applyAcroField(DrawContext drawContext) {
169176
protected Float getContentWidth() {
170177
Float width = super.getContentWidth();
171178
if (width == null) {
172-
float fontSize = (float) this.getPropertyAsFloat(Property.FONT_SIZE);
179+
UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE);
180+
if (!fontSize.isPointValue()) {
181+
Logger logger = LoggerFactory.getLogger(InputFieldRenderer.class);
182+
logger.error(MessageFormatUtil.format(com.itextpdf.io.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.FONT_SIZE));
183+
}
173184
int size = getSize();
174-
return fontSize * (size * 0.5f + 2) + 2;
185+
return fontSize.getValue() * (size * 0.5f + 2) + 2;
175186
}
176187
return width;
177188
}

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/TextAreaRenderer.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ This file is part of the iText (R) project.
5353
import com.itextpdf.kernel.pdf.PdfPage;
5454
import com.itextpdf.kernel.pdf.PdfString;
5555
import com.itextpdf.layout.property.Property;
56+
import com.itextpdf.layout.property.UnitValue;
5657
import com.itextpdf.layout.renderer.DrawContext;
5758
import com.itextpdf.layout.renderer.IRenderer;
5859
import com.itextpdf.layout.renderer.LineRenderer;
5960
import com.itextpdf.layout.renderer.ParagraphRenderer;
61+
import org.slf4j.Logger;
6062
import org.slf4j.LoggerFactory;
6163

6264
import java.util.List;
@@ -160,11 +162,15 @@ protected void applyAcroField(DrawContext drawContext) {
160162
font.setSubset(false);
161163
String value = getDefaultValue();
162164
String name = getModelId();
163-
float fontSize = (float) this.getPropertyAsFloat(Property.FONT_SIZE);
165+
UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE);
166+
if (!fontSize.isPointValue()) {
167+
Logger logger = LoggerFactory.getLogger(TextAreaRenderer.class);
168+
logger.error(MessageFormatUtil.format(com.itextpdf.io.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.FONT_SIZE));
169+
}
164170
PdfDocument doc = drawContext.getDocument();
165171
Rectangle area = flatRenderer.getOccupiedArea().getBBox().clone();
166172
PdfPage page = doc.getPage(occupiedArea.getPageNumber());
167-
PdfFormField inputField = PdfFormField.createText(doc, area, name, value, font, fontSize);
173+
PdfFormField inputField = PdfFormField.createText(doc, area, name, value, font, fontSize.getValue());
168174
inputField.setFieldFlag(PdfFormField.FF_MULTILINE, true);
169175
inputField.setDefaultValue(new PdfString(getDefaultValue()));
170176
applyDefaultFieldProperties(inputField);
@@ -178,9 +184,13 @@ protected void applyAcroField(DrawContext drawContext) {
178184
protected Float getContentWidth() {
179185
Float width = super.getContentWidth();
180186
if (width == null) {
181-
float fontSize = (float) this.getPropertyAsFloat(Property.FONT_SIZE);
187+
UnitValue fontSize = (UnitValue) this.getPropertyAsUnitValue(Property.FONT_SIZE);
188+
if (!fontSize.isPointValue()) {
189+
Logger logger = LoggerFactory.getLogger(TextAreaRenderer.class);
190+
logger.error(MessageFormatUtil.format(com.itextpdf.io.LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.FONT_SIZE));
191+
}
182192
int cols = getCols();
183-
return fontSize * (cols * 0.5f + 2) + 2;
193+
return fontSize.getValue() * (cols * 0.5f + 2) + 2;
184194
}
185195
return width;
186196
}

0 commit comments

Comments
 (0)