Skip to content

Commit e81ed88

Browse files
author
Evgeniy Prudnikov
committed
Fixed the display of checkboxes at 100% width
DEVSIX-5571
1 parent 4eb686e commit e81ed88

22 files changed

+140
-13
lines changed

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/AbstractFormFieldRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ protected boolean isRendererFit(float availableWidth, float availableHeight) {
231231
if (occupiedArea == null) {
232232
return false;
233233
}
234-
return availableHeight >= occupiedArea.getBBox().getHeight() && availableWidth >= occupiedArea.getBBox().getWidth();
234+
return availableHeight >= occupiedArea.getBBox().getHeight() &&
235+
((availableWidth >= occupiedArea.getBBox().getWidth()) ||
236+
(this.<OverflowPropertyValue>getProperty(Property.OVERFLOW_X) == OverflowPropertyValue.VISIBLE));
235237
}
236238

237239
/**

src/main/java/com/itextpdf/html2pdf/attach/impl/layout/form/renderer/CheckBoxRenderer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ This file is part of the iText (R) project.
5757
import com.itextpdf.layout.borders.SolidBorder;
5858
import com.itextpdf.layout.element.Paragraph;
5959
import com.itextpdf.layout.layout.LayoutContext;
60+
import com.itextpdf.layout.properties.HorizontalAlignment;
6061
import com.itextpdf.layout.properties.Property;
6162
import com.itextpdf.layout.renderer.DrawContext;
6263
import com.itextpdf.layout.renderer.IRenderer;
@@ -95,7 +96,8 @@ protected IRenderer createFlatRenderer() {
9596
.setWidth(DEFAULT_SIZE)
9697
.setHeight(DEFAULT_SIZE)
9798
.setBorder(new SolidBorder(DEFAULT_BORDER_COLOR, DEFAULT_BORDER_WIDTH))
98-
.setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
99+
.setBackgroundColor(DEFAULT_BACKGROUND_COLOR)
100+
.setHorizontalAlignment(HorizontalAlignment.CENTER);
99101
return new FlatParagraphRenderer(paragraph);
100102
}
101103

src/test/java/com/itextpdf/html2pdf/element/InputTest.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,43 @@ public void checkboxTaggingTest() throws IOException, InterruptedException {
271271
}
272272

273273
@Test
274-
// TODO DEVSIX-5571 Update cmp after the ticket is closed
275-
@LogMessages(ignore = true, messages = {
276-
@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA),
277-
@LogMessage(messageTemplate = Html2PdfLogMessageConstant.INPUT_FIELD_DOES_NOT_FIT),
278-
})
274+
public void checkboxInTableTest() throws IOException, InterruptedException {
275+
runTest("checkboxInTable");
276+
}
277+
278+
@Test
279+
public void checkboxDisplayBlockInTableTest() throws IOException, InterruptedException {
280+
runTest("checkboxDisplayBlockInTable");
281+
}
282+
283+
@Test
284+
public void checkboxFullWidthDisplayBlockInTableTest() throws IOException, InterruptedException {
285+
runTest("checkboxFullWidthDisplayBlockInTable");
286+
}
287+
288+
@Test
289+
public void checkboxDiffWidthDisplayBlockInTableTest() throws IOException, InterruptedException {
290+
runTest("checkboxDiffWidthDisplayBlockInTable");
291+
}
292+
293+
@Test
294+
public void checkboxTest() throws IOException, InterruptedException {
295+
runTest("checkbox");
296+
}
297+
298+
@Test
299+
public void checkboxDisplayBlockTest() throws IOException, InterruptedException {
300+
runTest("checkboxDisplayBlock");
301+
}
302+
303+
@Test
279304
public void checkboxFullWidthDisplayBlockTest() throws IOException, InterruptedException {
280-
runTest("checkboxFullWidthDisplayBlockTest");
305+
runTest("checkboxFullWidthDisplayBlock");
306+
}
307+
308+
@Test
309+
public void checkboxDiffWidthDisplayBlockTest() throws IOException, InterruptedException {
310+
runTest("checkboxDiffWidthDisplayBlock");
281311
}
282312

283313
@Test

src/test/java/com/itextpdf/html2pdf/element/TableTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,6 @@ public void checkResponsiveTableExample() throws IOException, InterruptedExcepti
532532
}
533533

534534
@Test
535-
@LogMessages(messages = {
536-
@LogMessage(messageTemplate = LayoutLogMessageConstant.ELEMENT_DOES_NOT_FIT_AREA, count = 2),
537-
@LogMessage(messageTemplate = Html2PdfLogMessageConstant.INPUT_FIELD_DOES_NOT_FIT, count = 2),
538-
})
539-
//TODO: DEVSIX-3022 - Inputs bigger than enclosing cell force table to split
540535
public void tableWithChildrenBiggerThanCellTest() throws IOException, InterruptedException {
541536
runTest("tableWithChildrenBiggerThanCell");
542537
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<div style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
5+
<input type="checkbox" value="true"/>
6+
</div>
7+
</body>
8+
</html>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
5+
<div style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
6+
<input type="checkbox" style="width: 50%; display: block;" value="true"/>
7+
</div>
8+
9+
10+
<div style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
11+
<input type="checkbox" style="width: 100%; display: block;" value="true"/>
12+
</div>
13+
14+
15+
<div style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
16+
<input type="checkbox" style="width: 200%; display: block;" value="true"/>
17+
</div>
18+
19+
20+
</body>
21+
</html>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<table style="border-width: 0px; padding: 0px; margin: 0px; border-spacing: 0px;">
5+
<tr>
6+
<td style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
7+
<input type="checkbox" style="width: 50%; display: block;" value="true"/>
8+
</td>
9+
</tr>
10+
</table>
11+
12+
<table style="border-width: 0px; padding: 0px; margin: 0px; border-spacing: 0px;">
13+
<tr>
14+
<td style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
15+
<input type="checkbox" style="width: 100%; display: block;" value="true"/>
16+
</td>
17+
</tr>
18+
</table>
19+
20+
<table style="border-width: 0px; padding: 0px; margin: 0px; border-spacing: 0px;">
21+
<tr>
22+
<td style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
23+
<input type="checkbox" style="width: 200%; display: block;" value="true"/>
24+
</td>
25+
</tr>
26+
</table>
27+
28+
</body>
29+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<div style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
5+
<input type="checkbox" style="display: block;" value="true"/>
6+
</div>
7+
</body>
8+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<table style="border-width: 0px; padding: 0px; margin: 0px; border-spacing: 0px;">
5+
<tr>
6+
<td style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
7+
<input type="checkbox" style="display: block;" value="true"/>
8+
</td>
9+
</tr>
10+
</table>
11+
</body>
12+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<div style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
5+
<input type="checkbox" style="width: 100%; display: block;" value="true"/>
6+
</div>
7+
</body>
8+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<table style="border-width: 0px; padding: 0px; margin: 0px; border-spacing: 0px;">
5+
<tr>
6+
<td style="background-color: red; border-width: 0px; padding: 0px; margin: 0px;">
7+
<input type="checkbox" value="true"/>
8+
</td>
9+
</tr>
10+
</table>
11+
</body>
12+
</html>
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)