Revision: 12447
http://sourceforge.net/p/foray/code/12447
Author: victormote
Date: 2022-01-21 23:36:45 +0000 (Fri, 21 Jan 2022)
Log Message:
-----------
Refactor page creation logic, part 2.
Modified Paths:
--------------
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-21 23:25:28 UTC (rev 12446)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPage4a.java 2022-01-21 23:36:45 UTC (rev 12447)
@@ -51,7 +51,7 @@
private static final String PDF_FILE_EXTENSION = ".pdf";
/** The page's parent, a PDF reference object. */
- private String parent;
+ private PdfPages parent;
/** The page's /Resource object. */
private PdfResources resources;
@@ -75,13 +75,15 @@
/**
* Create a /Page object.
+ * @param parent The parent /Pages object.
* @param doc The PDF document being built.
- * @param resources the /Resources object
- * @param pagewidth the page's width in points
- * @param pageheight the page's height in points
+ * @param resources The /Resources object.
+ * @param pagewidth The page's width in points.
+ * @param pageheight The page's height in points.
*/
- public PdfPage4a(final PdfDocument4a doc, final PdfResources resources,
+ public PdfPage4a(final PdfPages parent, final PdfDocument4a doc, final PdfResources resources,
final int pagewidth, final int pageheight) {
+ this.parent = parent;
this.doc = doc;
this.resources = resources;
@@ -100,14 +102,6 @@
}
/**
- * Set this page's parent.
- * @param parent the /Pages object that is this page's parent
- */
- public void setParent(final PdfPages parent) {
- this.parent = parent.pdfReference(this.doc);
- }
-
- /**
* Get this page's annotation list.
* @return annotList a PdfAnnotList list of annotations
*/
@@ -133,7 +127,7 @@
sb.append(this.pdfID() + EOL
+ "<<" + EOL
+ "/Type /Page" + EOL
- + "/Parent " + this.parent + EOL
+ + "/Parent " + this.parent.pdfReference(this.doc) + EOL
+ "/MediaBox [ 0 0 " + this.pagewidth + " "
+ this.pageheight + " ]" + EOL
+ "/Resources " + this.resources.pdfReference(doc) + EOL
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java 2022-01-21 23:25:28 UTC (rev 12446)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfPages.java 2022-01-21 23:36:45 UTC (rev 12447)
@@ -66,7 +66,6 @@
*/
public void addPage(final PdfPage4a page) {
this.kids.add(page.pdfReference(page.getPDFDocument()));
- page.setParent(this);
this.incrementCount();
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-21 23:25:28 UTC (rev 12446)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/object/PdfRoot.java 2022-01-21 23:36:45 UTC (rev 12447)
@@ -68,12 +68,12 @@
/**
* Create a /Page object and add it to /Pages.
- * @param width The width of the new page, in millipoints.
- * @param height The height of the new page, in millipoints.
+ * @param width The width of the new page, in points.
+ * @param height The height of the new page, in points.
* @return The new page.
*/
public PdfPage4a createPage(final int width, final int height) {
- final PdfPage4a page = new PdfPage4a(this.document, this.document.getResources(), width, height);
+ final PdfPage4a page = new PdfPage4a(this.pages, this.document, this.document.getResources(), width, height);
this.pages.addPage(page);
return page;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|