From: Jeremias Maerki Date: Sat, 12 Feb 2005 15:33:08 +0000 (+0000) Subject: Extend the user agent to pipe title, author and keywords through to the PDF. A title... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~81 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7f9899203326e461413ae6b2f9d2614f0b9eb8d9;p=xmlgraphics-fop.git Extend the user agent to pipe title, author and keywords through to the PDF. A title on the user agent will override any title info gathered from fo:title elements. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198426 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/apps/FOUserAgent.java b/src/java/org/apache/fop/apps/FOUserAgent.java index 7e669843a..2eec5a165 100644 --- a/src/java/org/apache/fop/apps/FOUserAgent.java +++ b/src/java/org/apache/fop/apps/FOUserAgent.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,6 +98,13 @@ public class FOUserAgent { */ protected Date creationDate = null; + /** Author of the content of the document. */ + protected String author = null; + /** Title of the document. */ + protected String title = null; + /** Set of keywords applicable to this document. */ + protected String keywords = null; + /** * Sets the InputHandler object for this process * @param inputHandler holding input file name information @@ -233,6 +240,55 @@ public class FOUserAgent { return creationDate; } + /** + * Sets the author of the document. + * @param author of document + */ + public void setAuthor(String author) { + this.author = author; + } + + /** + * Returns the author of the document + * @return author name + */ + public String getAuthor() { + return author; + } + + /** + * Sets the title of the document. This will override any title coming from + * an fo:title element. + * @param title of document + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Returns the title of the document + * @return title name + */ + public String getTitle() { + return title; + } + + /** + * Sets the keywords for the document. + * @param keywords for the document + */ + public void setKeywords(String keywords) { + this.keywords = keywords; + } + + /** + * Returns the keywords for the document + * @return the keywords + */ + public String getKeywords() { + return keywords; + } + /** * Returns the renderer options * @return renderer options diff --git a/src/java/org/apache/fop/pdf/PDFInfo.java b/src/java/org/apache/fop/pdf/PDFInfo.java index e65e8e3ef..ce926d4da 100644 --- a/src/java/org/apache/fop/pdf/PDFInfo.java +++ b/src/java/org/apache/fop/pdf/PDFInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +62,11 @@ public class PDFInfo extends PDFObject { this.creator = creator; } + /** @return the title string */ + public String getTitle() { + return this.title; + } + /** * set the title string * diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 7ab7e4d9b..7742ab040 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -84,7 +84,6 @@ import org.apache.fop.render.PrintRenderer; import org.apache.fop.render.RendererContext; import org.apache.fop.traits.BorderProps; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.properties.ColorTypeProperty; /* @@ -253,6 +252,9 @@ public class PDFRenderer extends PrintRenderer { userAgent.getProducer() != null ? userAgent.getProducer() : ""); this.pdfDoc.setCreator(userAgent.getCreator()); this.pdfDoc.setCreationDate(userAgent.getCreationDate()); + this.pdfDoc.getInfo().setAuthor(userAgent.getAuthor()); + this.pdfDoc.getInfo().setTitle(userAgent.getTitle()); + this.pdfDoc.getInfo().setKeywords(userAgent.getKeywords()); this.pdfDoc.setFilterMap(filterMap); this.pdfDoc.outputHeader(stream); @@ -390,7 +392,9 @@ public class PDFRenderer extends PrintRenderer { if (seqTitle != null) { String str = convertTitleToString(seqTitle); PDFInfo info = this.pdfDoc.getInfo(); - info.setTitle(str); + if (info.getTitle() == null) { + info.setTitle(str); + } } }