From c9a1bd7c7ba2e14bd1c8a83bcdf3acea36c9f44e Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 20 Nov 2002 07:51:35 +0000 Subject: [PATCH] enable setting creator git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195570 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/pdf/PDFDocument.java | 9 +++++++++ src/org/apache/fop/pdf/PDFInfo.java | 13 +++++++++++++ .../apache/fop/render/AbstractRenderer.java | 7 +++++++ src/org/apache/fop/render/Renderer.java | 14 ++++++++++++++ src/org/apache/fop/render/pdf/PDFRenderer.java | 18 +++++++++++++++--- 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/org/apache/fop/pdf/PDFDocument.java b/src/org/apache/fop/pdf/PDFDocument.java index f4b115770..4c62c85fb 100644 --- a/src/org/apache/fop/pdf/PDFDocument.java +++ b/src/org/apache/fop/pdf/PDFDocument.java @@ -192,6 +192,15 @@ public class PDFDocument { this.info.setProducer(producer); } + /** + * set the creator of the document + * + * @param creator string indicating application creating the document + */ + public void setCreator(String creator) { + this.info.setCreator(creator); + } + /** * Set the filter map to use for filters in this document. * diff --git a/src/org/apache/fop/pdf/PDFInfo.java b/src/org/apache/fop/pdf/PDFInfo.java index 1004389f9..9193648ab 100644 --- a/src/org/apache/fop/pdf/PDFInfo.java +++ b/src/org/apache/fop/pdf/PDFInfo.java @@ -47,6 +47,15 @@ public class PDFInfo extends PDFObject { this.producer = producer; } + /** + * set the creator string + * + * @param creator the document creator + */ + public void setCreator(String creator) { + this.creator = creator; + } + public void setTitle(String t) { this.title = t; } @@ -84,6 +93,10 @@ public class PDFInfo extends PDFObject { p += "/Keywords (" + this.keywords + ")\n"; } + if (creator != null) { + p += "/Creator (" + this.creator + ")\n"; + } + p += "/Producer (" + this.producer + ")\n"; // creation date in form (D:YYYYMMDDHHmmSSOHH'mm') diff --git a/src/org/apache/fop/render/AbstractRenderer.java b/src/org/apache/fop/render/AbstractRenderer.java index bf489acf6..4c0823b1a 100644 --- a/src/org/apache/fop/render/AbstractRenderer.java +++ b/src/org/apache/fop/render/AbstractRenderer.java @@ -95,6 +95,13 @@ public abstract class AbstractRenderer extends AbstractLogEnabled */ protected int containingIPPosition = 0; + /** @see org.apache.fop.render.Renderer */ + public void setProducer(String producer) { + } + + /** @see org.apache.fop.render.Renderer */ + public void setCreator(String creator) { + } /** @see org.apache.fop.render.Renderer */ public void setUserAgent(FOUserAgent agent) { diff --git a/src/org/apache/fop/render/Renderer.java b/src/org/apache/fop/render/Renderer.java index 9a489c7d7..2fe1a3f0c 100644 --- a/src/org/apache/fop/render/Renderer.java +++ b/src/org/apache/fop/render/Renderer.java @@ -47,6 +47,9 @@ public interface Renderer { /** * Initiates the rendering phase. + * This must only be called once for a rendering. If + * stopRenderer is called then this may be called again + * for a new document rendering. * * @param outputStream The OutputStream to use for output * @exception IOException If an I/O error occurs @@ -56,6 +59,8 @@ public interface Renderer { /** * Signals the end of the rendering phase. + * The renderer should reset to an initial state and dispose of + * any resources for the completed rendering. * * @exception IOException If an I/O error occurs */ @@ -92,6 +97,15 @@ public interface Renderer { */ void setProducer(String producer); + /** + * Set the creator of the document to be rendered. If this method + * isn't called the renderer uses a default. + * Note: Not all renderers support this feature. + * + * @param creator The name of the document creator + */ + void setCreator(String creator); + /** * Reports if out of order rendering is supported.

* diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 609023e1a..16d23e79a 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -112,7 +112,9 @@ public class PDFRenderer extends PrintRenderer { protected HashMap pageReferences = new HashMap(); protected HashMap pvReferences = new HashMap(); - private String producer; + private String producer = "FOP"; + + private String creator = null; /** * The output stream to write the document to @@ -221,6 +223,15 @@ public class PDFRenderer extends PrintRenderer { } + /** + * set the document creator + * + * @param creator string indicating application that is creating the document + */ + public void setCreator(String crea) { + creator = crea; + } + /** * set the PDF document's producer * @@ -240,8 +251,9 @@ public class PDFRenderer extends PrintRenderer { public void startRenderer(OutputStream stream) throws IOException { ostream = stream; - this.pdfDoc = new PDFDocument(Version.getVersion()); - this.pdfDoc.setProducer(producer); + producer = "FOP " + Version.getVersion(); + this.pdfDoc = new PDFDocument(producer); + this.pdfDoc.setCreator(creator); this.pdfDoc.setFilterMap(filterMap); pdfDoc.outputHeader(stream); } -- 2.39.5