Skip to content

Commit 2a4c6d5

Browse files
ars18wrwpavel-alay
authored andcommitted
Resolve list item's padding considering the direction.
Do not override padding with initial-padding if it's not needed. Update some cmps. DEVSIX-2433
1 parent daa58b4 commit 2a4c6d5

Some content is hidden

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

48 files changed

+28
-14
lines changed

src/main/java/com/itextpdf/html2pdf/css/CssConstants.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public class CssConstants extends CommonCssConstants {
8585
/** The Constant MAX_HEIGHT. */
8686
public static final String MAX_HEIGHT = "max-height";
8787

88+
/** The Constant MAX_WIDTH. */
89+
public static final String MAX_WIDTH = "max-width";
90+
91+
/** The Constant MIN_WIDTH. */
92+
public static final String MIN_WIDTH = "min-width";
93+
8894
/** The Constant OUTLINE_OFFSET. */
8995
public static final String OUTLINE_OFFSET = "outline-offset";
9096

@@ -97,6 +103,9 @@ public class CssConstants extends CommonCssConstants {
97103
/** The Constant OVERFLOW_Y. */
98104
public static final String OVERFLOW_Y = "overflow-y";
99105

106+
/** The Constant PADDING_INLINE_START. */
107+
public static final String PADDING_INLINE_START = "padding-inline-start";
108+
100109
/** The Constant PLACEHOLDER. */
101110
public static final String PLACEHOLDER = "placeholder";
102111

@@ -115,12 +124,6 @@ public class CssConstants extends CommonCssConstants {
115124
/** The Constant VISIBLE. */
116125
public static final String VISIBLE = "visible";
117126

118-
/** The Constant MAX_WIDTH. */
119-
public static final String MAX_WIDTH = "max-width";
120-
121-
/** The Constant MIN_WIDTH. */
122-
public static final String MIN_WIDTH = "min-width";
123-
124127
// property values
125128

126129
/** The Constant ABSOLUTE. */

src/main/java/com/itextpdf/html2pdf/css/apply/impl/UlOlTagCssApplier.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,13 @@ This file is part of the iText (R) project.
4848
import com.itextpdf.html2pdf.css.apply.ICssApplier;
4949
import com.itextpdf.html2pdf.css.apply.util.ListStyleApplierUtil;
5050
import com.itextpdf.layout.element.List;
51+
import com.itextpdf.layout.property.BaseDirection;
5152
import com.itextpdf.layout.property.ListSymbolPosition;
5253
import com.itextpdf.layout.property.Property;
54+
import com.itextpdf.layout.property.UnitValue;
55+
import com.itextpdf.styledxmlparser.css.util.CssUtils;
5356
import com.itextpdf.styledxmlparser.node.IStylesContainer;
57+
5458
import java.util.Map;
5559

5660
/**
@@ -80,7 +84,14 @@ public void apply(ProcessorContext context, IStylesContainer stylesContainer, IT
8084
ListStyleApplierUtil.applyListStyleImageProperty(css, context, list);
8185

8286
super.apply(context, stylesContainer, tagWorker);
83-
}
84-
8587

88+
// process the padding considering the direction
89+
boolean isRtl = BaseDirection.RIGHT_TO_LEFT.equals(list.<BaseDirection>getProperty(Property.BASE_DIRECTION));
90+
if ((isRtl && !list.hasProperty(Property.PADDING_RIGHT)) || (!isRtl && !list.hasProperty(Property.PADDING_LEFT))) {
91+
float em = CssUtils.parseAbsoluteLength(css.get(CssConstants.FONT_SIZE));
92+
float rem = context.getCssContext().getRootFontSize();
93+
UnitValue startPadding = CssUtils.parseLengthValueToPt(css.get(CssConstants.PADDING_INLINE_START), em, rem);
94+
list.setProperty(isRtl ? Property.PADDING_RIGHT : Property.PADDING_LEFT, startPadding);
95+
}
96+
}
8697
}

src/main/resources/com/itextpdf/html2pdf/default.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ abbr[title], acronym[title] {
158158
ul, menu, dir {
159159
list-style-type: disc;
160160
margin: 1em 0;
161-
padding-left: 40px;
161+
padding-inline-start: 40px;
162162
}
163163

164164
ul li ul {
@@ -173,7 +173,7 @@ ol ul, ul ol, ul ul, ol ol {
173173
ol {
174174
list-style-type: decimal;
175175
margin: 1em 0;
176-
padding-left: 40px;
176+
padding-inline-start: 40px;
177177
}
178178

179179
dl {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)