Skip to content

Commit 1cc4167

Browse files
author
dmitry.radchuk
committed
Add border and background shorthand color test
DEVSIX-7028
1 parent 48f4b4b commit 1cc4167

File tree

5 files changed

+142
-1
lines changed

5 files changed

+142
-1
lines changed

src/test/java/com/itextpdf/html2pdf/css/DeviceCmykTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This file is part of the iText (R) project.
2424

2525
import com.itextpdf.html2pdf.ExtendedHtmlConversionITextTest;
2626
import com.itextpdf.html2pdf.logs.Html2PdfLogMessageConstant;
27+
import com.itextpdf.io.logs.IoLogMessageConstant;
2728
import com.itextpdf.styledxmlparser.css.validate.CssDeclarationValidationMaster;
2829
import com.itextpdf.styledxmlparser.css.validate.impl.CssDefaultValidator;
2930
import com.itextpdf.styledxmlparser.css.validate.impl.CssDeviceCmykAwareValidator;
@@ -106,6 +107,12 @@ public void borderColorTest() throws IOException, InterruptedException {
106107
convertToPdfAndCompare("borderColor", SOURCE_FOLDER, DESTINATION_FOLDER);
107108
}
108109

110+
@Test
111+
@LogMessages(messages = @LogMessage(messageTemplate = IoLogMessageConstant.LAST_ROW_IS_NOT_COMPLETE, count = 3))
112+
public void borderShorthandTest() throws IOException, InterruptedException {
113+
convertToPdfAndCompare("borderShorthand", SOURCE_FOLDER, DESTINATION_FOLDER);
114+
}
115+
109116
@Test
110117
@LogMessages(messages = {
111118
@LogMessage(messageTemplate = Html2PdfLogMessageConstant.ELEMENT_DOES_NOT_FIT_CURRENT_AREA)})
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<body bgcolor="device-cmyk(70% 0% 100% 40%)">
4-
bgcolor device-cmyk test
4+
<div style="background-color: device-cmyk(11% 32% 80% 10%);">
5+
background-color device-cmyk test
6+
</div>
7+
<div style="background-color: device-cmyk(11%, 32%, 80%, 10% / .5);">
8+
half visible background-color with commas device-cmyk test (should be previous mixed with green)
9+
</div>
10+
<div style="background: device-cmyk(10% 32% 59% 25%);">
11+
background shorthand test
12+
</div>
13+
<div style="background: device-cmyk(10%, 32%, 59%, 25% / .8);">
14+
half visible background with commas shorthand test
15+
</div>
16+
<div style="background: padding-box device-cmyk(10%, 32%, 59%, 25% / .8)">
17+
background padding box test
18+
</div>
519
</body>
620
</html>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<body>
4+
<h3>BorderColorShorthandResolver tests:</h3>
5+
<div style="border-color: device-cmyk(70%, 0%, 100%, 40% / .5); border-style: solid; border-width: 1px;">
6+
border should be half visible and green
7+
</div>
8+
<div style="border-color: device-cmyk(70%, 0%, 100%, 40%); border-style: solid; border-width: 1px;">
9+
border should be green
10+
</div>
11+
<div style="border-color: device-cmyk(70% 0% 100% 40%); border-style: solid; border-width: 1px;">
12+
border should be green
13+
</div>
14+
<br>
15+
16+
<h3>BorderShorthandResolver tests:</h3>
17+
<div style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">
18+
border should be half visible and green
19+
</div>
20+
<div style="border: 1px solid device-cmyk(70%, 0%, 100%, 40% / .5);">
21+
border should be half visible and green
22+
</div>
23+
<div style="border: 1px solid device-cmyk(70% 0% 100% 40%);">
24+
border should be green
25+
</div>
26+
<br>
27+
28+
<h3>BorderBottomShorthandResolver tests:</h3>
29+
<div style="border-bottom: 1px dashed device-cmyk(70% 0% 100% 40%);">
30+
bottom border should be green and dashed
31+
</div>
32+
<div style="border-width: 1px; border-bottom-style: solid; border-bottom-color: device-cmyk(70% 0% 100% 40%);">
33+
bottom border should be green
34+
</div>
35+
<br>
36+
37+
<h3>BorderLeftShorthandResolver tests:</h3>
38+
<div style="border-width: 1px; border-left-style: solid; border-left-color: device-cmyk(70% 0% 100% 40%);">
39+
left border should be green
40+
</div>
41+
<div style="border-left: 1px dashed device-cmyk(70% 0% 100% 40%);">
42+
left border should be green and dashed
43+
</div>
44+
<br>
45+
46+
<h3>BorderRightShorthandResolver tests:</h3>
47+
<div style="border-right: 1px dashed device-cmyk(70% 0% 100% 40%);">
48+
right border should be green and dashed
49+
</div>
50+
<div style="border-width: 1px; border-right-style: solid; border-right-color: device-cmyk(70% 0% 100% 40%);">
51+
right border should be green
52+
</div>
53+
<br>
54+
55+
<h3>BorderTopShorthandResolver tests:</h3>
56+
<div style="border-top: 1px dashed device-cmyk(70% 0% 100% 40%);">
57+
top border should be green and dashed
58+
</div>
59+
<div style="border-width: 1px; border-top-style: solid; border-top-color: device-cmyk(70% 0% 100% 40%);">
60+
top border should be green
61+
</div>
62+
<br>
63+
64+
<h3>BorderRadiusShorthandResolver tests:</h3>
65+
<div style="border-radius: 10px; border: 2px solid device-cmyk(0 81% 81% 30%/ .5 rgb(178 34 34));padding: 2px;">
66+
device-cmyk with border-radius (half visible)
67+
</div>
68+
<div style="border-bottom-left-radius: 10px; border: 2px solid device-cmyk(0 81% 81% 30%/ .5 rgb(178 34 34));padding: 2px;">
69+
device-cmyk with border-bottom-left-radius (half visible)
70+
</div>
71+
<div style="border-bottom-right-radius: 10px; border: 2px solid device-cmyk(0, 81%, 81%, 30%/ .5);padding: 2px;">
72+
device-cmyk with border-bottom-right-radius (half visible)
73+
</div>
74+
<div style="border-top-right-radius: 10px; border: 2px solid device-cmyk(0 81% 81% 30%);padding: 2px;">
75+
device-cmyk with border-top-right-radius
76+
</div>
77+
<div style="border-top-left-radius: 10px; border: 2px solid device-cmyk(0, 81%, 81%, 30%);padding: 2px;">
78+
device-cmyk with border-top-left-radius
79+
</div>
80+
<br>
81+
82+
<h3>TableRenderer "border-collapse: separate" with CMYK colors tests:</h3>
83+
<table style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5); border-collapse: separate">
84+
<tr>
85+
<th style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">first column</th>
86+
<th style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">second column
87+
<th>
88+
</tr>
89+
<tr>
90+
<td style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">border collapse</td>
91+
<td style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">with device-cmyk</td>
92+
</tr>
93+
</table>
94+
<h3>TableRenderer "border-collapse: collapse" with CMYK colors tests:</h3>
95+
<table style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5); border-collapse: collapse">
96+
<tr>
97+
<th style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">first column</th>
98+
<th style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">second column
99+
<th>
100+
</tr>
101+
<tr>
102+
<td style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">border collapse</td>
103+
<td style="border: 1px solid device-cmyk(70% 0% 100% 40% / .5);">with device-cmyk</td>
104+
</tr>
105+
</table>
106+
<h3>TableRenderer "border-collapse: collapse" with RGB colors tests:</h3>
107+
<table style="border: 1px solid rgb(255, 128, 128); border-collapse: collapse">
108+
<tr>
109+
<th style="border: 1px solid rgb(255, 128, 128);">first column</th>
110+
<th style="border: 1px solid rgb(255, 128, 128);">second column
111+
<th>
112+
</tr>
113+
<tr>
114+
<td style="border: 1px solid rgb(255, 128, 128);">border collapse</td>
115+
<td style="border: 1px solid rgb(255, 128, 128);">with rgb</td>
116+
</tr>
117+
</table>
118+
<br>
119+
</body>
120+
</html>
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)