aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/pdf
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-01-28 15:04:39 +0000
committerJeremias Maerki <jeremias@apache.org>2008-01-28 15:04:39 +0000
commit1ea8b13df56f773fc3d28a9a4b69ed1ed8b97cf4 (patch)
treeaa175e32ee1cee808287fee13ff980747cfcc262 /src/java/org/apache/fop/render/pdf
parent74b2adc7ebb1c898d17bc5778de412522512d4c8 (diff)
downloadxmlgraphics-fop-1ea8b13df56f773fc3d28a9a4b69ed1ed8b97cf4.tar.gz
xmlgraphics-fop-1ea8b13df56f773fc3d28a9a4b69ed1ed8b97cf4.zip
Added support for the natural language indentifier ("Lang" in the document catalog) for PDF documents based on the language/country values on fo:page-sequence. This required a few changes in the AreaTreeModel and the Renderer interface because it didn't support passing through the PageSequence object, only its title. Now, we can put other values on the PageSequence and transport them to the renderers.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@615906 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/pdf')
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index 899bc1240..4d641517a 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -61,6 +61,7 @@ import org.apache.fop.area.DestinationData;
import org.apache.fop.area.LineArea;
import org.apache.fop.area.OffDocumentExtensionAttachment;
import org.apache.fop.area.OffDocumentItem;
+import org.apache.fop.area.PageSequence;
import org.apache.fop.area.PageViewport;
import org.apache.fop.area.RegionViewport;
import org.apache.fop.area.Trait;
@@ -611,7 +612,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
private void renderXMPMetadata(XMPMetadata metadata) {
Metadata docXMP = metadata.getMetadata();
- Metadata fopXMP = PDFMetadata.createXMPFromUserAgent(pdfDoc);
+ Metadata fopXMP = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
//Merge FOP's own metadata into the one from the XSL-FO document
fopXMP.mergeInto(docXMP);
XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(docXMP);
@@ -679,13 +680,15 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
/**
* Start the next page sequence.
- * For the pdf renderer there is no concept of page sequences
+ * For the PDF renderer there is no concept of page sequences
* but it uses the first available page sequence title to set
- * as the title of the pdf document.
- *
- * @param seqTitle the title of the page sequence
+ * as the title of the PDF document, and the language of the
+ * document.
+ * @param pageSequence the page sequence
*/
- public void startPageSequence(LineArea seqTitle) {
+ public void startPageSequence(PageSequence pageSequence) {
+ super.startPageSequence(pageSequence);
+ LineArea seqTitle = pageSequence.getTitle();
if (seqTitle != null) {
String str = convertTitleToString(seqTitle);
PDFInfo info = this.pdfDoc.getInfo();
@@ -693,10 +696,20 @@ public class PDFRenderer extends AbstractPathOrientedRenderer {
info.setTitle(str);
}
}
+ if (pageSequence.getLanguage() != null) {
+ String lang = pageSequence.getLanguage();
+ String country = pageSequence.getCountry();
+ String langCode = lang + (country != null ? "-" + country : "");
+ if (pdfDoc.getRoot().getLanguage() == null) {
+ //Only set if not set already (first non-null is used)
+ //Note: No checking is performed whether the values are valid!
+ pdfDoc.getRoot().setLanguage(langCode);
+ }
+ }
if (pdfDoc.getRoot().getMetadata() == null) {
//If at this time no XMP metadata for the overall document has been set, create it
//from the PDFInfo object.
- Metadata xmp = PDFMetadata.createXMPFromUserAgent(pdfDoc);
+ Metadata xmp = PDFMetadata.createXMPFromPDFDocument(pdfDoc);
PDFMetadata pdfMetadata = pdfDoc.getFactory().makeMetadata(
xmp, true);
pdfDoc.getRoot().setMetadata(pdfMetadata);