diff options
author | Jeremias Maerki <jeremias@apache.org> | 2009-04-17 13:07:29 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2009-04-17 13:07:29 +0000 |
commit | 218fa1d72a0f14273d8621047687da7f0ab2b49e (patch) | |
tree | e323fc6458f465e865280cf06d1ee2e5f9107bba /src/java/org/apache/fop/pdf | |
parent | 8eefdf7d68cc640ca4c3d4ac331e5af1a9049ee0 (diff) | |
download | xmlgraphics-fop-218fa1d72a0f14273d8621047687da7f0ab2b49e.tar.gz xmlgraphics-fop-218fa1d72a0f14273d8621047687da7f0ab2b49e.zip |
Enabled support for PDF/A-1a now that we have Tagged PDF, Natural Language Specification and alternate descriptions (fox:alt-text).
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@765979 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFAMode.java | 13 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFProfile.java | 29 | ||||
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFRoot.java | 18 |
3 files changed, 55 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFAMode.java b/src/java/org/apache/fop/pdf/PDFAMode.java index 1b433e66d..18c4a2489 100644 --- a/src/java/org/apache/fop/pdf/PDFAMode.java +++ b/src/java/org/apache/fop/pdf/PDFAMode.java @@ -44,7 +44,18 @@ public final class PDFAMode { return this.name; } - /** @return true if this mode obey the restrictions established by PDF/A-1b. */ + /** + * Indicates whether this mode obeys the restrictions established by PDF/A-1a. + * @return true if this mode obeys the restrictions established by PDF/A-1a. + */ + public boolean isPDFA1LevelA() { + return (this != DISABLED); + } + + /** + * Indicates whether this mode obeys the restrictions established by PDF/A-1b. + * @return true if this mode obeys the restrictions established by PDF/A-1b. + */ public boolean isPDFA1LevelB() { return (this != DISABLED); //PDF/A-1a is a superset of PDF/A-1b! diff --git a/src/java/org/apache/fop/pdf/PDFProfile.java b/src/java/org/apache/fop/pdf/PDFProfile.java index 20af4e212..b645cb825 100644 --- a/src/java/org/apache/fop/pdf/PDFProfile.java +++ b/src/java/org/apache/fop/pdf/PDFProfile.java @@ -58,9 +58,6 @@ public class PDFProfile { */ protected void validateProfileCombination() { if (pdfAMode != PDFAMode.DISABLED) { - if (pdfAMode == PDFAMode.PDFA_1A) { - throw new UnsupportedOperationException("PDF/A-1a is not implemented, yet"); - } if (pdfAMode == PDFAMode.PDFA_1B) { if (pdfXMode != PDFXMode.DISABLED && pdfXMode != PDFXMode.PDFX_3_2003) { throw new PDFConformanceException( @@ -192,6 +189,32 @@ public class PDFProfile { } } + /** + * Checks a few things required for tagged PDF. + */ + public void verifyTaggedPDF() { + if (getPDFAMode().isPDFA1LevelA()) { + final String err = "{0} requires the {1} dictionary entry to be set"; + PDFDictionary markInfo = getDocument().getRoot().getMarkInfo(); + if (markInfo == null) { + throw new PDFConformanceException(format( + "{0} requires the MarkInfo dictionary to be present", getPDFAMode())); + } + if (!Boolean.TRUE.equals(markInfo.get("Marked"))) { + throw new PDFConformanceException(format(err, + new Object[] {getPDFAMode(), "Marked"})); + } + if (getDocument().getRoot().getStructTreeRoot() == null) { + throw new PDFConformanceException(format(err, + new Object[] {getPDFAMode(), "StructTreeRoot"})); + } + if (getDocument().getRoot().getLanguage() == null) { + throw new PDFConformanceException(format(err, + new Object[] {getPDFAMode(), "Lang"})); + } + } + } + /** @return true if the ID entry must be present in the trailer. */ public boolean isIDEntryRequired() { return isPDFAActive() || isPDFXActive(); diff --git a/src/java/org/apache/fop/pdf/PDFRoot.java b/src/java/org/apache/fop/pdf/PDFRoot.java index c8d94585c..3057a9e4d 100644 --- a/src/java/org/apache/fop/pdf/PDFRoot.java +++ b/src/java/org/apache/fop/pdf/PDFRoot.java @@ -19,6 +19,9 @@ package org.apache.fop.pdf; +import java.io.IOException; +import java.io.OutputStream; + /** * Class representing a Root (/Catalog) object. */ @@ -56,7 +59,7 @@ public class PDFRoot extends PDFDictionary { * object must be created before the PDF document is * generated, but it is not assigned an object ID until * it is about to be written (immediately before the xref - * table as part of the trsailer). (mark-fop@inomial.com) + * table as part of the trailer). (mark-fop@inomial.com) * * @param objnum the object's number * @param pages the PDFPages object @@ -68,6 +71,12 @@ public class PDFRoot extends PDFDictionary { setRootPages(pages); } + /** {@inheritDoc} */ + protected int output(OutputStream stream) throws IOException { + getDocument().getProfile().verifyTaggedPDF(); + return super.output(stream); + } + /** * Set the page mode for the PDF document. * @@ -280,4 +289,11 @@ public class PDFRoot extends PDFDictionary { put("MarkInfo", dict); //new PDFMarkInfo() } + /** + * Returns the MarkInfo dictionary. + * @return the MarkInfo dictionary (or null if it's not present) + */ + public PDFDictionary getMarkInfo() { + return (PDFDictionary)get("MarkInfo"); + } } |