pietsch     2003/09/19 09:46:43

  Modified:    src/java/org/apache/fop/render Renderer.java
                        AbstractRenderer.java
               src/java/org/apache/fop/pdf PDFDocument.java
               src/java/org/apache/fop/render/pdf PDFRenderer.java
  Log:
  Add possibility to set creation date.
  
  Revision  Changes    Path
  1.5       +13 -2     xml-fop/src/java/org/apache/fop/render/Renderer.java
  
  Index: Renderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/Renderer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Renderer.java     22 Aug 2003 17:42:42 -0000      1.4
  +++ Renderer.java     19 Sep 2003 16:46:43 -0000      1.5
  @@ -53,6 +53,7 @@
   // Java
   import java.io.OutputStream;
   import java.io.IOException;
  +import java.util.Date;
   import java.util.Map;
   
   // FOP
  @@ -142,13 +143,23 @@
       void setProducer(String producer);
   
       /**
  -     * Set the creator of the document to be rendered. If this method
  -     * isn't called the renderer uses a default.
  +     * Set the creator of the document to be rendered.
  +     * If this method isn't called the renderer uses a default.
        * Note: Not all renderers support this feature.
        *
        * @param creator  The name of the document creator
        */
       void setCreator(String creator);
  +    
  +    /**
  +     * Set the creator date/timeof the document to be rendered.
  +     * If this method isn't called the renderer uses the current date/time
  +     * as default.
  +     * Note: Not all renderers support this feature.
  +     *
  +     * @param date The name of the document creator
  +     */
  +    void setCreationDate(Date date);
   
       /**
        * Reports if out of order rendering is supported. <p>
  
  
  
  1.15      +19 -2     xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java
  
  Index: AbstractRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AbstractRenderer.java     14 Sep 2003 19:32:44 -0000      1.14
  +++ AbstractRenderer.java     19 Sep 2003 16:46:43 -0000      1.15
  @@ -54,6 +54,7 @@
   import java.awt.geom.Rectangle2D;
   import java.io.IOException;
   import java.io.OutputStream;
  +import java.util.Date;
   import java.util.Map;
   import java.util.List;
   import java.util.Iterator;
  @@ -125,6 +126,11 @@
       protected String creator = null;
   
       /**
  +     * creation time
  +     */
  +    protected Date creationDate = null;
  +
  +    /**
        * renderer configuration
        */
       protected Map options;
  @@ -172,12 +178,23 @@
           creator = inCreator;
       }
   
  -    /** @see org.apache.fop.render.Renderer */
  +    /**
  +     *  @see org.apache.fop.render.Renderer
  +     */
       public abstract void setupFontInfo(FOTreeControl foTreeControl);
   
  -    /** @see org.apache.fop.render.Renderer */
  +    /**
  +     *  @see org.apache.fop.render.Renderer
  +     */
       public void setUserAgent(FOUserAgent agent) {
           userAgent = agent;
  +    }
  +
  +    /**
  +     * @param date
  +     */
  +    public void setCreationDate(Date date) {
  +        creationDate = date;
       }
   
       /** @see org.apache.fop.render.Renderer */
  
  
  
  1.6       +76 -47    xml-fop/src/java/org/apache/fop/pdf/PDFDocument.java
  
  Index: PDFDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/pdf/PDFDocument.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PDFDocument.java  24 Apr 2003 02:48:08 -0000      1.5
  +++ PDFDocument.java  19 Sep 2003 16:46:43 -0000      1.6
  @@ -55,6 +55,7 @@
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.io.UnsupportedEncodingException;
  +import java.util.Date;
   import java.util.List;
   import java.util.Map;
   import java.util.Iterator;
  @@ -159,7 +160,8 @@
       /**
        * the colorspace (0=RGB, 1=CMYK)
        */
  -    protected PDFColorSpace colorspace = new 
PDFColorSpace(PDFColorSpace.DEVICE_RGB);
  +    protected PDFColorSpace colorspace =
  +        new PDFColorSpace(PDFColorSpace.DEVICE_RGB);
   
       /**
        * the counter for Pattern name numbering (e.g. 'Pattern1')
  @@ -232,7 +234,6 @@
        */
       protected List gotos = new java.util.ArrayList();
   
  -
       private PDFFactory factory;
   
       private boolean encodingOnTheFly = true;
  @@ -325,10 +326,19 @@
       }
   
       /**
  -     * set the creator of the document
  -     *
  -     * @param creator string indicating application creating the document
  -     */
  +      * Set the creation date of the document.
  +      * 
  +      * @param date Date to be stored as creation date in the PDF.
  +      */
  +    public void setCreationDate(Date date) {
  +        info.setCreationDate(date);
  +    }
  +
  +    /**
  +      * Set the creator of the document.
  +      *
  +      * @param creator string indicating application creating the document
  +      */
       public void setCreator(String creator) {
           this.info.setCreator(creator);
       }
  @@ -399,13 +409,15 @@
               throw new NullPointerException("obj must not be null");
           }
           if (obj.hasObjectNumber()) {
  -            throw new IllegalStateException("Error registering a PDFObject: "
  -                + "PDFObject already has an object number");
  +            throw new IllegalStateException(
  +                "Error registering a PDFObject: "
  +                    + "PDFObject already has an object number");
           }
           PDFDocument currentParent = obj.getDocument();
           if (currentParent != null && currentParent != this) {
  -            throw new IllegalStateException("Error registering a PDFObject: "
  -                + "PDFObject already has a parent PDFDocument");
  +            throw new IllegalStateException(
  +                "Error registering a PDFObject: "
  +                    + "PDFObject already has a parent PDFDocument");
           }
   
           obj.setObjectNumber(++this.objectcount);
  @@ -425,8 +437,9 @@
               throw new NullPointerException("obj must not be null");
           }
           if (!obj.hasObjectNumber()) {
  -            throw new IllegalStateException("Error adding a PDFObject: "
  -                + "PDFObject doesn't have an object number");
  +            throw new IllegalStateException(
  +                "Error adding a PDFObject: "
  +                    + "PDFObject doesn't have an object number");
           }
   
           //Add object to list
  @@ -469,7 +482,6 @@
           }
       }
   
  -
       /**
        * Add trailer object.
        * Adds an object to the list of trailer objects.
  @@ -499,18 +511,19 @@
        * @param params The encryption parameters for the pdf file
        */
       public void setEncryption(PDFEncryptionParams params) {
  -        this.encryption = PDFEncryptionManager.newInstance(++this.objectcount, 
params);
  +        this.encryption =
  +            PDFEncryptionManager.newInstance(++this.objectcount, params);
           ((PDFObject)this.encryption).setDocument(this);
           if (encryption != null) {
               /[EMAIL PROTECTED] this cast is ugly. PDFObject should be transformed 
to an interface. */
               addTrailerObject((PDFObject)this.encryption);
           } else {
  -            getLogger().warn("PDF encryption is unavailable. PDF will be "
  -                + "generated without encryption.");
  +            getLogger().warn(
  +                "PDF encryption is unavailable. PDF will be "
  +                    + "generated without encryption.");
           }
       }
   
  -
       /**
        * Indicates whether encryption is active for this PDF or not.
        * @return boolean True if encryption is active
  @@ -681,7 +694,7 @@
        * @return the InputStream from the URI.
        */
       protected InputStream resolveURI(String uri)
  -                throws java.io.FileNotFoundException {
  +        throws java.io.FileNotFoundException {
           try {
               /[EMAIL PROTECTED] Temporary hack to compile, improve later */
               return new java.net.URL(uri).openStream();
  @@ -691,7 +704,6 @@
           }
       }
   
  -
       /**
        * Get an image from the image map.
        *
  @@ -727,8 +739,7 @@
           // setup image
           img.setup(this);
           // create a new XObject
  -        xObject = new PDFXObject(++this.xObjectCount,
  -                                 img);
  +        xObject = new PDFXObject(++this.xObjectCount, img);
           registerObject(xObject);
           this.resources.addXObject(xObject);
           if (res != null) {
  @@ -750,11 +761,17 @@
        * @param key the key for the object
        * @return the PDF Form XObject that references the PDF data
        */
  -    public PDFFormXObject addFormXObject(PDFResourceContext res, PDFStream cont,
  -                                         PDFResources formres, String key) {
  +    public PDFFormXObject addFormXObject(
  +        PDFResourceContext res,
  +        PDFStream cont,
  +        PDFResources formres,
  +        String key) {
           PDFFormXObject xObject;
  -        xObject = new PDFFormXObject(++this.xObjectCount,
  -                                 cont, formres.referencePDF());
  +        xObject =
  +            new PDFFormXObject(
  +                ++this.xObjectCount,
  +                cont,
  +                formres.referencePDF());
           registerObject(xObject);
           this.resources.addXObject(xObject);
           if (res != null) {
  @@ -841,8 +858,7 @@
        * @param stream the OutputStream to write the header to
        * @throws IOException if there is an exception writing to the output stream
        */
  -    public void outputHeader(OutputStream stream)
  -                throws IOException {
  +    public void outputHeader(OutputStream stream) throws IOException {
           this.position = 0;
   
           byte[] pdf = ("%PDF-" + PDF_VERSION + "\n").getBytes();
  @@ -850,10 +866,14 @@
           this.position += pdf.length;
   
           // output a binary comment as recommended by the PDF spec (3.4.1)
  -        byte[] bin = {
  -            (byte)'%', (byte)0xAA, (byte)0xAB, (byte)0xAC, (byte)0xAD,
  -            (byte)'\n'
  -        };
  +        byte[] bin =
  +            {
  +                (byte)'%',
  +                (byte)0xAA,
  +                (byte)0xAB,
  +                (byte)0xAC,
  +                (byte)0xAD,
  +                (byte)'\n' };
           stream.write(bin);
           this.position += bin.length;
       }
  @@ -864,13 +884,13 @@
        * @param stream the OutputStream to write the trailer to
        * @throws IOException if there is an exception writing to the output stream
        */
  -    public void outputTrailer(OutputStream stream)
  -                throws IOException {
  +    public void outputTrailer(OutputStream stream) throws IOException {
           output(stream);
           for (int count = 0; count < trailerObjects.size(); count++) {
  -            PDFObject o = (PDFObject) trailerObjects.get(count);
  -            this.location.set(o.getObjectNumber() - 1,
  -                              new Integer(this.position));
  +            PDFObject o = (PDFObject)trailerObjects.get(count);
  +            this.location.set(
  +                o.getObjectNumber() - 1,
  +                new Integer(this.position));
               this.position += o.output(stream);
           }
           /* output the xref table and increment the character position
  @@ -884,13 +904,24 @@
           }
   
           /* construct the trailer */
  -        String pdf = "trailer\n" + "<<\n"
  -                     + "/Size " + (this.objectcount + 1) + "\n"
  -                     + "/Root " + this.root.referencePDF() + "\n"
  -                     + "/Info " + this.info.referencePDF() + "\n"
  -                     + encryptEntry
  -                     + ">>\n" + "startxref\n" + this.xref
  -                     + "\n" + "%%EOF\n";
  +        String pdf =
  +            "trailer\n"
  +                + "<<\n"
  +                + "/Size "
  +                + (this.objectcount + 1)
  +                + "\n"
  +                + "/Root "
  +                + this.root.referencePDF()
  +                + "\n"
  +                + "/Info "
  +                + this.info.referencePDF()
  +                + "\n"
  +                + encryptEntry
  +                + ">>\n"
  +                + "startxref\n"
  +                + this.xref
  +                + "\n"
  +                + "%%EOF\n";
   
           /* write the trailer */
           stream.write(encode(pdf));
  @@ -909,9 +940,8 @@
   
           /* construct initial part of xref */
           StringBuffer pdf = new StringBuffer(128);
  -        pdf.append("xref\n0 "
  -            + (this.objectcount + 1)
  -            + "\n0000000000 65535 f \n");
  +        pdf.append(
  +            "xref\n0 " + (this.objectcount + 1) + "\n0000000000 65535 f \n");
   
           for (int count = 0; count < this.location.size(); count++) {
               String x = this.location.get(count).toString();
  @@ -931,4 +961,3 @@
       }
   
   }
  -
  
  
  
  1.17      +1 -0      xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- PDFRenderer.java  1 Sep 2003 14:19:34 -0000       1.16
  +++ PDFRenderer.java  19 Sep 2003 16:46:43 -0000      1.17
  @@ -271,6 +271,7 @@
           this.pdfDoc = new PDFDocument(producer);
           setupLogger(this.pdfDoc);
           this.pdfDoc.setCreator(creator);
  +        this.pdfDoc.setCreationDate(creationDate);
           this.pdfDoc.setFilterMap(filterMap);
           this.pdfDoc.outputHeader(stream);
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to