Skip to content

Commit a221d31

Browse files
yulian-gaponenkoiText-CI
authored andcommitted
Refactor PageSize constants
DEVSIX-5769
1 parent a0654a1 commit a221d31

File tree

7 files changed

+47
-49
lines changed

7 files changed

+47
-49
lines changed

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -45,38 +45,37 @@ This file is part of the iText (R) project.
4545

4646
public class PageSize extends Rectangle implements Cloneable {
4747

48-
49-
public static PageSize A0 = new PageSize(2384, 3370);
50-
public static PageSize A1 = new PageSize(1684, 2384);
51-
public static PageSize A2 = new PageSize(1190, 1684);
52-
public static PageSize A3 = new PageSize(842, 1190);
53-
public static PageSize A4 = new PageSize(595, 842);
54-
public static PageSize A5 = new PageSize(420, 595);
55-
public static PageSize A6 = new PageSize(298, 420);
56-
public static PageSize A7 = new PageSize(210, 298);
57-
public static PageSize A8 = new PageSize(148, 210);
58-
public static PageSize A9 = new PageSize(105, 547);
59-
public static PageSize A10 = new PageSize(74, 105);
60-
61-
public static PageSize B0 = new PageSize(2834, 4008);
62-
public static PageSize B1 = new PageSize(2004, 2834);
63-
public static PageSize B2 = new PageSize(1417, 2004);
64-
public static PageSize B3 = new PageSize(1000, 1417);
65-
public static PageSize B4 = new PageSize(708, 1000);
66-
public static PageSize B5 = new PageSize(498, 708);
67-
public static PageSize B6 = new PageSize(354, 498);
68-
public static PageSize B7 = new PageSize(249, 354);
69-
public static PageSize B8 = new PageSize(175, 249);
70-
public static PageSize B9 = new PageSize(124, 175);
71-
public static PageSize B10 = new PageSize(88, 124);
72-
73-
public static PageSize LETTER = new PageSize(612, 792);
74-
public static PageSize LEGAL = new PageSize(612, 1008);
75-
public static PageSize TABLOID = new PageSize(792, 1224);
76-
public static PageSize LEDGER = new PageSize(1224, 792);
77-
public static PageSize EXECUTIVE = new PageSize(522, 756);
78-
79-
public static PageSize Default = A4;
48+
public static final PageSize A0 = new PageSize(2384, 3370);
49+
public static final PageSize A1 = new PageSize(1684, 2384);
50+
public static final PageSize A2 = new PageSize(1190, 1684);
51+
public static final PageSize A3 = new PageSize(842, 1190);
52+
public static final PageSize A4 = new PageSize(595, 842);
53+
public static final PageSize A5 = new PageSize(420, 595);
54+
public static final PageSize A6 = new PageSize(298, 420);
55+
public static final PageSize A7 = new PageSize(210, 298);
56+
public static final PageSize A8 = new PageSize(148, 210);
57+
public static final PageSize A9 = new PageSize(105, 547);
58+
public static final PageSize A10 = new PageSize(74, 105);
59+
60+
public static final PageSize B0 = new PageSize(2834, 4008);
61+
public static final PageSize B1 = new PageSize(2004, 2834);
62+
public static final PageSize B2 = new PageSize(1417, 2004);
63+
public static final PageSize B3 = new PageSize(1000, 1417);
64+
public static final PageSize B4 = new PageSize(708, 1000);
65+
public static final PageSize B5 = new PageSize(498, 708);
66+
public static final PageSize B6 = new PageSize(354, 498);
67+
public static final PageSize B7 = new PageSize(249, 354);
68+
public static final PageSize B8 = new PageSize(175, 249);
69+
public static final PageSize B9 = new PageSize(124, 175);
70+
public static final PageSize B10 = new PageSize(88, 124);
71+
72+
public static final PageSize DEFAULT = A4;
73+
74+
public static final PageSize EXECUTIVE = new PageSize(522, 756);
75+
public static final PageSize LEDGER = new PageSize(1224, 792);
76+
public static final PageSize LEGAL = new PageSize(612, 1008);
77+
public static final PageSize LETTER = new PageSize(612, 792);
78+
public static final PageSize TABLOID = new PageSize(792, 1224);
8079

8180
public PageSize(float width, float height) {
8281
super(0, 0, width, height);

kernel/src/main/java/com/itextpdf/kernel/pdf/PdfDocument.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public class PdfDocument implements IEventDispatcher, Closeable {
116116
* Default page size.
117117
* New page by default will be created with this size.
118118
*/
119-
protected PageSize defaultPageSize = PageSize.Default;
119+
private PageSize defaultPageSize = PageSize.DEFAULT;
120120

121121
protected EventDispatcher eventDispatcher = new EventDispatcher();
122122

@@ -702,17 +702,19 @@ public PdfString getModifiedDocumentId() {
702702

703703
/**
704704
* Gets default page size.
705+
* New pages by default are created with this size.
705706
*
706-
* @return default page size.
707+
* @return default page size
707708
*/
708709
public PageSize getDefaultPageSize() {
709710
return defaultPageSize;
710711
}
711712

712713
/**
713714
* Sets default page size.
715+
* New pages by default will be created with this size.
714716
*
715-
* @param pageSize page size to be set as default.
717+
* @param pageSize page size to be set as default
716718
*/
717719
public void setDefaultPageSize(PageSize pageSize) {
718720
defaultPageSize = pageSize;
@@ -1058,7 +1060,7 @@ public boolean isTagged() {
10581060
* Specifies that document shall contain tag structure.
10591061
* See ISO 32000-1, section 14.8 "Tagged PDF"
10601062
*
1061-
* @return this PdfDocument
1063+
* @return this {@link PdfDocument} instance
10621064
*/
10631065
public PdfDocument setTagged() {
10641066
checkClosingStatus();

kernel/src/test/java/com/itextpdf/kernel/pdf/PdfXObjectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void createDocumentFromImages1() throws IOException, InterruptedExceptio
104104
for (int i = 0; i < 4; i++) {
105105
PdfPage page = document.addNewPage();
106106
PdfCanvas canvas = new PdfCanvas(page);
107-
canvas.addXObjectFittedIntoRectangle(images[i], PageSize.Default);
107+
canvas.addXObjectFittedIntoRectangle(images[i], PageSize.DEFAULT);
108108
page.flush();
109109
}
110110
PdfPage page = document.addNewPage();

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,12 @@ This file is part of the iText (R) project.
5050
import com.itextpdf.kernel.font.PdfFontFactory;
5151
import com.itextpdf.kernel.geom.PageSize;
5252
import com.itextpdf.kernel.geom.Rectangle;
53-
import com.itextpdf.kernel.pdf.PdfDictionary;
5453
import com.itextpdf.kernel.pdf.PdfDocument;
5554
import com.itextpdf.kernel.pdf.PdfPage;
5655
import com.itextpdf.kernel.pdf.PdfReader;
5756
import com.itextpdf.kernel.pdf.PdfWriter;
58-
import com.itextpdf.kernel.pdf.StampingProperties;
5957
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
6058
import com.itextpdf.kernel.pdf.layer.PdfLayer;
61-
import com.itextpdf.kernel.pdf.tagging.PdfStructElem;
6259
import com.itextpdf.kernel.utils.CompareTool;
6360
import com.itextpdf.layout.borders.SolidBorder;
6461
import com.itextpdf.layout.element.AreaBreak;
@@ -105,7 +102,7 @@ public void multipleAdditionsOfSameModelElementTest() throws IOException, Interr
105102
Document document = new Document(pdfDocument);
106103

107104
Paragraph p = new Paragraph("Hello. I am a paragraph. I want you to process me correctly");
108-
document.add(p).add(p).add(new AreaBreak(PageSize.Default)).add(p);
105+
document.add(p).add(p).add(new AreaBreak(PageSize.DEFAULT)).add(p);
109106

110107
document.close();
111108

@@ -123,7 +120,7 @@ public void rendererTest01() throws IOException, InterruptedException {
123120
String str = "Hello. I am a fairly long paragraph. I really want you to process me correctly. You heard that? Correctly!!! Even if you will have to wrap me.";
124121
document.add(new Paragraph(new Text(str).setBackgroundColor(ColorConstants.RED)).setBackgroundColor(ColorConstants.GREEN)).
125122
add(new Paragraph(str)).
126-
add(new AreaBreak(PageSize.Default)).
123+
add(new AreaBreak(PageSize.DEFAULT)).
127124
add(new Paragraph(str));
128125

129126
document.close();
@@ -301,7 +298,7 @@ public void checkPageSizeOfClosedEmptyDocumentTest() throws IOException {
301298
baos.close();
302299

303300
PdfDocument newDoc = new PdfDocument(new PdfReader(new ByteArrayInputStream(bytes)));
304-
Assert.assertTrue(PageSize.Default.equalsWithEpsilon(newDoc.getPage(1).getPageSize()));
301+
Assert.assertTrue(PageSize.DEFAULT.equalsWithEpsilon(newDoc.getPage(1).getPageSize()));
305302
newDoc.close();
306303
}
307304

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void preLayoutTest01() throws IOException, InterruptedException {
8484
String cmpFileName = sourceFolder + "cmp_preLayoutTest01.pdf";
8585
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)).setTagged();
8686

87-
Document document = new Document(pdfDocument, PageSize.Default, false);
87+
Document document = new Document(pdfDocument, PageSize.DEFAULT, false);
8888

8989
List<Text> pageNumberTexts = new ArrayList<>();
9090
List<IRenderer> pageNumberRenderers = new ArrayList<>();
@@ -124,7 +124,7 @@ public void preLayoutTest02() throws IOException, InterruptedException {
124124
String cmpFileName = sourceFolder + "cmp_preLayoutTest02.pdf";
125125
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
126126

127-
Document document = new Document(pdfDoc, PageSize.Default, false);
127+
Document document = new Document(pdfDoc, PageSize.DEFAULT, false);
128128

129129
document.add(new Paragraph("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
130130

@@ -164,7 +164,7 @@ public void columnDocumentRendererRelayoutTest() throws IOException, Interrupted
164164
String cmpFileName = sourceFolder + "cmp_columnDocumentRendererRelayoutTest.pdf";
165165
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)).setTagged();
166166

167-
Document document = new Document(pdfDoc, PageSize.Default, false);
167+
Document document = new Document(pdfDoc, PageSize.DEFAULT, false);
168168
Rectangle column1 = new Rectangle(40, 40, 200, 720);
169169
Rectangle column2 = new Rectangle(300, 40, 200, 720);
170170
document.setRenderer(new ColumnDocumentRenderer(document, false, new Rectangle[] {column1, column2}));

svg/src/test/java/com/itextpdf/svg/renderers/SvgIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void convert(InputStream svg, OutputStream pdfOutputStream) throws IOExce
7575
}
7676

7777
public void convert(String svg, String output) throws IOException {
78-
convert(svg, output, PageSize.Default);
78+
convert(svg, output, PageSize.DEFAULT);
7979
}
8080

8181
public void convert(String svg, String output, PageSize size) throws IOException {
@@ -124,7 +124,7 @@ public void convertToSinglePage(InputStream svg, OutputStream pdfOutputStream, I
124124
}
125125

126126
public void convertAndCompare(String src, String dest, String fileName) throws IOException, InterruptedException {
127-
convertAndCompare(src, dest, fileName, PageSize.Default);
127+
convertAndCompare(src, dest, fileName, PageSize.DEFAULT);
128128
}
129129

130130
public void convertAndCompare(String src, String dest, String fileName, PageSize size) throws IOException, InterruptedException {

svg/src/test/java/com/itextpdf/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ This file is part of the iText (R) project.
4040
@Category(UnitTest.class)
4141
public class PreserveAspectRatioSvgNodeRendererUnitTest extends ExtendedITextTest {
4242

43-
private static final Rectangle VIEWPORT_VALUE = PageSize.Default;
43+
private static final Rectangle VIEWPORT_VALUE = PageSize.DEFAULT;
4444
private static final float[] VIEWBOX_VALUES = new float[]{0, 0, 300, 400};
4545

4646
@Test

0 commit comments

Comments
 (0)