Skip to content

Commit 817c70b

Browse files
Translate word-break: break-word CSS property to overflow-wrap: ANYWHERE
DEVSIX-7141
1 parent e02f5a1 commit 817c70b

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public static void applyFontStyles(Map<String, String> cssProps, ProcessorContex
196196
// a deprecated break-word keyword. When specified, this has the same effect
197197
// as word-break: normal and overflow-wrap: anywhere, regardless of the actual value
198198
// of the overflow-wrap property."
199-
element.setProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.BREAK_WORD);
199+
element.setProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.ANYWHERE);
200200
element.setProperty(Property.SPLIT_CHARACTERS, new DefaultSplitCharacters());
201201
} else {
202202
element.setProperty(Property.SPLIT_CHARACTERS, new DefaultSplitCharacters());

src/test/resources/com/itextpdf/html2pdf/css/OverflowWrapTest/whiteSpaceOnParentAndOverflowWrapOnChildTest.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<style>
5-
p {
5+
p {
66
width: 100px;
77
border: 1px solid red;
88
}
@@ -13,7 +13,7 @@
1313

1414
.pre {
1515
white-space: pre;
16-
}
16+
}
1717

1818
.anywhere {
1919
overflow-wrap: anywhere;
@@ -26,15 +26,15 @@
2626
</head>
2727
<body>
2828
<h3>1. nowrapBreakWord</h3>
29-
<p class="nowrap"><span class="break-word">ametconsecteturadipiscingelitseddoeiusmodtempor</span></p>
29+
<p class="nowrap"><span class="breakWord">ametconsecteturadipiscingelitseddoeiusmodtempor</span></p>
3030

3131
<h3>2. preBreakWord</h3>
32-
<p class="pre"><span class="break-word">ametconsecteturadipiscingelitseddoeiusmodtempor</span></p>
32+
<p class="pre"><span class="breakWord">ametconsecteturadipiscingelitseddoeiusmodtempor</span></p>
3333

34-
<h3>3. nowrapAnywhere</h3>
34+
<h3>3. nowrapAnywhere</h3>
3535
<p class="nowrap"><span class="anywhere">ametconsecteturadipiscingelitseddoeiusmodtempor</span></p>
3636

37-
<h3>4. preAnywhere</h3>
37+
<h3>4. preAnywhere</h3>
3838
<p class="pre"><span class="anywhere">ametconsecteturadipiscingelitseddoeiusmodtempor</span></p>
3939
</body>
4040
</html>
Binary file not shown.

src/test/resources/com/itextpdf/html2pdf/css/WordBreakTest/wordBreakTableScenario.html

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,52 @@
55
border: solid 1px;
66
}
77
.normal {
8-
break-word: normal;
8+
word-break: normal;
99
}
10-
.breakAll {
11-
break-word: break-all;
10+
.break-all {
11+
word-break: break-all;
1212
}
13-
.keepAll {
14-
break-word: keep-all;
13+
.break-word {
14+
word-break: break-word;
1515
}
16-
16+
.keep-all {
17+
word-break: keep-all;
18+
}
19+
1720
</style>
1821
</head>
1922
<body>
20-
<h3>Break-word: normal</h3>
21-
<table cellspacing="0">
23+
<h3>Word-break: normal</h3>
24+
<table cellspacing="0">
2225
<tr>
2326
<td style="width: 20%">Lorem ipsum dolor sit <span class="normal">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
2427
<td style="width: 30%">Lorem ipsum dolor sit <span class="normal">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
2528
<td style="width: 50%">Lorem ipsum dolor sit <span class="normal">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
2629
</tr>
2730
</table>
28-
<h3>Break-word: break-all</h3>
29-
<table cellspacing="0">
31+
<h3>Word-break: break-all</h3>
32+
<table cellspacing="0" style="">
3033
<tr>
3134
<td style="width: 20%">Lorem ipsum dolor sit <span class="break-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
3235
<td style="width: 30%">Lorem ipsum dolor sit <span class="break-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
3336
<td style="width: 50%">Lorem ipsum dolor sit <span class="break-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
3437
</tr>
3538
</table>
36-
<h3>Break-word: keep-all;</h3>
37-
<table cellspacing="0">
38-
<tr>
39-
<td style="width: 20%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
40-
<td style="width: 30%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
41-
<td style="width: 50%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
42-
</tr>
39+
<h3>Word-break: keep-all;</h3>
40+
<table cellspacing="0">
41+
<tr>
42+
<td style="width: 20%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
43+
<td style="width: 30%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
44+
<td style="width: 50%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
45+
</tr>
46+
</table>
47+
<h3>Word-break: break-word;</h3>
48+
<table cellspacing="0">
49+
<tr>
50+
<td style="width: 20%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
51+
<td style="width: 30%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
52+
<td style="width: 50%">Lorem ipsum dolor sit <span class="keep-all">ametconsecteturadipiscingelitseddoeiusmodtempor</span> incididunt ut labore et dolore magna aliqua</td>
53+
</tr>
4354
</table>
4455
</body>
4556
</html>

0 commit comments

Comments
 (0)