Skip to content

Commit 60922bf

Browse files
Extract part of the margin box handling logic to tag worker and css applier
This allows customization of margin boxes processing. See new tests that show examples of how it is done. DEVSIX-1563
1 parent 0e54494 commit 60922bf

File tree

15 files changed

+568
-209
lines changed

15 files changed

+568
-209
lines changed

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,17 @@ public final class LogMessageConstant {
4949

5050
/** The Constant CONTENT_PROPERTY_INVALID. */
5151
public static final String CONTENT_PROPERTY_INVALID = "Content property \"{0}\" is either invalid or uses unsupported function.";
52-
5352
/** The Constant CSS_PROPERTY_IN_PERCENTS_NOT_SUPPORTED. */
5453
public static final String CSS_PROPERTY_IN_PERCENTS_NOT_SUPPORTED = "Css property {0} in percents is not supported";
55-
5654
public static final String DEFAULT_VALUE_OF_CSS_PROPERTY_UNKNOWN = "Default value of the css property \"{0}\" is unknown.";
57-
5855
/** The Constant ERROR_LOADING_FONT. */
5956
public static final String ERROR_LOADING_FONT = "Error while loading font";
60-
6157
/** The Constant ERROR_PARSING_CSS_SELECTOR. */
6258
public static final String ERROR_PARSING_CSS_SELECTOR = "Error while parsing css selector: {0}";
63-
6459
/** The Constant ERROR_RESOLVING_PARENT_STYLES. */
6560
public static final String ERROR_RESOLVING_PARENT_STYLES = "Element parent styles are not resolved. Styles for current element might be incorrect.";
66-
6761
/** The Constant ERROR_WHILE_LAYOUT_OF_FORM_FIELD. */
6862
public static final String ERROR_WHILE_LAYOUT_OF_FORM_FIELD = "Cannot layout form field field. It won't be displayed";
69-
7063
/** The Constant ERROR_WHILE_LAYOUT_OF_FORM_FIELD_WITH_TYPE. */
7164
public static final String ERROR_WHILE_LAYOUT_OF_FORM_FIELD_WITH_TYPE = "Error during layout of form filed with type {0}.";
7265
/** The Constant HEIGHT_VALUE_IN_PERCENT_NOT_SUPPORTED. */
@@ -77,13 +70,10 @@ public final class LogMessageConstant {
7770
public static final String INPUT_SUPPORTS_ONLY_POINT_WIDTH = "Input field supports only point width";
7871
/** The Constant INPUT_TYPE_IS_NOT_SUPPORTED. */
7972
public static final String INPUT_TYPE_IS_NOT_SUPPORTED = "Input type {0} is not supported";
80-
8173
/** The Constant INVALID_CSS_PROPERTY_DECLARATION. */
8274
public static final String INVALID_CSS_PROPERTY_DECLARATION = "Invalid css property declaration: {0}";
83-
8475
/** The Constant MARGIN_VALUE_IN_PERCENT_NOT_SUPPORTED. */
8576
public static final String MARGIN_VALUE_IN_PERCENT_NOT_SUPPORTED = "Margin value in percents not supported";
86-
8777
/** The Constant NOT_SUPPORTED_LIST_STYLE_TYPE. */
8878
public static final String NOT_SUPPORTED_LIST_STYLE_TYPE = "Not supported list style type: {0}";
8979
/** The Constant NO_CONSUMER_FOUND_FOR_CONTENT. */
@@ -94,10 +84,10 @@ public final class LogMessageConstant {
9484
public static final String NO_IPROPERTYCONTAINER_RESULT_FOR_THE_TAG = "Tag worker does not produce IPropertyContainer for \"{0}\" tag. An outline for \"{0}\" tag will not be created.";
9585
/** The Constant NO_WORKER_FOUND_FOR_TAG. */
9686
public static final String NO_WORKER_FOUND_FOR_TAG = "No worker found for tag {0}";
97-
9887
/** The Constant PADDING_VALUE_IN_PERCENT_NOT_SUPPORTED. */
9988
public static final String PADDING_VALUE_IN_PERCENT_NOT_SUPPORTED = "Padding value in percents not supported";
10089
public static final String PAGE_MARGIN_BOX_CONTENT_CANNOT_BE_DRAWN = "Page margin box {0} content cannot be drawn.";
90+
public static final String PAGE_MARGIN_BOX_SOME_PROPERTIES_NOT_PROCESSED = "Page margin box margin, padding, height and width properties are not processed. Passed styles container shall be of PageMarginBoxContextNode type.";
10191
/** The Constant PAGE_SIZE_VALUE_IS_INVALID. */
10292
public static final String PAGE_SIZE_VALUE_IS_INVALID = "Page size value {0} is invalid.";
10393
/** The Constant QUOTES_PROPERTY_INVALID. */

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

Lines changed: 9 additions & 6 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
*/
@@ -63,6 +63,7 @@ This file is part of the iText (R) project.
6363
import com.itextpdf.html2pdf.attach.impl.tags.MetaTagWorker;
6464
import com.itextpdf.html2pdf.attach.impl.tags.PTagWorker;
6565
import com.itextpdf.html2pdf.attach.impl.tags.PageCountWorker;
66+
import com.itextpdf.html2pdf.attach.impl.tags.PageMarginBoxWorker;
6667
import com.itextpdf.html2pdf.attach.impl.tags.PreTagWorker;
6768
import com.itextpdf.html2pdf.attach.impl.tags.SpanTagWorker;
6869
import com.itextpdf.html2pdf.attach.impl.tags.TableFooterTagWorker;
@@ -75,6 +76,7 @@ This file is part of the iText (R) project.
7576
import com.itextpdf.html2pdf.attach.impl.tags.TrTagWorker;
7677
import com.itextpdf.html2pdf.attach.impl.tags.UlOlTagWorker;
7778
import com.itextpdf.html2pdf.css.CssConstants;
79+
import com.itextpdf.html2pdf.css.page.PageMarginBoxContextNode;
7880
import com.itextpdf.html2pdf.css.pseudo.CssPseudoElementUtil;
7981
import com.itextpdf.html2pdf.css.resolve.func.counter.PageCountElementNode;
8082
import com.itextpdf.html2pdf.html.TagConstants;
@@ -208,6 +210,7 @@ private DefaultTagWorkerMapping() {
208210

209211
// custom elements mapping, implementation-specific
210212
workerMapping.putMapping(PageCountElementNode.PAGE_COUNTER_TAG, PageCountWorker.class);
213+
workerMapping.putMapping(PageMarginBoxContextNode.PAGE_MARGIN_BOX_TAG, PageMarginBoxWorker.class);
211214
}
212215

213216
/**

0 commit comments

Comments
 (0)