Skip to content

Commit 6935ccb

Browse files
author
Alexander Pliushchou
committed
Fix A9 page size
DEVSIX-8406
1 parent b35c28b commit 6935ccb

File tree

8 files changed

+87
-2
lines changed

8 files changed

+87
-2
lines changed

kernel/src/main/java/com/itextpdf/kernel/geom/PageSize.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class PageSize extends Rectangle implements Cloneable {
3333
public static final PageSize A6 = new PageSize(298, 420);
3434
public static final PageSize A7 = new PageSize(210, 298);
3535
public static final PageSize A8 = new PageSize(148, 210);
36-
public static final PageSize A9 = new PageSize(105, 547);
36+
public static final PageSize A9 = new PageSize(105, 148);
3737
public static final PageSize A10 = new PageSize(74, 105);
3838

3939
public static final PageSize B0 = new PageSize(2834, 4008);
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.itextpdf.kernel.geom;
2+
3+
import com.itextpdf.kernel.pdf.PdfDocument;
4+
import com.itextpdf.kernel.pdf.PdfPage;
5+
import com.itextpdf.kernel.pdf.PdfString;
6+
import com.itextpdf.kernel.pdf.annot.PdfAnnotation;
7+
import com.itextpdf.kernel.pdf.annot.PdfFreeTextAnnotation;
8+
import com.itextpdf.kernel.utils.CompareTool;
9+
import com.itextpdf.test.ExtendedITextTest;
10+
import com.itextpdf.test.annotations.type.IntegrationTest;
11+
import org.junit.AfterClass;
12+
import org.junit.Assert;
13+
import org.junit.BeforeClass;
14+
import org.junit.Test;
15+
import org.junit.experimental.categories.Category;
16+
17+
import java.io.IOException;
18+
19+
@Category(IntegrationTest.class)
20+
public class PageSizeTest extends ExtendedITextTest {
21+
22+
public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/kernel/geom/PageSizeTest/";
23+
24+
public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/kernel/geom/PageSizeTest/";
25+
26+
@BeforeClass
27+
public static void beforeClass() {
28+
createOrClearDestinationFolder(DESTINATION_FOLDER);
29+
}
30+
31+
@AfterClass
32+
public static void afterClass() {
33+
CompareTool.cleanup(DESTINATION_FOLDER);
34+
}
35+
36+
@Test
37+
public void emptyA9PageTest() throws IOException, InterruptedException {
38+
String outPdf = DESTINATION_FOLDER + "emptyA9Page.pdf";
39+
String cmpPdf = SOURCE_FOLDER + "cmp_emptyA9Page.pdf";
40+
41+
PdfDocument doc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf));
42+
doc.addNewPage(PageSize.A9);
43+
doc.close();
44+
45+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff"));
46+
}
47+
48+
@Test
49+
public void notEmptyA9PageTest() throws IOException, InterruptedException {
50+
String outPdf = DESTINATION_FOLDER + "notEmptyA9Page.pdf";
51+
String cmpPdf = SOURCE_FOLDER + "cmp_notEmptyA9Page.pdf";
52+
53+
PdfDocument doc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf));
54+
PdfPage page = doc.addNewPage(PageSize.A9);
55+
PdfAnnotation annotation = new PdfFreeTextAnnotation(new Rectangle(50,10,50,50)
56+
, new PdfString("some content"));
57+
page.addAnnotation(annotation);
58+
doc.close();
59+
60+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff"));
61+
}
62+
63+
@Test
64+
public void allATypePageSizesTest() throws IOException, InterruptedException {
65+
String outPdf = DESTINATION_FOLDER + "allATypePageSizes.pdf";
66+
String cmpPdf = SOURCE_FOLDER + "cmp_allATypePageSizes.pdf";
67+
68+
PageSize[] pageSizes = {PageSize.A0, PageSize.A1, PageSize.A2, PageSize.A3, PageSize.A4, PageSize.A5
69+
, PageSize.A6, PageSize.A7, PageSize.A8, PageSize.A9, PageSize.A10, };
70+
PdfDocument doc = new PdfDocument(CompareTool.createTestPdfWriter(outPdf));
71+
for (PageSize pageSize : pageSizes) {
72+
doc.addNewPage(pageSize);
73+
}
74+
doc.close();
75+
76+
Assert.assertNull(new CompareTool().compareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff"));
77+
}
78+
}

kernel/src/test/java/com/itextpdf/kernel/geom/PageSizeUnitTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,11 @@ public void constructFromRectangleTest() {
4040
Assert.assertEquals(rectangle.width, pageSize.width, 1e-5);
4141
Assert.assertEquals(rectangle.height, pageSize.height, 1e-5);
4242
}
43+
44+
@Test
45+
public void A9pageSizeTest() {
46+
PageSize size = new PageSize(PageSize.A9);
47+
Assert.assertEquals(148, size.height, 1e-5);
48+
Assert.assertEquals(105, size.width, 1e-5);
49+
}
4350
}
Binary file not shown.

layout/src/test/java/com/itextpdf/layout/ListTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void listNestedInTableTest01() throws IOException, InterruptedException {
135135
add("fourth string");
136136

137137
Table table = new Table(UnitValue.createPercentArray(1)).useAllAvailableWidth();
138-
table.addCell(new Cell().add(list).setVerticalAlignment(VerticalAlignment.BOTTOM));
138+
table.addCell(new Cell().add(list).setVerticalAlignment(VerticalAlignment.BOTTOM).setFontSize(10));
139139

140140
document.add(table);
141141
document.close();

0 commit comments

Comments
 (0)