Skip to content

Commit 79a7c91

Browse files
Refactor PageSize constants
DEVSIX-5769 Autoported commit. Original commit hash: [339e73272]
1 parent 2ab2cfb commit 79a7c91

File tree

8 files changed

+55
-43
lines changed

8 files changed

+55
-43
lines changed

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfXObjectTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public virtual void CreateDocumentFromImages1() {
8686
for (int i = 0; i < 4; i++) {
8787
PdfPage page = document.AddNewPage();
8888
PdfCanvas canvas = new PdfCanvas(page);
89-
canvas.AddXObjectFittedIntoRectangle(images[i], PageSize.Default);
89+
canvas.AddXObjectFittedIntoRectangle(images[i], PageSize.DEFAULT);
9090
page.Flush();
9191
}
9292
PdfPage page_1 = document.AddNewPage();

itext.tests/itext.layout.tests/itext/layout/DefaultLayoutTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public virtual void MultipleAdditionsOfSameModelElementTest() {
7979
pdfDocument.SetTagged();
8080
Document document = new Document(pdfDocument);
8181
Paragraph p = new Paragraph("Hello. I am a paragraph. I want you to process me correctly");
82-
document.Add(p).Add(p).Add(new AreaBreak(PageSize.Default)).Add(p);
82+
document.Add(p).Add(p).Add(new AreaBreak(PageSize.DEFAULT)).Add(p);
8383
document.Close();
8484
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
8585
, "diff"));
@@ -93,7 +93,7 @@ public virtual void RendererTest01() {
9393
Document document = new Document(pdfDocument);
9494
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.";
9595
document.Add(new Paragraph(new Text(str).SetBackgroundColor(ColorConstants.RED)).SetBackgroundColor(ColorConstants
96-
.GREEN)).Add(new Paragraph(str)).Add(new AreaBreak(PageSize.Default)).Add(new Paragraph(str));
96+
.GREEN)).Add(new Paragraph(str)).Add(new AreaBreak(PageSize.DEFAULT)).Add(new Paragraph(str));
9797
document.Close();
9898
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
9999
, "diff"));
@@ -241,7 +241,7 @@ public virtual void CheckPageSizeOfClosedEmptyDocumentTest() {
241241
byte[] bytes = baos.ToArray();
242242
baos.Dispose();
243243
PdfDocument newDoc = new PdfDocument(new PdfReader(new MemoryStream(bytes)));
244-
NUnit.Framework.Assert.IsTrue(PageSize.Default.EqualsWithEpsilon(newDoc.GetPage(1).GetPageSize()));
244+
NUnit.Framework.Assert.IsTrue(PageSize.DEFAULT.EqualsWithEpsilon(newDoc.GetPage(1).GetPageSize()));
245245
newDoc.Close();
246246
}
247247

itext.tests/itext.layout.tests/itext/layout/PreLayoutTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public virtual void PreLayoutTest01() {
7272
String outFileName = destinationFolder + "preLayoutTest01.pdf";
7373
String cmpFileName = sourceFolder + "cmp_preLayoutTest01.pdf";
7474
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)).SetTagged();
75-
Document document = new Document(pdfDocument, PageSize.Default, false);
75+
Document document = new Document(pdfDocument, PageSize.DEFAULT, false);
7676
IList<Text> pageNumberTexts = new List<Text>();
7777
IList<IRenderer> pageNumberRenderers = new List<IRenderer>();
7878
document.SetProperty(Property.FONT, PdfFontFactory.CreateFont(StandardFonts.HELVETICA));
@@ -105,7 +105,7 @@ public virtual void PreLayoutTest02() {
105105
String outFileName = destinationFolder + "preLayoutTest02.pdf";
106106
String cmpFileName = sourceFolder + "cmp_preLayoutTest02.pdf";
107107
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName));
108-
Document document = new Document(pdfDoc, PageSize.Default, false);
108+
Document document = new Document(pdfDoc, PageSize.DEFAULT, false);
109109
document.Add(new Paragraph("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
110110
StringBuilder text = new StringBuilder();
111111
for (int i = 0; i < 1200; i++) {
@@ -139,7 +139,7 @@ public virtual void ColumnDocumentRendererRelayoutTest() {
139139
String outFileName = destinationFolder + "columnDocumentRendererRelayoutTest.pdf";
140140
String cmpFileName = sourceFolder + "cmp_columnDocumentRendererRelayoutTest.pdf";
141141
PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)).SetTagged();
142-
Document document = new Document(pdfDoc, PageSize.Default, false);
142+
Document document = new Document(pdfDoc, PageSize.DEFAULT, false);
143143
Rectangle column1 = new Rectangle(40, 40, 200, 720);
144144
Rectangle column2 = new Rectangle(300, 40, 200, 720);
145145
document.SetRenderer(new ColumnDocumentRenderer(document, false, new Rectangle[] { column1, column2 }));

itext.tests/itext.svg.tests/itext/svg/renderers/SvgIntegrationTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public virtual void Convert(Stream svg, Stream pdfOutputStream) {
6161
}
6262

6363
public virtual void Convert(String svg, String output) {
64-
Convert(svg, output, PageSize.Default);
64+
Convert(svg, output, PageSize.DEFAULT);
6565
}
6666

6767
public virtual void Convert(String svg, String output, PageSize size) {
@@ -114,7 +114,7 @@ public virtual void ConvertToSinglePage(Stream svg, Stream pdfOutputStream, ISvg
114114
}
115115

116116
public virtual void ConvertAndCompare(String src, String dest, String fileName) {
117-
ConvertAndCompare(src, dest, fileName, PageSize.Default);
117+
ConvertAndCompare(src, dest, fileName, PageSize.DEFAULT);
118118
}
119119

120120
public virtual void ConvertAndCompare(String src, String dest, String fileName, PageSize size) {

itext.tests/itext.svg.tests/itext/svg/renderers/impl/PreserveAspectRatioSvgNodeRendererUnitTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ You should have received a copy of the GNU Affero General Public License
3030

3131
namespace iText.Svg.Renderers.Impl {
3232
public class PreserveAspectRatioSvgNodeRendererUnitTest : ExtendedITextTest {
33-
private static readonly Rectangle VIEWPORT_VALUE = PageSize.Default;
33+
private static readonly Rectangle VIEWPORT_VALUE = PageSize.DEFAULT;
3434

3535
private static readonly float[] VIEWBOX_VALUES = new float[] { 0, 0, 300, 400 };
3636

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,61 +43,61 @@ source product.
4343
*/
4444
namespace iText.Kernel.Geom {
4545
public class PageSize : Rectangle {
46-
public static iText.Kernel.Geom.PageSize A0 = new iText.Kernel.Geom.PageSize(2384, 3370);
46+
public static readonly iText.Kernel.Geom.PageSize A0 = new iText.Kernel.Geom.PageSize(2384, 3370);
4747

48-
public static iText.Kernel.Geom.PageSize A1 = new iText.Kernel.Geom.PageSize(1684, 2384);
48+
public static readonly iText.Kernel.Geom.PageSize A1 = new iText.Kernel.Geom.PageSize(1684, 2384);
4949

50-
public static iText.Kernel.Geom.PageSize A2 = new iText.Kernel.Geom.PageSize(1190, 1684);
50+
public static readonly iText.Kernel.Geom.PageSize A2 = new iText.Kernel.Geom.PageSize(1190, 1684);
5151

52-
public static iText.Kernel.Geom.PageSize A3 = new iText.Kernel.Geom.PageSize(842, 1190);
52+
public static readonly iText.Kernel.Geom.PageSize A3 = new iText.Kernel.Geom.PageSize(842, 1190);
5353

54-
public static iText.Kernel.Geom.PageSize A4 = new iText.Kernel.Geom.PageSize(595, 842);
54+
public static readonly iText.Kernel.Geom.PageSize A4 = new iText.Kernel.Geom.PageSize(595, 842);
5555

56-
public static iText.Kernel.Geom.PageSize A5 = new iText.Kernel.Geom.PageSize(420, 595);
56+
public static readonly iText.Kernel.Geom.PageSize A5 = new iText.Kernel.Geom.PageSize(420, 595);
5757

58-
public static iText.Kernel.Geom.PageSize A6 = new iText.Kernel.Geom.PageSize(298, 420);
58+
public static readonly iText.Kernel.Geom.PageSize A6 = new iText.Kernel.Geom.PageSize(298, 420);
5959

60-
public static iText.Kernel.Geom.PageSize A7 = new iText.Kernel.Geom.PageSize(210, 298);
60+
public static readonly iText.Kernel.Geom.PageSize A7 = new iText.Kernel.Geom.PageSize(210, 298);
6161

62-
public static iText.Kernel.Geom.PageSize A8 = new iText.Kernel.Geom.PageSize(148, 210);
62+
public static readonly iText.Kernel.Geom.PageSize A8 = new iText.Kernel.Geom.PageSize(148, 210);
6363

64-
public static iText.Kernel.Geom.PageSize A9 = new iText.Kernel.Geom.PageSize(105, 547);
64+
public static readonly iText.Kernel.Geom.PageSize A9 = new iText.Kernel.Geom.PageSize(105, 547);
6565

66-
public static iText.Kernel.Geom.PageSize A10 = new iText.Kernel.Geom.PageSize(74, 105);
66+
public static readonly iText.Kernel.Geom.PageSize A10 = new iText.Kernel.Geom.PageSize(74, 105);
6767

68-
public static iText.Kernel.Geom.PageSize B0 = new iText.Kernel.Geom.PageSize(2834, 4008);
68+
public static readonly iText.Kernel.Geom.PageSize B0 = new iText.Kernel.Geom.PageSize(2834, 4008);
6969

70-
public static iText.Kernel.Geom.PageSize B1 = new iText.Kernel.Geom.PageSize(2004, 2834);
70+
public static readonly iText.Kernel.Geom.PageSize B1 = new iText.Kernel.Geom.PageSize(2004, 2834);
7171

72-
public static iText.Kernel.Geom.PageSize B2 = new iText.Kernel.Geom.PageSize(1417, 2004);
72+
public static readonly iText.Kernel.Geom.PageSize B2 = new iText.Kernel.Geom.PageSize(1417, 2004);
7373

74-
public static iText.Kernel.Geom.PageSize B3 = new iText.Kernel.Geom.PageSize(1000, 1417);
74+
public static readonly iText.Kernel.Geom.PageSize B3 = new iText.Kernel.Geom.PageSize(1000, 1417);
7575

76-
public static iText.Kernel.Geom.PageSize B4 = new iText.Kernel.Geom.PageSize(708, 1000);
76+
public static readonly iText.Kernel.Geom.PageSize B4 = new iText.Kernel.Geom.PageSize(708, 1000);
7777

78-
public static iText.Kernel.Geom.PageSize B5 = new iText.Kernel.Geom.PageSize(498, 708);
78+
public static readonly iText.Kernel.Geom.PageSize B5 = new iText.Kernel.Geom.PageSize(498, 708);
7979

80-
public static iText.Kernel.Geom.PageSize B6 = new iText.Kernel.Geom.PageSize(354, 498);
80+
public static readonly iText.Kernel.Geom.PageSize B6 = new iText.Kernel.Geom.PageSize(354, 498);
8181

82-
public static iText.Kernel.Geom.PageSize B7 = new iText.Kernel.Geom.PageSize(249, 354);
82+
public static readonly iText.Kernel.Geom.PageSize B7 = new iText.Kernel.Geom.PageSize(249, 354);
8383

84-
public static iText.Kernel.Geom.PageSize B8 = new iText.Kernel.Geom.PageSize(175, 249);
84+
public static readonly iText.Kernel.Geom.PageSize B8 = new iText.Kernel.Geom.PageSize(175, 249);
8585

86-
public static iText.Kernel.Geom.PageSize B9 = new iText.Kernel.Geom.PageSize(124, 175);
86+
public static readonly iText.Kernel.Geom.PageSize B9 = new iText.Kernel.Geom.PageSize(124, 175);
8787

88-
public static iText.Kernel.Geom.PageSize B10 = new iText.Kernel.Geom.PageSize(88, 124);
88+
public static readonly iText.Kernel.Geom.PageSize B10 = new iText.Kernel.Geom.PageSize(88, 124);
8989

90-
public static iText.Kernel.Geom.PageSize LETTER = new iText.Kernel.Geom.PageSize(612, 792);
90+
public static readonly iText.Kernel.Geom.PageSize DEFAULT = A4;
9191

92-
public static iText.Kernel.Geom.PageSize LEGAL = new iText.Kernel.Geom.PageSize(612, 1008);
92+
public static readonly iText.Kernel.Geom.PageSize EXECUTIVE = new iText.Kernel.Geom.PageSize(522, 756);
9393

94-
public static iText.Kernel.Geom.PageSize TABLOID = new iText.Kernel.Geom.PageSize(792, 1224);
94+
public static readonly iText.Kernel.Geom.PageSize LEDGER = new iText.Kernel.Geom.PageSize(1224, 792);
9595

96-
public static iText.Kernel.Geom.PageSize LEDGER = new iText.Kernel.Geom.PageSize(1224, 792);
96+
public static readonly iText.Kernel.Geom.PageSize LEGAL = new iText.Kernel.Geom.PageSize(612, 1008);
9797

98-
public static iText.Kernel.Geom.PageSize EXECUTIVE = new iText.Kernel.Geom.PageSize(522, 756);
98+
public static readonly iText.Kernel.Geom.PageSize LETTER = new iText.Kernel.Geom.PageSize(612, 792);
9999

100-
public static iText.Kernel.Geom.PageSize Default = A4;
100+
public static readonly iText.Kernel.Geom.PageSize TABLOID = new iText.Kernel.Geom.PageSize(792, 1224);
101101

102102
public PageSize(float width, float height)
103103
: base(0, 0, width, height) {

itext/itext.kernel/itext/kernel/pdf/PdfDocument.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class PdfDocument : IEventDispatcher, IDisposable {
8282
/// Default page size.
8383
/// New page by default will be created with this size.
8484
/// </remarks>
85-
protected internal PageSize defaultPageSize = PageSize.Default;
85+
private PageSize defaultPageSize = PageSize.DEFAULT;
8686

8787
protected internal EventDispatcher eventDispatcher = new EventDispatcher();
8888

@@ -608,13 +608,21 @@ public virtual PdfString GetModifiedDocumentId() {
608608
}
609609

610610
/// <summary>Gets default page size.</summary>
611-
/// <returns>default page size.</returns>
611+
/// <remarks>
612+
/// Gets default page size.
613+
/// New pages by default are created with this size.
614+
/// </remarks>
615+
/// <returns>default page size</returns>
612616
public virtual PageSize GetDefaultPageSize() {
613617
return defaultPageSize;
614618
}
615619

616620
/// <summary>Sets default page size.</summary>
617-
/// <param name="pageSize">page size to be set as default.</param>
621+
/// <remarks>
622+
/// Sets default page size.
623+
/// New pages by default will be created with this size.
624+
/// </remarks>
625+
/// <param name="pageSize">page size to be set as default</param>
618626
public virtual void SetDefaultPageSize(PageSize pageSize) {
619627
defaultPageSize = pageSize;
620628
}
@@ -922,7 +930,11 @@ public virtual bool IsTagged() {
922930
/// Specifies that document shall contain tag structure.
923931
/// See ISO 32000-1, section 14.8 "Tagged PDF"
924932
/// </remarks>
925-
/// <returns>this PdfDocument</returns>
933+
/// <returns>
934+
/// this
935+
/// <see cref="PdfDocument"/>
936+
/// instance
937+
/// </returns>
926938
public virtual iText.Kernel.Pdf.PdfDocument SetTagged() {
927939
CheckClosingStatus();
928940
if (structTreeRoot == null) {

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a0654a1ed99416c1597d6d34739d1538368d2cb4
1+
a221d31ae5f9bf8588a62b807d32882d2c2d7059

0 commit comments

Comments
 (0)