Skip to content

Commit 841b11c

Browse files
Alexander PliushchouiText-CI
authored andcommitted
Fix A9 page size
DEVSIX-8406 Autoported commit. Original commit hash: [6935ccb5e]
1 parent 2ef862e commit 841b11c

File tree

9 files changed

+76
-3
lines changed

9 files changed

+76
-3
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using iText.Kernel.Pdf;
3+
using iText.Kernel.Pdf.Annot;
4+
using iText.Kernel.Utils;
5+
using iText.Test;
6+
7+
namespace iText.Kernel.Geom {
8+
[NUnit.Framework.Category("IntegrationTest")]
9+
public class PageSizeTest : ExtendedITextTest {
10+
public static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
11+
+ "/test/itext/kernel/geom/PageSizeTest/";
12+
13+
public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
14+
.CurrentContext.TestDirectory) + "/resources/itext/kernel/geom/PageSizeTest/";
15+
16+
[NUnit.Framework.OneTimeSetUp]
17+
public static void BeforeClass() {
18+
CreateOrClearDestinationFolder(DESTINATION_FOLDER);
19+
}
20+
21+
[NUnit.Framework.OneTimeTearDown]
22+
public static void AfterClass() {
23+
CompareTool.Cleanup(DESTINATION_FOLDER);
24+
}
25+
26+
[NUnit.Framework.Test]
27+
public virtual void EmptyA9PageTest() {
28+
String outPdf = DESTINATION_FOLDER + "emptyA9Page.pdf";
29+
String cmpPdf = SOURCE_FOLDER + "cmp_emptyA9Page.pdf";
30+
PdfDocument doc = new PdfDocument(CompareTool.CreateTestPdfWriter(outPdf));
31+
doc.AddNewPage(PageSize.A9);
32+
doc.Close();
33+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff"
34+
));
35+
}
36+
37+
[NUnit.Framework.Test]
38+
public virtual void NotEmptyA9PageTest() {
39+
String outPdf = DESTINATION_FOLDER + "notEmptyA9Page.pdf";
40+
String cmpPdf = SOURCE_FOLDER + "cmp_notEmptyA9Page.pdf";
41+
PdfDocument doc = new PdfDocument(CompareTool.CreateTestPdfWriter(outPdf));
42+
PdfPage page = doc.AddNewPage(PageSize.A9);
43+
PdfAnnotation annotation = new PdfFreeTextAnnotation(new Rectangle(50, 10, 50, 50), new PdfString("some content"
44+
));
45+
page.AddAnnotation(annotation);
46+
doc.Close();
47+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff"
48+
));
49+
}
50+
51+
[NUnit.Framework.Test]
52+
public virtual void AllATypePageSizesTest() {
53+
String outPdf = DESTINATION_FOLDER + "allATypePageSizes.pdf";
54+
String cmpPdf = SOURCE_FOLDER + "cmp_allATypePageSizes.pdf";
55+
PageSize[] pageSizes = new PageSize[] { PageSize.A0, PageSize.A1, PageSize.A2, PageSize.A3, PageSize.A4, PageSize
56+
.A5, PageSize.A6, PageSize.A7, PageSize.A8, PageSize.A9, PageSize.A10 };
57+
PdfDocument doc = new PdfDocument(CompareTool.CreateTestPdfWriter(outPdf));
58+
foreach (PageSize pageSize in pageSizes) {
59+
doc.AddNewPage(pageSize);
60+
}
61+
doc.Close();
62+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff"
63+
));
64+
}
65+
}
66+
}

itext.tests/itext.kernel.tests/itext/kernel/geom/PageSizeUnitTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,12 @@ public virtual void ConstructFromRectangleTest() {
3434
NUnit.Framework.Assert.AreEqual(rectangle.width, pageSize.width, 1e-5);
3535
NUnit.Framework.Assert.AreEqual(rectangle.height, pageSize.height, 1e-5);
3636
}
37+
38+
[NUnit.Framework.Test]
39+
public virtual void A9pageSizeTest() {
40+
PageSize size = new PageSize(PageSize.A9);
41+
NUnit.Framework.Assert.AreEqual(148, size.height, 1e-5);
42+
NUnit.Framework.Assert.AreEqual(105, size.width, 1e-5);
43+
}
3744
}
3845
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

itext.tests/itext.layout.tests/itext/layout/ListTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public virtual void ListNestedInTableTest01() {
9393
List list = new List(ListNumberingType.DECIMAL).Add("first string").Add("second string").Add("third string"
9494
).Add("fourth string");
9595
Table table = new Table(UnitValue.CreatePercentArray(1)).UseAllAvailableWidth();
96-
table.AddCell(new Cell().Add(list).SetVerticalAlignment(VerticalAlignment.BOTTOM));
96+
table.AddCell(new Cell().Add(list).SetVerticalAlignment(VerticalAlignment.BOTTOM).SetFontSize(10));
9797
document.Add(table);
9898
document.Close();
9999
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
Binary file not shown.

itext/itext.kernel/itext/kernel/geom/PageSize.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class PageSize : Rectangle {
4040

4141
public static readonly iText.Kernel.Geom.PageSize A8 = new iText.Kernel.Geom.PageSize(148, 210);
4242

43-
public static readonly iText.Kernel.Geom.PageSize A9 = new iText.Kernel.Geom.PageSize(105, 547);
43+
public static readonly iText.Kernel.Geom.PageSize A9 = new iText.Kernel.Geom.PageSize(105, 148);
4444

4545
public static readonly iText.Kernel.Geom.PageSize A10 = new iText.Kernel.Geom.PageSize(74, 105);
4646

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b35c28b993564c2a7eb0be14fe05d3e5a323f125
1+
6935ccb5ed7a96bb006e03c723e8190bbbdd0338

0 commit comments

Comments
 (0)