You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2013/11/24 14:46:27 UTC
svn commit: r1544973 - in /pdfbox/branches/1.8: ./
examples/src/main/appended-resources/
examples/src/main/java/org/apache/pdfbox/examples/pdfa/
examples/src/main/resources/ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/
pdfbox/src/main/java/org/apach...
Author: lehmi
Date: Sun Nov 24 13:46:27 2013
New Revision: 1544973
URL: http://svn.apache.org/r1544973
Log:
PDFBOX-1564: added PDOutputIntent support including a simple sample on how to create a PDF/A
Added:
pdfbox/branches/1.8/examples/src/main/appended-resources/
- copied from r1544972, pdfbox/trunk/examples/src/main/appended-resources/
pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdfa/
- copied from r1468195, pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdfa/
pdfbox/branches/1.8/examples/src/main/resources/
- copied from r1544972, pdfbox/trunk/examples/src/main/resources/
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDOutputIntent.java
- copied unchanged from r1468195, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDOutputIntent.java
Modified:
pdfbox/branches/1.8/ (props changed)
pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java
pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
Propchange: pdfbox/branches/1.8/
------------------------------------------------------------------------------
Merged /pdfbox/trunk:r1468195,1544972
Modified: pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java?rev=1544973&r1=1468195&r2=1544973&view=diff
==============================================================================
--- pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java (original)
+++ pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdfa/CreatePDFA.java Sun Nov 24 13:46:27 2013
@@ -16,7 +16,6 @@
*/
package org.apache.pdfbox.examples.pdfa;
-import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.jempbox.xmp.XMPMetadata;
@@ -30,7 +29,6 @@ import org.apache.pdfbox.pdmodel.font.PD
import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
-
/**
* This is an example that creates a simple PDF/A document.
*
@@ -98,13 +96,7 @@ public class CreatePDFA
pdfaid.setAbout("");
metadata.importXMPMetadata(xmp);
-
- // retrieve icc
- // this file cannot be added in PDFBox, it must be downloaded
- // its localization is http://www.color.org/sRGB_IEC61966-2-1_black_scaled.icc
- // UNIX command to retrieve :
- // wget -O target/sRGB_IEC61966-2-1_black_scaled.icc http://www.color.org/sRGB_IEC61966-2-1_black_scaled.icc
- InputStream colorProfile = new FileInputStream("target/sRGB_IEC61966-2-1_black_scaled.icc");
+ InputStream colorProfile = CreatePDFA.class.getResourceAsStream("/org/apache/pdfbox/resources/pdfa/sRGB Color Space Profile.icm");
// create output intent
PDOutputIntent oi = new PDOutputIntent(doc, colorProfile);
oi.setInfo("sRGB IEC61966-2.1");
Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java?rev=1544973&r1=1544972&r2=1544973&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java Sun Nov 24 13:46:27 2013
@@ -32,6 +32,7 @@ import org.apache.pdfbox.pdmodel.common.
import org.apache.pdfbox.pdmodel.common.PDPageLabels;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDMarkInfo;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot;
+import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
import org.apache.pdfbox.pdmodel.graphics.optionalcontent.PDOptionalContentProperties;
import org.apache.pdfbox.pdmodel.interactive.action.PDActionFactory;
import org.apache.pdfbox.pdmodel.interactive.action.PDDocumentCatalogAdditionalActions;
@@ -444,6 +445,56 @@ public class PDDocumentCatalog implement
}
/**
+ * Get the list of OutputIntents defined in the document.
+ *
+ * @return The list of PDOoutputIntent
+ */
+ public List<PDOutputIntent> getOutputIntent () {
+ List<PDOutputIntent> retval = new ArrayList<PDOutputIntent>();
+ COSArray array = (COSArray)root.getItem(COSName.OUTPUT_INTENTS);
+ if (array!=null) {
+ for (COSBase cosBase : array)
+ {
+ PDOutputIntent oi = new PDOutputIntent((COSStream)cosBase);
+ retval.add(oi);
+ }
+ }
+ return retval;
+ }
+
+ /**
+ * Add an OutputIntent to the list.
+ *
+ * If there is not OutputIntent, the list is created and the first
+ * element added.
+ *
+ * @param outputIntent the OutputIntent to add.
+ */
+ public void addOutputIntent (PDOutputIntent outputIntent) {
+ COSArray array = (COSArray)root.getItem(COSName.OUTPUT_INTENTS);
+ if (array==null) {
+ array = new COSArray();
+ root.setItem(COSName.OUTPUT_INTENTS, array);
+ }
+ array.add(outputIntent.getCOSObject());
+ }
+
+ /**
+ * Replace the list of OutputIntents of the document.
+ *
+ * @param outputIntents the list of OutputIntents, if the list is empty all
+ * OutputIntents are removed.
+ */
+ public void setOutputIntents (List<PDOutputIntent> outputIntents) {
+ COSArray array = new COSArray();
+ for (PDOutputIntent intent : outputIntents)
+ {
+ array.add(intent.getCOSObject());
+ }
+ root.setItem(COSName.OUTPUT_INTENTS, array);
+ }
+
+ /**
* Set the page display mode, see the PAGE_MODE_XXX constants.
* @return A string representing the page mode.
*/