You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/06/14 16:34:31 UTC

svn commit: r414272 [2/2] - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/pdf/ src/java/org/apache/fop/render/ src/java/org/apache/fop/render/pdf/ src/java/org/apache/fop/svg/

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=414272&r1=414271&r2=414272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java Wed Jun 14 07:34:29 2006
@@ -22,7 +22,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.net.URL;
 import java.awt.Color;
 import java.awt.color.ColorSpace;
 import java.awt.color.ICC_Profile;
@@ -32,6 +32,9 @@
 import java.util.Map;
 import java.util.List;
 
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
 // XML
 import org.w3c.dom.Document;
 
@@ -68,10 +71,12 @@
 import org.apache.fop.pdf.PDFAMode;
 import org.apache.fop.pdf.PDFAnnotList;
 import org.apache.fop.pdf.PDFColor;
+import org.apache.fop.pdf.PDFConformanceException;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFEncryptionManager;
 import org.apache.fop.pdf.PDFEncryptionParams;
 import org.apache.fop.pdf.PDFFilterList;
+import org.apache.fop.pdf.PDFICCBasedColorSpace;
 import org.apache.fop.pdf.PDFICCStream;
 import org.apache.fop.pdf.PDFInfo;
 import org.apache.fop.pdf.PDFLink;
@@ -85,6 +90,7 @@
 import org.apache.fop.pdf.PDFState;
 import org.apache.fop.pdf.PDFStream;
 import org.apache.fop.pdf.PDFText;
+import org.apache.fop.pdf.PDFXMode;
 import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.Graphics2DAdapter;
@@ -118,6 +124,9 @@
      */
     public static final String MIME_TYPE = MimeConstants.MIME_PDF;
 
+    /** Normal PDF resolution (72dpi) */
+    public static final int NORMAL_PDF_RESOLUTION = 72;
+    
     /** PDF encryption parameter: all parameters as object, datatype: PDFEncryptionParams */
     public static final String ENCRYPTION_PARAMS = "encryption-params";
     /** PDF encryption parameter: user password, datatype: String */
@@ -134,6 +143,10 @@
     public static final String NO_ANNOTATIONS = "noannotations";
     /** Rendering Options key for the PDF/A mode. */
     public static final String PDF_A_MODE = "pdf-a-mode";
+    /** Rendering Options key for the PDF/X mode. */
+    public static final String PDF_X_MODE = "pdf-x-mode";
+    /** Rendering Options key for the ICC profile for the output intent. */
+    public static final String KEY_OUTPUT_PROFILE = "output-profile";
 
     /** Controls whether comments are written to the PDF stream. */
     protected static final boolean WRITE_COMMENTS = true;
@@ -146,6 +159,9 @@
     /** the PDF/A mode (Default: disabled) */
     protected PDFAMode pdfAMode = PDFAMode.DISABLED;
     
+    /** the PDF/X mode (Default: disabled) */
+    protected PDFXMode pdfXMode = PDFXMode.DISABLED;
+    
     /**
      * Map of pages using the PageViewport as the key
      * this is used for prepared pages that cannot be immediately
@@ -190,6 +206,16 @@
     
     /** the (optional) encryption parameters */
     protected PDFEncryptionParams encryptionParams;
+
+    /** the ICC stream used as output profile by this document for PDF/A and PDF/X functionality. */
+    protected PDFICCStream outputProfile;
+    /** the ICC stream for the sRGB color space. */
+    //protected PDFICCStream sRGBProfile;
+    /** the default sRGB color space. */
+    protected PDFICCBasedColorSpace sRGBColorSpace;
+    
+    /** Optional URI to an output profile to be used. */
+    protected String outputProfileURI; 
     
     /** The current Transform */
     protected AffineTransform currentBasicTransform;
@@ -267,6 +293,14 @@
         if (s != null) {
             this.pdfAMode = PDFAMode.valueOf(s);
         }
+        s = cfg.getChild(PDF_X_MODE, true).getValue(null);
+        if (s != null) {
+            this.pdfXMode = PDFXMode.valueOf(s);
+        }
+        s = cfg.getChild(KEY_OUTPUT_PROFILE, true).getValue(null);
+        if (s != null) {
+            this.outputProfileURI = s;
+        }
     }
 
     private boolean booleanValueOf(Object obj) {
@@ -337,6 +371,14 @@
         if (s != null) {
             this.pdfAMode = PDFAMode.valueOf(s);
         }
+        s = (String)agent.getRendererOptions().get(PDF_X_MODE);
+        if (s != null) {
+            this.pdfXMode = PDFXMode.valueOf(s);
+        }
+        s = (String)agent.getRendererOptions().get(KEY_OUTPUT_PROFILE);
+        if (s != null) {
+            this.outputProfileURI = s;
+        }
     }
 
     /**
@@ -349,7 +391,8 @@
         ostream = stream;
         this.pdfDoc = new PDFDocument(
                 userAgent.getProducer() != null ? userAgent.getProducer() : "");
-        this.pdfDoc.setPDFAMode(this.pdfAMode);
+        this.pdfDoc.getProfile().setPDFAMode(this.pdfAMode);
+        this.pdfDoc.getProfile().setPDFXMode(this.pdfXMode);
         this.pdfDoc.setCreator(userAgent.getCreator());
         this.pdfDoc.setCreationDate(userAgent.getCreationDate());
         this.pdfDoc.getInfo().setAuthor(userAgent.getAuthor());
@@ -358,25 +401,32 @@
         this.pdfDoc.setFilterMap(filterMap);
         this.pdfDoc.outputHeader(stream);
 
+        //Setup encryption if necessary
+        PDFEncryptionManager.setupPDFEncryption(encryptionParams, this.pdfDoc);
+
+        addsRGBColorSpace();
+        if (this.outputProfileURI != null) {
+            addDefaultOutputProfile();
+        }
+        if (pdfXMode != PDFXMode.DISABLED) {
+            log.debug(pdfXMode + " is active.");
+            log.warn("Note: " + pdfXMode 
+                    + " support is work-in-progress and not fully implemented, yet!");
+            addPDFXOutputIntent();
+        }
         if (pdfAMode.isPDFA1LevelB()) {
             log.debug("PDF/A is active. Conformance Level: " + pdfAMode);
             addPDFA1OutputIntent();
         }
         
-        //Setup encryption if necessary
-        PDFEncryptionManager.setupPDFEncryption(encryptionParams, this.pdfDoc);
     }
 
-    /**
-     * Adds an OutputIntent to the PDF as mandated by PDF/A-1 when uncalibrated color spaces
-     * are used (which is true if we use DeviceRGB to represent sRGB colors).
-     * @throws IOException in case of an I/O problem
-     */
-    private void addPDFA1OutputIntent() throws IOException {
-        PDFOutputIntent outputIntent = pdfDoc.getFactory().makeOutputIntent();
-        outputIntent.setSubtype(PDFOutputIntent.GTS_PDFA1);
-        PDFICCStream icc = pdfDoc.getFactory().makePDFICCStream();
+    private void addsRGBColorSpace() throws IOException {
+        if (this.sRGBColorSpace != null) {
+            return;
+        }
         ICC_Profile profile;
+        PDFICCStream sRGBProfile = pdfDoc.getFactory().makePDFICCStream();
         InputStream in = PDFDocument.class.getResourceAsStream("sRGB Color Space Profile.icm");
         if (in != null) {
             try {
@@ -388,10 +438,77 @@
             //Fallback: Use the sRGB profile from the JRE (about 140KB)
             profile = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
         }
-        String desc = ColorProfileUtil.getICCProfileDescription(profile);
+        sRGBProfile.setColorSpace(profile, null);
         
-        icc.setColorSpace(profile, null);
-        outputIntent.setDestOutputProfile(icc);
+        //Map sRGB as default RGB profile for DeviceRGB
+        this.sRGBColorSpace = pdfDoc.getFactory().makeICCBasedColorSpace(
+                null, "DefaultRGB", sRGBProfile);
+    }
+    
+    private void addDefaultOutputProfile() throws IOException {
+        if (this.outputProfile != null) {
+            return;
+        }
+        ICC_Profile profile;
+        InputStream in = null;
+        if (this.outputProfileURI != null) {
+            this.outputProfile = pdfDoc.getFactory().makePDFICCStream();
+            Source src = userAgent.resolveURI(this.outputProfileURI);
+            if (src == null) {
+                throw new IOException("Output profile not found: " + this.outputProfileURI);
+            }
+            if (src instanceof StreamSource) {
+                in = ((StreamSource)src).getInputStream();
+            } else {
+                in = new URL(src.getSystemId()).openStream();
+            }
+            try {
+                profile = ICC_Profile.getInstance(in);
+            } finally {
+                IOUtils.closeQuietly(in);
+            }
+            this.outputProfile.setColorSpace(profile, null);
+        } else {
+            //Fall back to sRGB profile
+            outputProfile = sRGBColorSpace.getICCStream();
+        }
+    }
+    
+    /**
+     * Adds an OutputIntent to the PDF as mandated by PDF/A-1 when uncalibrated color spaces
+     * are used (which is true if we use DeviceRGB to represent sRGB colors).
+     * @throws IOException in case of an I/O problem
+     */
+    private void addPDFA1OutputIntent() throws IOException {
+        addDefaultOutputProfile();
+        
+        String desc = ColorProfileUtil.getICCProfileDescription(this.outputProfile.getICCProfile());
+        PDFOutputIntent outputIntent = pdfDoc.getFactory().makeOutputIntent();
+        outputIntent.setSubtype(PDFOutputIntent.GTS_PDFA1);
+        outputIntent.setDestOutputProfile(this.outputProfile);
+        outputIntent.setOutputConditionIdentifier(desc);
+        outputIntent.setInfo(outputIntent.getOutputConditionIdentifier());
+        pdfDoc.getRoot().addOutputIntent(outputIntent);
+    }
+
+    /**
+     * Adds an OutputIntent to the PDF as mandated by PDF/X when uncalibrated color spaces
+     * are used (which is true if we use DeviceRGB to represent sRGB colors).
+     * @throws IOException in case of an I/O problem
+     */
+    private void addPDFXOutputIntent() throws IOException {
+        addDefaultOutputProfile();
+        
+        String desc = ColorProfileUtil.getICCProfileDescription(this.outputProfile.getICCProfile());
+        int deviceClass = this.outputProfile.getICCProfile().getProfileClass();
+        if (deviceClass != ICC_Profile.CLASS_OUTPUT) {
+            throw new PDFConformanceException(pdfDoc.getProfile().getPDFXMode() + " requires that"
+                    + " the DestOutputProfile be an Output Device Profile. "
+                    + desc + " does not match that requirement.");
+        }
+        PDFOutputIntent outputIntent = pdfDoc.getFactory().makeOutputIntent();
+        outputIntent.setSubtype(PDFOutputIntent.GTS_PDFX);
+        outputIntent.setDestOutputProfile(this.outputProfile);
         outputIntent.setOutputConditionIdentifier(desc);
         outputIntent.setInfo(outputIntent.getOutputConditionIdentifier());
         pdfDoc.getRoot().addOutputIntent(outputIntent);
@@ -1015,36 +1132,40 @@
         // render contents
         super.renderInlineParent(ip);
 
-        // place the link over the top
-        Object tr = ip.getTrait(Trait.INTERNAL_LINK);
-        boolean internal = false;
-        String dest = null;
-        float yoffset = 0;
-        if (tr == null) {
-            dest = (String)ip.getTrait(Trait.EXTERNAL_LINK);
-        } else {
-            String pvKey = (String)tr;
-            dest = (String)pageReferences.get(pvKey);
+        if (pdfDoc.getProfile().isAnnotationAllowed()) {
+            // place the link over the top
+            Object tr = ip.getTrait(Trait.INTERNAL_LINK);
+            boolean internal = false;
+            String dest = null;
+            float yoffset = 0;
+            if (tr == null) {
+                dest = (String)ip.getTrait(Trait.EXTERNAL_LINK);
+            } else {
+                String pvKey = (String)tr;
+                dest = (String)pageReferences.get(pvKey);
+                if (dest != null) {
+                    PageViewport pv = (PageViewport)pvReferences.get(pvKey);
+                    Rectangle2D bounds = pv.getViewArea();
+                    double h = bounds.getHeight();
+                    yoffset = (float)h / 1000f;
+                    internal = true;
+                }
+            }
             if (dest != null) {
-                PageViewport pv = (PageViewport)pvReferences.get(pvKey);
-                Rectangle2D bounds = pv.getViewArea();
-                double h = bounds.getHeight();
-                yoffset = (float)h / 1000f;
-                internal = true;
-            }
-        }
-        if (dest != null) {
-            // add link to pdf document
-            Rectangle2D rect = new Rectangle2D.Float(start, top, width, height);
-            // transform rect to absolute coords
-            AffineTransform transform = currentState.getTransform();
-            rect = transform.createTransformedShape(rect).getBounds2D();
-            rect = currentBasicTransform.createTransformedShape(rect).getBounds2D();
-
-            int type = internal ? PDFLink.INTERNAL : PDFLink.EXTERNAL;
-            PDFLink pdflink = pdfDoc.getFactory().makeLink(
-                        rect, dest, type, yoffset);
-            currentPage.addAnnotation(pdflink);
+                // add link to pdf document
+                Rectangle2D rect = new Rectangle2D.Float(start, top, width, height);
+                // transform rect to absolute coords
+                AffineTransform transform = currentState.getTransform();
+                rect = transform.createTransformedShape(rect).getBounds2D();
+                rect = currentBasicTransform.createTransformedShape(rect).getBounds2D();
+
+                int type = internal ? PDFLink.INTERNAL : PDFLink.EXTERNAL;
+                PDFLink pdflink = pdfDoc.getFactory().makeLink(
+                            rect, dest, type, yoffset);
+                currentPage.addAnnotation(pdflink);
+            }
+        } else {
+            log.warn("Skipping annotation for a link due to PDF profile: " + pdfDoc.getProfile());
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java?rev=414272&r1=414271&r2=414272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java Wed Jun 14 07:34:29 2006
@@ -18,7 +18,9 @@
 
 package org.apache.fop.render.pdf;
 
+import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Map;
 import java.awt.Color;
 import java.awt.geom.AffineTransform;
 
@@ -26,9 +28,10 @@
 import org.w3c.dom.svg.SVGDocument;
 import org.w3c.dom.svg.SVGSVGElement;
 
+import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
-import org.apache.fop.render.XMLHandler;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFNumber;
 import org.apache.fop.pdf.PDFPage;
@@ -38,6 +41,8 @@
 import org.apache.fop.svg.PDFBridgeContext;
 import org.apache.fop.svg.PDFGraphics2D;
 import org.apache.fop.svg.SVGUserAgent;
+import org.apache.fop.util.QName;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.FontInfo;
 
 // Commons-Logging
@@ -49,7 +54,6 @@
 import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.ViewBox;
-import org.apache.batik.dom.svg.SVGDOMImplementation;
 import org.apache.batik.gvt.GraphicsNode;
 
 /**
@@ -58,29 +62,12 @@
  * It renders SVG to the PDF document using the PDFGraphics2D.
  * The properties from the PDF renderer are subject to change.
  */
-public class PDFSVGHandler implements XMLHandler, PDFRendererContextConstants {
+public class PDFSVGHandler extends AbstractGenericSVGHandler 
+            implements PDFRendererContextConstants {
 
     /** logging instance */
     private static Log log = LogFactory.getLog(PDFSVGHandler.class);
 
-
-    /**
-     * Create a new PDF XML handler for use by the PDF renderer.
-     */
-    public PDFSVGHandler() {
-    }
-
-    /** @see org.apache.fop.render.XMLHandler */
-    public void handleXML(RendererContext context, 
-                Document doc, String ns) throws Exception {
-        PDFInfo pdfi = getPDFInfo(context);
-
-        String svg = "http://www.w3.org/2000/svg";
-        if (svg.equals(ns)) {
-            renderSVGDocument(context, doc, pdfi);
-        }
-    }
-
     /**
      * Get the pdf information from the render context.
      *
@@ -103,6 +90,12 @@
         pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue();
         pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue();
         pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION);
+        Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
+        QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
+        if (foreign != null 
+                && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) {
+            pdfi.paintAsBitmap = true;
+        }
         return pdfi;
     }
 
@@ -138,16 +131,26 @@
         public int currentYPosition;
         /** see PDF_HANDLER_CONFIGURATION */
         public Configuration cfg;
+        /** true if SVG should be rendered as a bitmap instead of natively */
+        public boolean paintAsBitmap;
     }
 
     /**
-     * Render the svg document.
-     * @param context the renderer context
-     * @param doc the svg document
-     * @param pdfInfo the pdf information of the current context
+     * @see org.apache.fop.render.AbstractGenericSVGHandler#renderSVGDocument(
+     *          org.apache.fop.render.RendererContext, org.w3c.dom.Document)
      */
     protected void renderSVGDocument(RendererContext context,
-            Document doc, PDFInfo pdfInfo) {
+            Document doc) {
+        PDFInfo pdfInfo = getPDFInfo(context);
+        if (pdfInfo.paintAsBitmap) {
+            try {
+                super.renderSVGDocument(context, doc);
+            } catch (IOException ioe) {
+                log.error("I/O error while rendering SVG graphic: "
+                                       + ioe.getMessage(), ioe);
+            }
+            return;
+        }
         int xOffset = pdfInfo.currentXPosition;
         int yOffset = pdfInfo.currentYPosition;
 
@@ -262,9 +265,4 @@
     public boolean supportsRenderer(Renderer renderer) {
         return (renderer instanceof PDFRenderer);
     }
-    /** @see org.apache.fop.render.XMLHandler#getNamespace() */
-    public String getNamespace() {
-        return SVGDOMImplementation.SVG_NAMESPACE_URI;
-    }
-    
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=414272&r1=414271&r2=414272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java Wed Jun 14 07:34:29 2006
@@ -22,7 +22,7 @@
 import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFResources;
 import org.apache.fop.pdf.PDFGState;
-import org.apache.fop.pdf.PDFColorSpace;
+import org.apache.fop.pdf.PDFDeviceColorSpace;
 import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.pdf.PDFState;
 import org.apache.fop.pdf.PDFNumber;
@@ -352,6 +352,9 @@
      * @param linkType the type of link, internal or external
      */
     public void addLink(Rectangle2D bounds, AffineTransform trans, String dest, int linkType) {
+        if (!pdfDoc.getProfile().isAnnotationAllowed()) {
+            return;
+        }
         preparePainting();
         AffineTransform at = getTransform();
         Shape b = at.createTransformedShape(bounds);
@@ -563,7 +566,7 @@
                 BitmapImage fopimg = new BitmapImage("TempImageMask:"
                                              + img.toString(), buf.getWidth(),
                                              buf.getHeight(), mask, null);
-                fopimg.setColorSpace(new PDFColorSpace(PDFColorSpace.DEVICE_GRAY));
+                fopimg.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
                 PDFXObject xobj = pdfDoc.addImage(resourceContext, fopimg);
                 ref = xobj.referencePDF();
 
@@ -693,12 +696,12 @@
         }
 
         if (c.getAlpha() != 255) {
+            checkTransparencyAllowed();
             Map vals = new java.util.HashMap();
             vals.put(PDFGState.GSTATE_ALPHA_STROKE, 
                     new Float(c.getAlpha() / 255f));
             PDFGState gstate = pdfDoc.getFactory().makeGState(
                     vals, graphicsState.getGState());
-            //gstate.setAlpha(c.getAlpha() / 255f, false);
             resourceContext.addGState(gstate);
             currentStream.write("/" + gstate.getName() + " gs\n");
         }
@@ -815,7 +818,7 @@
             currentStream.write(currentColour.getColorSpaceOut(fill));
         } else if (c.getColorSpace().getType()
                    == ColorSpace.TYPE_CMYK) {
-            if (pdfDoc.getPDFAMode().isPDFA1LevelB()) {
+            if (pdfDoc.getProfile().getPDFAMode().isPDFA1LevelB()) {
                 //See PDF/A-1, ISO 19005:1:2005(E), 6.2.3.3
                 //FOP is currently restricted to DeviceRGB if PDF/A-1 is active.
                 throw new PDFConformanceException(
@@ -944,8 +947,8 @@
                 }
             }
 
-            PDFColorSpace aColorSpace;
-            aColorSpace = new PDFColorSpace(PDFColorSpace.DEVICE_RGB);
+            PDFDeviceColorSpace aColorSpace;
+            aColorSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
             PDFPattern myPat = pdfDoc.getFactory().makeGradient(
                     resourceContext, false, aColorSpace,
                     someColors, theBounds, theCoords, theMatrix);
@@ -1021,8 +1024,8 @@
                 float offset = fractions[count];
                 theBounds.add(new Double(offset));
             }
-            PDFColorSpace colSpace;
-            colSpace = new PDFColorSpace(PDFColorSpace.DEVICE_RGB);
+            PDFDeviceColorSpace colSpace;
+            colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
 
             PDFPattern myPat = pdfDoc.getFactory().makeGradient
                 (resourceContext, true, colSpace,
@@ -1221,7 +1224,7 @@
             if (mask != null) {
                 BitmapImage fopimg = new BitmapImage
                     ("TempImageMask:" + pctx.toString(), devW, devH, mask, null);
-                fopimg.setColorSpace(new PDFColorSpace(PDFColorSpace.DEVICE_GRAY));
+                fopimg.setColorSpace(new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY));
                 PDFXObject xobj = pdfDoc.addImage(resourceContext, fopimg);
                 maskRef = xobj.referencePDF();
 
@@ -1439,6 +1442,7 @@
         int salpha = c.getAlpha();
 
         if (salpha != 255) {
+            checkTransparencyAllowed();
             Map vals = new java.util.HashMap();
             vals.put(PDFGState.GSTATE_ALPHA_NONSTROKE, new Float(salpha / 255f));
             PDFGState gstate = pdfDoc.getFactory().makeGState(
@@ -1687,6 +1691,7 @@
         }
 
         if (c.getAlpha() != 255) {
+            checkTransparencyAllowed();
             Map vals = new java.util.HashMap();
             vals.put(PDFGState.GSTATE_ALPHA_NONSTROKE, 
                     new Float(c.getAlpha() / 255f));
@@ -1728,6 +1733,11 @@
             currentStream.write("Q\n");
             graphicsState.pop();
         }
+    }
+
+    /** Checks whether the use of transparency is allowed. */
+    protected void checkTransparencyAllowed() {
+        pdfDoc.getProfile().verifyTransparencyAllowed("Java2D graphics");
     }
 
     /**

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=414272&r1=414271&r2=414272&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Jun 14 07:34:29 2006
@@ -27,6 +27,14 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add">
+        Added support for PDF/A-1b and PDF/X-3:2003. (Note: this may still be a bit
+        incomplete. Feedback is welcome!)
+      </action>
+      <action context="Code" dev="JM" type="add">
+        The CIDSet object is now generated for CID fonts which are embedded in PDFs.
+        (Required by PDF/A).
+      </action>
       <action context="Code" dev="JM" type="update">
         The Java2DRenderer (and therefore the print and bitmap renderers) is now
         offering the same quality as the PDF and PS renderers. Note: There can still



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org