Skip to content

Commit 297c6c6

Browse files
committed
Parse min-width and max-width properties.
DEVSIX-1195
1 parent 2e104ab commit 297c6c6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,12 @@ public class CssConstants {
434434
/** The Constant WIDTH. */
435435
public static final String WIDTH = "width";
436436

437+
/** The Constant MAX_WIDTH. */
438+
public static final String MAX_WIDTH = "max-width";
439+
440+
/** The Constant MIN_WIDTH. */
441+
public static final String MIN_WIDTH = "min-width";
442+
437443
/** The Constant WORDWRAP. */
438444
public static final String WORDWRAP = "word-wrap";
439445

src/main/java/com/itextpdf/html2pdf/css/apply/util/WidthHeightApplierUtil.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ public static void applyWidthHeight(Map<String, String> cssProps, ProcessorConte
8787
element.setProperty(Property.WIDTH, width);
8888
}
8989

90+
String minWidthVal = cssProps.get(CssConstants.MIN_WIDTH);
91+
if (!CssConstants.AUTO.equals(minWidthVal) && minWidthVal != null) {
92+
UnitValue minWidth = CssUtils.parseLengthValueToPt(minWidthVal, em, rem);
93+
element.setProperty(Property.MIN_WIDTH, minWidth);
94+
}
95+
96+
String maxWidthVal = cssProps.get(CssConstants.MAX_WIDTH);
97+
if (!CssConstants.AUTO.equals(maxWidthVal) && maxWidthVal != null) {
98+
UnitValue maxWidth = CssUtils.parseLengthValueToPt(maxWidthVal, em, rem);
99+
element.setProperty(Property.MAX_WIDTH, maxWidth);
100+
}
101+
90102
// TODO consider display css property
91103
boolean applyToTable = element instanceof Table;
92104
boolean applyToCell = element instanceof Cell;

0 commit comments

Comments
 (0)