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 ke...@locus.apache.org on 2000/12/18 03:28:41 UTC

cvs commit: xml-fop/src/org/apache/fop/render/xml XMLRenderer.java

kellyc      00/12/17 18:28:41

  Modified:    conf     config.xml
               lib      Fop.class Fop.java
               src/org/apache/fop/apps CommandLine.java Driver.java
                        PrintCommandLine.java XTCommandLine.java
                        XalanCommandLine.java
               src/org/apache/fop/layout/hyphenation Hyphenator.java
               src/org/apache/fop/pdf PDFAction.java PDFAnnotList.java
                        PDFArray.java PDFColor.java PDFDocument.java
                        PDFEncoding.java PDFFileSpec.java PDFFilter.java
                        PDFFont.java PDFFontDescriptor.java
                        PDFFunction.java PDFGoTo.java PDFGoToRemote.java
                        PDFInfo.java PDFInternalLink.java PDFLink.java
                        PDFObject.java PDFPage.java PDFPages.java
                        PDFPathPaint.java PDFPattern.java PDFRectangle.java
                        PDFResources.java PDFRoot.java PDFShading.java
                        PDFStream.java PDFUri.java PDFXObject.java
               src/org/apache/fop/render Renderer.java
               src/org/apache/fop/render/awt AWTRenderer.java
               src/org/apache/fop/render/pdf PDFRenderer.java
               src/org/apache/fop/render/xml XMLRenderer.java
  Added:       src/org/apache/fop/pdf ASCII85Filter.java
                        ASCIIHexFilter.java FlateFilter.java
  Removed:     src/org/apache/fop/pdf PDFBinaryStream.java
  Log:
  Changed output from Writer to OutputStream to allow for binary output.
  Added compression filters for PDF renderer.
  
  Revision  Changes    Path
  1.2       +19 -1     xml-fop/conf/config.xml
  
  Index: config.xml
  ===================================================================
  RCS file: /home/cvs/xml-fop/conf/config.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- config.xml	2000/12/12 19:18:07	1.1
  +++ config.xml	2000/12/18 02:28:27	1.2
  @@ -8,4 +8,22 @@
       <value>Fop 0.16.0 dev</value>
     </entry>
   
  -</configuration>
  \ No newline at end of file
  +  <!-- stream-filter-list provides the default filters that are applied to all
  +       stream objects within the PDF file. These are normally used for 
  +       compression -->
  +  <entry role="pdf">
  +    <key>stream-filter-list</key>
  +    <list>
  +      <!-- provides compression using zlib flate (default is on)-->
  +      <value>flate</value>
  +      
  +      <!-- encodes binary data into printable ascii characters (default off)
  +           This provides about a 4:5 expansion of data size -->
  +      <!-- <value>ascii-85</value> -->
  +
  +      <!-- encodes binary data with hex representation (default off)
  +           This filter is not recommended as it doubles the data size -->
  +      <!-- <value>ascii-hex</value> -->
  +    </list>
  +  </entry>
  +</configuration>
  
  
  
  1.7       +49 -50    xml-fop/lib/Fop.class
  
  	<<Binary file>>
  
  
  1.7       +2 -7      xml-fop/lib/Fop.java
  
  Index: Fop.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/lib/Fop.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Fop.java	2000/12/17 16:28:36	1.6
  +++ Fop.java	2000/12/18 02:28:28	1.7
  @@ -61,12 +61,7 @@
   import org.xml.sax.SAXParseException;
   
   // Java
  -import java.io.FileReader;
  -import java.io.File;
  -import java.io.FileWriter;
  -import java.io.PrintWriter;
  -import java.io.IOException;
  -import java.io.FileNotFoundException;
  +import java.io.*;
   import java.net.URL;
   
   // FOP
  @@ -200,7 +195,7 @@
                   driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
                   driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
                   driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
  -                driver.setWriter(new PrintWriter(new FileWriter(pdffile)));
  +                driver.setOutputStream(new FileOutputStream(pdffile));
                   driver.buildFOTree(parser, fileInputSource(fofile));
                   driver.format();
                   driver.render();
  
  
  
  1.17      +3 -9      xml-fop/src/org/apache/fop/apps/CommandLine.java
  
  Index: CommandLine.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/CommandLine.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CommandLine.java	2000/12/17 16:27:19	1.16
  +++ CommandLine.java	2000/12/18 02:28:29	1.17
  @@ -1,4 +1,4 @@
  -/*-- $Id: CommandLine.java,v 1.16 2000/12/17 16:27:19 fotis Exp $ --
  +/*-- $Id: CommandLine.java,v 1.17 2000/12/18 02:28:29 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -59,14 +59,8 @@
   import org.xml.sax.SAXParseException;
   
   // Java
  -import java.io.FileReader;
  -import java.io.File;
  -import java.io.FileWriter;
  -import java.io.PrintWriter;
  -import java.io.IOException;
  -import java.io.FileNotFoundException;
  +import java.io.*;
   import java.net.URL;
  -import java.io.InputStream;
   
   
   // FOP
  @@ -176,7 +170,7 @@
               driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
               driver.buildFOTree(parser, fileInputSource(foFile));
               driver.format();
  -            driver.setWriter(new PrintWriter(new FileWriter(pdfFile)));
  +	    driver.setOutputStream(new FileOutputStream(pdfFile));
               driver.render();
           } catch (Exception e) {
               MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
  
  
  
  1.19      +12 -15    xml-fop/src/org/apache/fop/apps/Driver.java
  
  Index: Driver.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/Driver.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Driver.java	2000/12/17 16:27:20	1.18
  +++ Driver.java	2000/12/18 02:28:29	1.19
  @@ -1,4 +1,4 @@
  -/*-- $Id: Driver.java,v 1.18 2000/12/17 16:27:20 fotis Exp $ --
  +/*-- $Id: Driver.java,v 1.19 2000/12/18 02:28:29 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -77,11 +77,9 @@
   import org.xml.sax.helpers.AttributesImpl;
   
   // Java
  -import java.io.PrintWriter;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.File;
  +import java.io.*;
   
  +
   /**
    * <P>Primary class that drives overall FOP process.
    *
  @@ -114,7 +112,7 @@
    *   driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
    *   driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
    *   driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
  - *   driver.setWriter(new PrintWriter(new FileWriter(args[1])));
  + *   driver.setOutputStream(new FileOutputStream(args[1]));
    *   driver.buildFOTree(parser, fileInputSource(args[0]));
    *   driver.format();
    *   driver.render();
  @@ -131,8 +129,8 @@
       /** the renderer to use to output the area tree */
       protected Renderer renderer;
   
  -    /** the PrintWriter to use to output the results of the renderer */
  -    protected PrintWriter writer;
  +    /** the stream to use to output the results of the renderer */
  +    protected OutputStream stream;
   
       /** If true, full error stacks are reported */
       protected boolean errorDump = false;
  @@ -421,13 +419,12 @@
   
       }
   
  -
       /**
  -        * set the PrintWriter to use to output the result of the Renderer
  -        * (if applicable)
  -        */
  -    public void setWriter(PrintWriter writer) {
  -        this.writer = writer;
  +       * set the OutputStream to use to output the result of the Renderer
  +       * (if applicable)
  +       */
  +    public void setOutputStream(OutputStream stream) {
  +        this.stream = stream;
       }
   
       /**
  @@ -447,7 +444,7 @@
           * render the area tree to the output form
           */
       public void render() throws IOException, FOPException {
  -        this.renderer.render(areaTree, this.writer);
  +        this.renderer.render(areaTree, this.stream);
       }
   
       /**
  
  
  
  1.8       +2 -2      xml-fop/src/org/apache/fop/apps/PrintCommandLine.java
  
  Index: PrintCommandLine.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/PrintCommandLine.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PrintCommandLine.java	2000/11/15 21:44:15	1.7
  +++ PrintCommandLine.java	2000/12/18 02:28:29	1.8
  @@ -14,7 +14,7 @@
   
   import java.awt.Graphics;
   import java.awt.print.*;
  -import java.io.PrintWriter;
  +import java.io.OutputStream;
   import java.io.IOException;
   import java.util.Vector;
   
  @@ -142,7 +142,7 @@
         }
       }
   
  -    public void render(AreaTree areaTree, PrintWriter writer) throws IOException {
  +    public void render(AreaTree areaTree, OutputStream stream) throws IOException {
         tree = areaTree;
         if (endNumber == -1) {
           endNumber = tree.getPages().size();
  
  
  
  1.10      +3 -8      xml-fop/src/org/apache/fop/apps/XTCommandLine.java
  
  Index: XTCommandLine.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/XTCommandLine.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XTCommandLine.java	2000/08/03 05:44:32	1.9
  +++ XTCommandLine.java	2000/12/18 02:28:29	1.10
  @@ -1,4 +1,4 @@
  -/*-- $Id: XTCommandLine.java,v 1.9 2000/08/03 05:44:32 keiron Exp $ -- 
  +/*-- $Id: XTCommandLine.java,v 1.10 2000/12/18 02:28:29 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -67,12 +67,7 @@
   import org.xml.sax.SAXParseException;
   
   // Java
  -import java.io.File;
  -import java.io.FileReader;
  -import java.io.FileWriter;
  -import java.io.PrintWriter;
  -import java.io.IOException;
  -import java.io.FileNotFoundException;
  +import java.io.*;
   import java.net.URL;
   
   /**
  @@ -121,7 +116,7 @@
   	    driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
   	    driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
   	    driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
  -	    driver.setWriter(new PrintWriter(new FileWriter(args[2])));
  +	    driver.setOutputStream(new FileOutputStream(args[2]));
   	    driver.buildFOTree(xslProcessor, fileInputSource(args[0]));
   	    driver.format();
   	    driver.render();
  
  
  
  1.10      +5 -15     xml-fop/src/org/apache/fop/apps/XalanCommandLine.java
  
  Index: XalanCommandLine.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/apps/XalanCommandLine.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XalanCommandLine.java	2000/12/17 16:27:20	1.9
  +++ XalanCommandLine.java	2000/12/18 02:28:29	1.10
  @@ -60,16 +60,7 @@
   
   
   // Java
  -import java.io.FileReader;
  -import java.io.File;
  -import java.io.StringWriter;
  -import java.io.StringReader;
  -import java.io.FileWriter;
  -import java.io.PrintWriter;
  -import java.io.BufferedWriter;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.FileNotFoundException;
  +import java.io.*;
   import java.net.URL;
   
   // Xalan
  @@ -305,9 +296,8 @@
               driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
               driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
               driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
  -            PrintWriter pwriter = new PrintWriter(
  -                                    new BufferedWriter(new FileWriter(pdfFile)));
  -            driver.setWriter(pwriter);
  +            OutputStream stream = new BufferedOutputStream(new FileOutputStream(pdfFile));
  +            driver.setOutputStream(stream);
               driver.buildFOTree(parser, new InputSource(reader));
               reader.close();
               driver.format();
  @@ -315,8 +305,8 @@
               if (usefile) {
                   new File (pdfFile + ".tmp").delete();
               }
  -            pwriter.flush();
  -            pwriter.close();
  +            stream.flush();
  +            stream.close();
           }
           catch (Exception e) {
               MessageHandler.errorln("FATAL ERROR: " + e.getMessage());
  
  
  
  1.2       +2 -2      xml-fop/src/org/apache/fop/layout/hyphenation/Hyphenator.java
  
  Index: Hyphenator.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/layout/hyphenation/Hyphenator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Hyphenator.java	2000/12/12 19:18:49	1.1
  +++ Hyphenator.java	2000/12/18 02:28:30	1.2
  @@ -1,4 +1,4 @@
  -/** -- $Id: Hyphenator.java,v 1.1 2000/12/12 19:18:49 fotis Exp $ --
  +/** -- $Id: Hyphenator.java,v 1.2 2000/12/18 02:28:30 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -91,7 +91,7 @@
   
           HyphenationTree hTree = getFopHyphenationTree(key);
           if (hTree == null) {
  -            String hyphenDir = StandardConfiguration.getStringValue("hyphenation-dir");
  +            String hyphenDir = Configuration.getStringValue("hyphenation-dir");
               if (hyphenDir != null){
                   hTree = getUserHyphenationTree(key,hyphenDir);
               }
  
  
  
  1.3       +101 -101  xml-fop/src/org/apache/fop/pdf/PDFAction.java
  
  Index: PDFAction.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFAction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PDFAction.java	2000/06/14 01:55:10	1.2
  +++ PDFAction.java	2000/12/18 02:28:31	1.3
  @@ -1,101 +1,101 @@
  -/*-- $Id: PDFAction.java,v 1.2 2000/06/14 01:55:10 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  -    endorse  or promote  products derived  from this  software without  prior
  -    written permission. For written permission, please contact
  -    apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.pdf;
  -
  -/**
  - * class representing an action object.
  - */
  -public abstract class PDFAction extends PDFObject {
  -
  -    
  -    /**
  -     * create an Action object.
  -     * this constructor is used for passing on the object number to the PDFObject
  -     *
  -     * @param number the object's number     
  -     */
  -    public PDFAction(int number) {
  -
  -	/* generic creation of object */
  -	super(number);	    
  -    }
  -
  -    /**
  -     * empty constructor for PDFAction.
  -     * this constructor is used when there is no additional object being created
  -     *     
  -     */
  -    public PDFAction()
  -    {
  -    }
  -
  -    /**
  -     * represent the action to call
  -     * this method should be implemented to return the action which gets
  -     * called by the Link Object.  This could be a reference to another object
  -     * or the specific destination of the link
  -     *
  -     * @return the action to place next to /A within a Link
  -     */
  -    abstract public String getAction();
  -    
  -
  -    /**
  -     * represent the object in PDF
  -     * this method should be implemented to return the PDF which is to be
  -     * generated by the Action object
  -     *
  -     * @return the PDF string
  -     */
  -    abstract public String toPDF();
  -
  -    }
  +/*-- $Id: PDFAction.java,v 1.3 2000/12/18 02:28:31 kellyc Exp $ -- 
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  +    endorse  or promote  products derived  from this  software without  prior
  +    written permission. For written permission, please contact
  +    apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +
  +package org.apache.fop.pdf;
  +
  +/**
  + * class representing an action object.
  + */
  +public abstract class PDFAction extends PDFObject {
  +
  +    
  +    /**
  +     * create an Action object.
  +     * this constructor is used for passing on the object number to the PDFObject
  +     *
  +     * @param number the object's number     
  +     */
  +    public PDFAction(int number) {
  +
  +	/* generic creation of object */
  +	super(number);	    
  +    }
  +
  +    /**
  +     * empty constructor for PDFAction.
  +     * this constructor is used when there is no additional object being created
  +     *     
  +     */
  +    public PDFAction()
  +    {
  +    }
  +
  +    /**
  +     * represent the action to call
  +     * this method should be implemented to return the action which gets
  +     * called by the Link Object.  This could be a reference to another object
  +     * or the specific destination of the link
  +     *
  +     * @return the action to place next to /A within a Link
  +     */
  +    abstract public String getAction();
  +    
  +
  +    /**
  +     * represent the object in PDF
  +     * this method should be implemented to return the PDF which is to be
  +     * generated by the Action object
  +     *
  +     * @return the PDF string
  +     */
  +    abstract public byte[] toPDF();
  +
  +    }
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFAnnotList.java
  
  Index: PDFAnnotList.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFAnnotList.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFAnnotList.java	1999/11/22 17:37:16	1.1
  +++ PDFAnnotList.java	2000/12/18 02:28:31	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFAnnotList.java,v 1.1 1999/11/22 17:37:16 jtauber Exp $ -- 
  +/*-- $Id: PDFAnnotList.java,v 1.2 2000/12/18 02:28:31 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -103,7 +103,7 @@
        *
        * @return the PDF string
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	StringBuffer p = new StringBuffer(this.number + " "
   					  + this.generation
   					  + " obj\n[\n"); 
  @@ -112,7 +112,7 @@
   			  links.elementAt(i)).referencePDF() + "\n");
   	}
   	p = p.append("]\nendobj\n");
  -	return p.toString();
  +	return p.toString().getBytes();
       }
   
       /* example
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFArray.java
  
  Index: PDFArray.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFArray.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFArray.java	2000/11/02 12:48:26	1.1
  +++ PDFArray.java	2000/12/18 02:28:31	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFArray.java,v 1.1 2000/11/02 12:48:26 fotis Exp $ --
  +/*-- $Id: PDFArray.java,v 1.2 2000/12/18 02:28:31 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -77,7 +77,7 @@
   	 *
   	 * @return the PDF
   	 */
  -	public String toPDF() {
  +	public byte[] toPDF() {
   		StringBuffer p = new StringBuffer();
   		p.append(this.number + " " + this.generation + " obj\n[");
   		for (int i = 0; i < values.length; i++) {
  @@ -85,6 +85,6 @@
   			p.append(values[i]);
   		}
   		p.append("]\nendobj\n");
  -		return p.toString();
  +		return p.toString().getBytes();
   	}
   }
  
  
  
  1.7       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFColor.java
  
  Index: PDFColor.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFColor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PDFColor.java	2000/07/18 06:04:07	1.6
  +++ PDFColor.java	2000/12/18 02:28:31	1.7
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFColor.java,v 1.6 2000/07/18 06:04:07 keiron Exp $ -- 
  +/*-- $Id: PDFColor.java,v 1.7 2000/12/18 02:28:31 kellyc Exp $ -- 
   
    ============================================================================
   						 The Apache Software License, Version 1.1
  @@ -375,9 +375,9 @@
   		
   	}
   	
  -	String toPDF()
  +	byte[] toPDF()
   	{
  -		return ("");
  +		return (new byte[0]);
   
   	} //end of toPDF
   }
  
  
  
  1.16      +36 -24    xml-fop/src/org/apache/fop/pdf/PDFDocument.java
  
  Index: PDFDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- PDFDocument.java	2000/11/16 15:36:59	1.15
  +++ PDFDocument.java	2000/12/18 02:28:31	1.16
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFDocument.java,v 1.15 2000/11/16 15:36:59 fotis Exp $ --
  +/*-- $Id: PDFDocument.java,v 1.16 2000/12/18 02:28:31 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -67,7 +67,7 @@
   import org.apache.fop.layout.FontDescriptor;
   // Java
   import java.io.IOException;
  -import java.io.PrintWriter;
  +import java.io.OutputStream;
   import java.util.Vector;
   import java.util.Hashtable;
   import java.util.Enumeration;
  @@ -914,10 +914,13 @@
           /* create a PDFStream with the next object number and add it
       
              to the list of objects */
  -        PDFStream obj = new PDFStream(++this.objectcount);
  +	PDFStream obj = new PDFStream(++this.objectcount);
  +	obj.addDefaultFilters();
  +		
           this.objects.addElement(obj);
           return obj;
       }
  +	    
   
       /**
        * make an annotation list object
  @@ -945,13 +948,13 @@
       /**
        * write the entire document out
        *
  -     * @param writer the PrinterWriter to output the document to
  +     * @param writer the OutputStream to output the document to
        */
  -    public void output(PrintWriter writer) throws IOException {
  +    public void output(OutputStream stream) throws IOException {
   
           /* output the header and increment the character position by
              the header's length */
  -        this.position += outputHeader(writer);
  +        this.position += outputHeader(stream);
   
           this.resources.setXObjects(xObjects);
   
  @@ -967,36 +970,44 @@
   
               /* output the object and increment the character position
                  by the object's length */
  -            this.position += object.output(writer);
  +            this.position += object.output(stream);
           }
   
           /* output the xref table and increment the character position
              by the table's length */
  -        this.position += outputXref(writer);
  +        this.position += outputXref(stream);
   
  -        /* output the trailer and flush the Writer */
  -        outputTrailer(writer);
  -        writer.flush();
  +        /* output the trailer and flush the Stream */
  +        outputTrailer(stream);
  +        stream.flush();
       }
   
       /**
        * write the PDF header
        *
  -     * @param writer the PrintWriter to write the header to
  -     * @return the number of characters written
  +     * @param stream the OutputStream to write the header to
  +     * @return the number of bytes written
        */
  -    protected int outputHeader(PrintWriter writer) throws IOException {
  -        String pdf = "%PDF-" + this.pdfVersion + "\n";
  -        writer.write(pdf);
  -        return pdf.length();
  +    protected int outputHeader(OutputStream stream) throws IOException {
  +	int length = 0;
  +	byte[] pdf = ("%PDF-" + this.pdfVersion + "\n").getBytes();
  +	stream.write(pdf);
  +	length += 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'};
  +	stream.write(bin);
  +	length += bin.length;
  +	
  +	return length;
       }
   
       /**
        * write the trailer
        *
  -     * @param writer the PrintWriter to write the trailer to
  +     * @param stream the OutputStream to write the trailer to
        */
  -    protected void outputTrailer(PrintWriter writer) throws IOException {
  +    protected void outputTrailer(OutputStream stream) throws IOException {
   
           /* construct the trailer */
           String pdf = "trailer\n<<\n/Size " + (this.objectcount+1)
  @@ -1006,16 +1017,16 @@
           + "\n%%EOF\n";
   
           /* write the trailer */
  -        writer.write(pdf);
  +        stream.write(pdf.getBytes());
       }
   
       /**
        * write the xref table
        *
  -     * @param writer the PrintWriter to write the xref table to
  +     * @param stream the OutputStream to write the xref table to
        * @return the number of characters written
        */
  -    private int outputXref(PrintWriter writer) throws IOException {
  +    private int outputXref(OutputStream stream) throws IOException {
   
           /* remember position of xref table */
           this.xref = this.position;
  @@ -1037,8 +1048,9 @@
           }
   
           /* write the xref table and return the character length */
  -        writer.write(pdf.toString());
  -        return pdf.length();
  +	byte[] pdfBytes = pdf.toString().getBytes();
  +	stream.write(pdfBytes);
  +        return pdfBytes.length;
       }    
   
       public void setIDReferences(IDReferences idReferences){
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFEncoding.java
  
  Index: PDFEncoding.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFEncoding.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFEncoding.java	2000/11/02 12:48:27	1.1
  +++ PDFEncoding.java	2000/12/18 02:28:31	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFEncoding.java,v 1.1 2000/11/02 12:48:27 fotis Exp $ --
  +/*-- $Id: PDFEncoding.java,v 1.2 2000/12/18 02:28:31 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -115,7 +115,7 @@
   	 *
   	 * @return the PDF
   	 */
  -	public String toPDF() {
  +	public byte[] toPDF() {
   		StringBuffer p = new StringBuffer();
   		p.append(this.number + " " + this.generation
   				+ " obj\n<< /Type /Encoding");
  @@ -137,7 +137,7 @@
   			p.append(" ]");
   		}
   		p.append(" >>\nendobj\n");
  -		return p.toString();
  +		return p.toString().getBytes();
   	}
   	/* example (p. 214)
   		25 0 obj
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFFileSpec.java
  
  Index: PDFFileSpec.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFileSpec.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFileSpec.java	1999/11/22 17:37:17	1.1
  +++ PDFFileSpec.java	2000/12/18 02:28:32	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFFileSpec.java,v 1.1 1999/11/22 17:37:17 jtauber Exp $ -- 
  +/*-- $Id: PDFFileSpec.java,v 1.2 2000/12/18 02:28:32 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -79,12 +79,12 @@
        *
        * @return the PDF string
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	String p = new String(this.number + " " + this.generation +
   			      " obj\n<<\n/Type /FileSpec\n" +
   			      "/F (" + this.filename + ")\n" + 
   			      ">>\nendobj\n"); 
  -	return p;
  +	return p.getBytes();
       }
   
       /* example
  
  
  
  1.2       +107 -236  xml-fop/src/org/apache/fop/pdf/PDFFilter.java
  
  Index: PDFFilter.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFilter.java	2000/05/23 09:18:55	1.1
  +++ PDFFilter.java	2000/12/18 02:28:32	1.2
  @@ -1,236 +1,107 @@
  -/*
  -
  - ============================================================================
  -						 The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of	source code must	retain the above copyright	notice,
  -	 this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -	 this list of conditions and the following disclaimer in the documentation
  -	 and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -	 include  the following  acknowledgment:	"This product includes	software
  -	 developed	by the	Apache Software Foundation	(http://www.apache.org/)."
  -	 Alternately, this	acknowledgment may	appear in the software itself,	if
  -	 and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  -	 endorse  or promote  products derived	from this	software without	prior
  -	 written permission. For written permission, please contact
  -	 apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -	 "Apache" appear	in their name,	without prior written permission  of the
  -	 Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR	PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL	THE
  - APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT	OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)	HOWEVER CAUSED AND ON
  - ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR	OTHERWISE) ARISING IN	ANY WAY OUT OF THE	USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software	consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software	Foundation and was	originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  -*/
  -
  -//Author:       Eric SCHAEFFER
  -//Description:  represent a PDF filter object
  -
  -package org.apache.fop.pdf;
  -
  -public class PDFFilter {
  -	public static int ASCII_HEX_DECODE = 1;
  -	public static int ASCII_85_DECODE = 2;
  -	public static int LZW_DECODE = 3;
  -	public static int RUN_LENGTH_DECODE = 4;
  -	public static int CCITT_FAX_DECODE = 5;
  -	public static int DCT_DECODE = 6;
  -	public static int FLATE_DECODE = 7;
  -
  -	// Filter type
  -	private int m_filterType;
  -
  -	// Properties
  -
  -	// LZW - Flat
  -	private Integer m_predictor = null;
  -	// LZW - Flat - CCITT
  -	private Integer m_columns = null;
  -	// LZW - Flat
  -	private Integer m_colors = null;
  -	// LZW - Flat
  -	private Integer m_bitsPerComponent = null;
  -	// LZW
  -	private Integer m_earlyChange = null;
  -	// CCITT
  -	private Integer m_k = null;
  -	// CCITT
  -	private Boolean m_endOfLine = null;
  -	// CCITT
  -	private Boolean m_encodedByteAlign = null;
  -	// CCITT
  -	private Integer m_rows = null;
  -	// CCITT
  -	private Boolean m_endOfBlock = null;
  -	// CCITT
  -	private Boolean m_blackls1 = null;
  -	// CCITT
  -	private Integer m_damagedRowsBeforeError = null;
  -
  -	public PDFFilter(int filter) throws PDFFilterException {
  -		if (	(filter != ASCII_HEX_DECODE) &&
  -				(filter != ASCII_85_DECODE) &&
  -				(filter != LZW_DECODE) &&
  -				(filter != RUN_LENGTH_DECODE) &&
  -				(filter != CCITT_FAX_DECODE) &&
  -				(filter != DCT_DECODE) &&
  -				(filter != FLATE_DECODE)
  -				) {
  -			throw new PDFFilterException("Filter type not supported");
  -		}
  -		this.m_filterType = filter;
  -	}
  -
  -	public int getType() {
  -		return this.m_filterType;
  -	}
  -
  -	public void setPredictor(Integer value) throws PDFFilterException {
  -		if ((this.m_filterType != LZW_DECODE) && (this.m_filterType != FLATE_DECODE)) {
  -			throw new PDFFilterException("No Predictor property for this filter");
  -		}
  -
  -		this.m_predictor = value;
  -	}
  -
  -	public Integer getPredictor() throws PDFFilterException {
  -		if ((this.m_filterType != LZW_DECODE) && (this.m_filterType != FLATE_DECODE)) {
  -			throw new PDFFilterException("No Predictor property for this filter");
  -		}
  -
  -		return this.m_predictor;
  -	}
  -
  -// ... etc ... 
  -
  -	public String toPDF() {
  -		String pdf = null;
  -/*
  -	public static int DCT_DECODE = 6;
  -*/
  -		if (this.m_filterType == ASCII_HEX_DECODE) {
  -			pdf = "/ASCIIHexDecode";
  -		} else if (this.m_filterType == ASCII_85_DECODE) {
  -			pdf = "/ASCI85Decode";
  -		} else if (this.m_filterType == LZW_DECODE) {
  -			StringBuffer buffer = new StringBuffer();
  -			buffer.append("/LZWDecode");
  -
  -			if (this.m_predictor != null) {
  -				buffer.append(" /Predictor ");
  -				buffer.append(this.m_predictor);
  -			}
  -			if (this.m_columns != null) {
  -				buffer.append(" /Columns ");
  -				buffer.append(this.m_columns);
  -			}
  -			if (this.m_colors != null) {
  -				buffer.append(" /Colors ");
  -				buffer.append(this.m_colors);
  -			}
  -			if (this.m_bitsPerComponent != null) {
  -				buffer.append(" /BitsPerComponent ");
  -				buffer.append(this.m_bitsPerComponent);
  -			}
  -			if (this.m_earlyChange != null) {
  -				buffer.append(" /EarlyChange ");
  -				buffer.append(this.m_earlyChange);
  -			}
  -
  -			pdf = buffer.toString();
  -		} else if (this.m_filterType == FLATE_DECODE) {
  -			StringBuffer buffer = new StringBuffer();
  -			buffer.append("/FlateDecode");
  -
  -			if (this.m_predictor != null) {
  -				buffer.append(" /Predictor ");
  -				buffer.append(this.m_predictor);
  -			}
  -			if (this.m_columns != null) {
  -				buffer.append(" /Columns ");
  -				buffer.append(this.m_columns);
  -			}
  -			if (this.m_colors != null) {
  -				buffer.append(" /Colors ");
  -				buffer.append(this.m_colors);
  -			}
  -			if (this.m_bitsPerComponent != null) {
  -				buffer.append(" /BitsPerComponent ");
  -				buffer.append(this.m_bitsPerComponent);
  -			}
  -
  -			pdf = buffer.toString();
  -		} else if (this.m_filterType == RUN_LENGTH_DECODE) {
  -			pdf = "/RunLengthDecode";
  -		} else if (this.m_filterType == CCITT_FAX_DECODE) {
  -			StringBuffer buffer = new StringBuffer();
  -			buffer.append("/CCITTFaxDecode");
  -
  -			if (this.m_k != null) {
  -				buffer.append(" /K ");
  -				buffer.append(this.m_k);
  -			}
  -			if (this.m_endOfLine != null) {
  -				buffer.append(" /EndOfLine ");
  -				buffer.append(this.m_endOfLine);
  -			}
  -			if (this.m_encodedByteAlign != null) {
  -				buffer.append(" /EncodedByteAlign ");
  -				buffer.append(this.m_encodedByteAlign);
  -			}
  -			if (this.m_columns != null) {
  -				buffer.append(" /Columns ");
  -				buffer.append(this.m_columns);
  -			}
  -			if (this.m_rows != null) {
  -				buffer.append(" /Rows ");
  -				buffer.append(this.m_rows);
  -			}
  -			if (this.m_endOfBlock != null) {
  -				buffer.append(" /EndOfBlock ");
  -				buffer.append(this.m_endOfBlock);
  -			}
  -			if (this.m_blackls1 != null) {
  -				buffer.append(" /Blackls1 ");
  -				buffer.append(this.m_blackls1);
  -			}
  -			if (this.m_damagedRowsBeforeError != null) {
  -				buffer.append(" /DamagedRowsBeforeError ");
  -				buffer.append(this.m_damagedRowsBeforeError);
  -			}
  -
  -			pdf = buffer.toString();
  -		} else if (this.m_filterType == DCT_DECODE) {
  -			pdf = "/DCTDecode";
  -		}
  -
  -		return pdf;
  -	}
  -
  -}
  +/*-- $Id: PDFFilter.java,v 1.2 2000/12/18 02:28:32 kellyc Exp $ -- 
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  +    endorse  or promote  products derived  from this  software without  prior
  +    written permission. For written permission, please contact
  +    apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  +
  +*/
  +
  +
  +//Author:       Eric SCHAEFFER, Kelly A. Campbell
  +//Description:  represent a PDF filter object
  +
  +package org.apache.fop.pdf;
  +
  +public abstract class PDFFilter {
  +    /* These are no longer needed, but are here as a reminder about what 
  +       filters pdf supports.
  +
  +	public static final int ASCII_HEX_DECODE = 1;
  +	public static final int ASCII_85_DECODE = 2;
  +	public static final int LZW_DECODE = 3;
  +	public static final int RUN_LENGTH_DECODE = 4;
  +	public static final int CCITT_FAX_DECODE = 5;
  +	public static final int DCT_DECODE = 6;
  +	public static final int FLATE_DECODE = 7;
  +
  +    */
  +
  +    /** Marker to know if this filter has already been applied to the data */
  +    private boolean _applied = false;
  +    
  +    public boolean isApplied() 
  +    {
  +	return _applied;
  +    }
  +    
  +    /**
  +     * Set the applied attribute to the given value. This attribute is
  +     * used to determine if this filter is just a placeholder for the
  +     * decodeparms and dictionary entries, or if the filter needs to
  +     * actually encode the data. For example if the raw data is copied
  +     * out of an image file in it's compressed format, then this
  +     * should be set to true and the filter options should be set to
  +     * those which the raw data was encoded with.  
  +     */
  +    public void setApplied(boolean b) 
  +    {
  +	_applied = b;
  +    }
  +    
  +    
  +    /** return a PDF string representation of the filter, e.g. /FlateDecode */
  +    public abstract String getName();
  +    
  +    /** return a parameter dictionary for this filter, or null */
  +    public abstract String getDecodeParms();
  +     
  +    /** encode the given data with the filter */
  +    public abstract byte[] encode(byte[] data);
  +    
  + 
  +    
  +}
  
  
  
  1.7       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFFont.java
  
  Index: PDFFont.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFont.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PDFFont.java	2000/11/02 12:48:27	1.6
  +++ PDFFont.java	2000/12/18 02:28:32	1.7
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFFont.java,v 1.6 2000/11/02 12:48:27 fotis Exp $ --
  +/*-- $Id: PDFFont.java,v 1.7 2000/12/18 02:28:32 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -209,7 +209,7 @@
        *
        * @return the PDF
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
           StringBuffer p = new StringBuffer();
           p.append(this.number + " " + this.generation
                   + " obj\n<< /Type /Font\n/Subtype /" + TYPE_NAMES[this.subtype]
  @@ -226,7 +226,7 @@
           }
           fillInPDF(p);
           p.append(" >>\nendobj\n");
  -        return p.toString();
  +        return p.toString().getBytes();
       }
   
       /**
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFFontDescriptor.java
  
  Index: PDFFontDescriptor.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFontDescriptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFFontDescriptor.java	2000/11/02 12:48:29	1.1
  +++ PDFFontDescriptor.java	2000/12/18 02:28:32	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFFontDescriptor.java,v 1.1 2000/11/02 12:48:29 fotis Exp $ --
  +/*-- $Id: PDFFontDescriptor.java,v 1.2 2000/12/18 02:28:32 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -139,7 +139,7 @@
   	 *
   	 * @return the PDF
   	 */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   		StringBuffer p = new StringBuffer(
   				this.number + " " + this.generation
   				+ " obj\n<< /Type /FontDescriptor"
  @@ -188,7 +188,7 @@
   		// CID optional field
   		fillInPDF(p);
   		p.append("\n >>\nendobj\n");
  -		return p.toString();
  +		return p.toString().getBytes();
       }
   
   	/**
  
  
  
  1.5       +758 -758  xml-fop/src/org/apache/fop/pdf/PDFFunction.java
  
  Index: PDFFunction.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFFunction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PDFFunction.java	2000/07/11 01:03:05	1.4
  +++ PDFFunction.java	2000/12/18 02:28:32	1.5
  @@ -1,758 +1,758 @@
  -/*-- $Id: PDFFunction.java,v 1.4 2000/07/11 01:03:05 keiron Exp $ -- 
  -
  - ============================================================================
  -						 The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of	source code must	retain the above copyright  notice,
  -	 this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -	 this list of conditions and the following disclaimer in the documentation
  -	 and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -	 include  the following  acknowledgment:	"This product includes	software
  -	 developed	by the  Apache Software Foundation	(http://www.apache.org/)."
  -	 Alternately, this  acknowledgment may  appear in the software itself,	if
  -	 and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  -	 endorse  or promote  products derived  from this	software without	prior
  -	 written permission. For written permission, please contact
  -	 apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -	 "Apache" appear	in their name,  without prior written permission  of the
  -	 Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN	ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software	Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.pdf;
  -
  -//Java... 
  -import java.util.Vector;
  -
  -/**
  - * class representing a PDF Function.
  - * 
  - * PDF Functions represent parameterized mathematical formulas and sampled representations with
  - * arbitrary resolution. Functions are used in two areas: device-dependent
  - * rasterization information for halftoning and transfer
  - * functions, and color specification for smooth shading (a PDF 1.3 feature).
  - * 
  - * All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
  - */
  -public class PDFFunction extends PDFObject {
  -	//Guts common to all function types
  -	/** Required: The Type of function (0,2,3,4) default is 0.*/
  -	protected int functionType =0; //Default
  -	
  -	/**
  -	 * Required: 2 * m Array of Double numbers which are possible inputs to the function
  -	 */
  -	protected Vector domain = null;
  -
  -	/**
  -	 * Required: 2 * n Array of Double numbers which are possible outputs to the function
  -	 */	 
  -	protected Vector range = null;
  -	
  -	/* ********************TYPE 0***************************** */
  -	//FunctionType 0 specific function guts
  -	/**
  -	 * Required: Array containing the Integer size of the Domain and Range, respectively.
  -	 * Note: This is really more like two seperate integers, sizeDomain, and sizeRange,
  -	 * but since they're expressed as an array in PDF, my implementation reflects that.
  -	 */ 
  -	protected Vector size = null;
  -	
  -	/** Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32 */
  -	protected int bitsPerSample = 1;	
  -	/** Optional for Type 0: order of interpolation between samples. Limited to linear (1) or cubic (3). Default is 1 */
  -	protected int order = 1;
  -	/**
  -	 * Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain.
  -	 * 
  -	 * Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.
  -	 * Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions.
  -	 */
  -	protected Vector encode = null;
  -	/**
  -	 * Optinoal for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range. Defaults to Range.
  -	 */
  -	protected Vector decode = null;
  -	/** Optional For Type 0: A stream of sample values */
  -	/** Required For Type 4: Postscript Calculator function composed of arithmetic, boolean, and stack operators + boolean constants */
  -	protected StringBuffer functionDataStream = null;
  -	/**
  -	 * Required (?) For Type 0: A vector of Strings for the various filters to be used to decode the stream.
  -	 * These are how the string is compressed. Flate, LZW, etc.
  -	 */
  -	protected Vector filter = null;
  -	/* *************************TYPE 2************************** */
  -	/**
  -	 * Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0].
  -	 */
  -	protected Vector cZero = null;
  -	/**
  -	 * Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1].
  -	 */
  -	protected Vector cOne = null;
  -	/**
  -	 * Required for Type 2: The interpolation exponent.
  -	 * Each value x will return n results.
  -	 * Must be greater than 0.
  -	 */
  -	protected double interpolationExponentN = 1;
  -
  -	/* *************************TYPE 3************************** */
  -	/** Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function. */
  -	protected Vector functions = null;
  -	/**
  -	 * Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain.
  -	 * k is the number of functions.
  -	 * If you pass null, it will output (1/k) in an array of k-1 elements.
  -	 * This makes each function responsible for an equal amount of the stitching function.
  -	 * It makes the gradient even.
  -	 */
  -	protected Vector bounds = null;
  -   // See encode above, as it's also part of Type 3 Functions.
  -   
  -	/* *************************TYPE 4************************** */
  -	//See 'data' above.
  -	private PDFNumber pdfNumber = new PDFNumber();
  -	
  -	/**
  -	 * create an complete Function object of Type 0, A Sampled function.
  -	 * 
  -	 * Use null for an optional object parameter if you choose not to use it.
  -	 * For optional int parameters, pass the default.
  -	 * 
  -	 * @param theDomain Vector objects of Double objects.
  -	 * This is the domain of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theRange Vector objects of Double objects.
  -	 * This is the Range of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theSize A Vector object of Integer objects.
  -	 * This is the number of samples in each input dimension.
  -	 * I can't imagine there being more or less than two input dimensions,
  -	 * so maybe this should be an array of length 2.
  -	 * 
  -	 * See page 265 of the PDF 1.3 Spec.
  -	 * @param theBitsPerSample An int specifying the number of bits user to represent each sample value.
  -	 * Limited to 1,2,4,8,12,16,24 or 32.
  -	 * See page 265 of the 1.3 PDF Spec.
  -	 * @param theOrder The order of interpolation between samples. Default is 1 (one). Limited
  -	 * to 1 (one) or 3, which means linear or cubic-spline interpolation.
  -	 * 
  -	 * This attribute is optional.
  -	 * 
  -	 * See page 265 in the PDF 1.3 spec.
  -	 * @param theEncode Vector objects of Double objects.
  -	 * This is the linear mapping of input values intop the domain
  -	 * of the function's sample table. Default is hard to represent in
  -	 * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
  -	 * This attribute is optional.
  -	 * 
  -	 * See page 265 in the PDF 1.3 spec.
  -	 * @param theDecode Vector objects of Double objects.
  -	 * This is a linear mapping of sample values into the range.
  -	 * The default is just the range.
  -	 * 
  -	 * This attribute is optional.
  -	 * Read about it on page 265 of the PDF 1.3 spec.
  -	 * @param theFunctionDataStream The sample values that specify the function are provided in a stream.
  -	 * 
  -	 * This is optional, but is almost always used.
  -	 * 
  -	 * Page 265 of the PDF 1.3 spec has more.
  -	 * @param theFilter This is a vector of String objects which are the various filters that
  -	 * have are to be applied to the stream to make sense of it. Order matters,
  -	 * so watch out.
  -	 * 
  -	 * This is not documented in the Function section of the PDF 1.3 spec,
  -	 * it was deduced from samples that this is sometimes used, even if we may never
  -	 * use it in FOP. It is added for completeness sake.
  -	 * @param theNumber The object number of this PDF object.
  -	 * @param theFunctionType This is the type of function (0,2,3, or 4).
  -	 * It should be 0 as this is the constructor for sampled functions.
  -	 */
  -	public PDFFunction(int theNumber, int theFunctionType,
  -			Vector theDomain, Vector theRange,
  -			Vector theSize,int theBitsPerSample,
  -			int theOrder,Vector theEncode,Vector theDecode,
  -			StringBuffer theFunctionDataStream, Vector theFilter)
  -	{
  -		super(theNumber);
  -		
  -		this.functionType = 0; //dang well better be 0;
  -		this.size = theSize;
  -		this.bitsPerSample = theBitsPerSample; 
  -		this.order = theOrder; //int
  -		this.encode = theEncode;//vector of int
  -		this.decode = theDecode; //vector of int
  -		this.functionDataStream = theFunctionDataStream;
  -		this.filter = theFilter;//vector of Strings
  -		
  -		//the domain and range are actually two dimensional arrays.
  -		//so if there's not an even number of items, bad stuff
  -		//happens.
  -		this.domain =  theDomain;
  -		this.range =  theRange;
  -	}
  -	
  -	/**
  -	 * create an complete Function object of Type 2, an Exponential Interpolation function.
  -	 * 
  -	 * Use null for an optional object parameter if you choose not to use it.
  -	 * For optional int parameters, pass the default.
  -	 * 
  -	 * @param theNumber the object's number
  -	 * @param theDomain Vector objects of Double objects.
  -	 * This is the domain of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theRange Vector of Doubles that is the Range of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theCZero This is a vector of Double objects which defines the function result
  -	 * when x=0.
  -	 * 
  -	 * This attribute is optional.
  -	 * It's described on page 268 of the PDF 1.3 spec.
  -	 * @param theCOne This is a vector of Double objects which defines the function result
  -	 * when x=1.
  -	 * 
  -	 * This attribute is optional.
  -	 * It's described on page 268 of the PDF 1.3 spec.
  -	 * @param theInterpolationExponentN This is the inerpolation exponent.
  -	 * 
  -	 * This attribute is required.
  -	 * PDF Spec page 268
  -	 * @param theFunctionType The type of the function, which should be 2.
  -	 */
  -	public PDFFunction(int theNumber, int theFunctionType,
  -						Vector theDomain, Vector theRange,
  -						Vector theCZero, Vector theCOne,
  -						double theInterpolationExponentN)
  -	{
  -		super(theNumber);
  -		
  -		this.functionType = 2; //dang well better be 2;
  -		
  -		this.cZero = theCZero;
  -		this.cOne = theCOne;
  -		this.interpolationExponentN = theInterpolationExponentN;
  -		
  -
  -		this.domain = theDomain;
  -		this.range = theRange;
  -		
  -	}
  -
  -	/**
  -	 * create an complete Function object of Type 3, a Stitching function.
  -	 * 
  -	 * Use null for an optional object parameter if you choose not to use it.
  -	 * For optional int parameters, pass the default.
  -	 * 
  -	 * @param theNumber the object's number
  -	 * @param theDomain Vector objects of Double objects.
  -	 * This is the domain of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theRange Vector objects of Double objects.
  -	 * This is the Range of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theFunctions A Vector of the PDFFunction objects that the stitching function stitches.
  -	 * 
  -	 * This attributed is required.
  -	 * It is described on page 269 of the PDF spec.
  -	 * @param theBounds This is a vector of Doubles representing the numbers that,
  -	 * in conjunction with Domain define the intervals to which each function from
  -	 * the 'functions' object applies. It must be in order of increasing magnitude,
  -	 * and each must be within Domain.
  -	 * 
  -	 * It basically sets how much of the gradient each function handles.
  -	 * 
  -	 * This attributed is required.
  -	 * It's described on page 269 of the PDF 1.3 spec.
  -	 * @param theEncode Vector objects of Double objects.
  -	 * This is the linear mapping of input values intop the domain
  -	 * of the function's sample table. Default is hard to represent in
  -	 * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
  -	 * This attribute is required.
  -	 * 
  -	 * See page 270 in the PDF 1.3 spec.
  -	 * @param theFunctionType This is the function type. It should be 3,
  -	 * for a stitching function.
  -	 */
  -	public PDFFunction(int theNumber, int theFunctionType,
  -			Vector theDomain, Vector theRange,
  -			Vector theFunctions, Vector theBounds,
  -			Vector theEncode)
  -	{
  -		super(theNumber);
  -		
  -		this.functionType = 3; //dang well better be 3;
  -				
  -		this.functions = theFunctions;
  -		this.bounds = theBounds;
  -		this.encode = theEncode;
  -		this.domain = theDomain;
  -		this.range =  theRange;
  -
  -	}
  -	
  -	/**
  -	 * create an complete Function object of Type 4, a postscript calculator function.
  -	 * 
  -	 * Use null for an optional object parameter if you choose not to use it.
  -	 * For optional int parameters, pass the default.
  -	 * 
  -	 * @param theDomain Vector object of Double objects.
  -	 * This is the domain of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theRange Vector object of Double objects.
  -	 * This is the Range of the function.
  -	 * See page 264 of the PDF 1.3 Spec.
  -	 * @param theFunctionDataStream This is a stream of arithmetic, boolean, and stack operators and boolean constants.
  -	 * I end up enclosing it in the '{' and '}' braces for you, so don't do it
  -	 * yourself.
  -	 * 
  -	 * This attribute is required.
  -	 * It's described on page 269 of the PDF 1.3 spec.
  -	 * @param theNumber The object number of this PDF object.
  -	 * @param theFunctionType The type of function which should be 4, as this is
  -	 * a Postscript calculator function
  -	 */
  -	public PDFFunction(int theNumber, int theFunctionType,
  -			Vector theDomain, Vector theRange,
  -			StringBuffer theFunctionDataStream)
  -	{
  -		super(theNumber);
  -		
  -		this.functionType = 4; //dang well better be 4;
  -		this.functionDataStream = theFunctionDataStream;
  -
  -		this.domain =  theDomain;
  -		
  -		this.range = theRange;
  -
  -	}
  -	
  -
  -	 /**
  -	  * represent as PDF. Whatever the FunctionType is, the correct
  -	  * representation spits out. The sets of required and optional
  -	  * attributes are different for each type, but if a required
  -	  * attribute's object was constructed as null, then no error
  -	  * is raised. Instead, the malformed PDF that was requested
  -	  * by the construction is dutifully output.
  -	  * This policy should be reviewed.
  -	  * 
  -	  * @return the PDF string.
  -	  */ 
  -	public String toPDF() {
  -		int vectorSize=0;
  -		int numberOfFunctions=0;
  -		int tempInt=0;
  -		StringBuffer p = new StringBuffer();
  -		p.append(this.number + " " +this.generation 
  -			+ " obj\n<< \n/FunctionType "+this.functionType+" \n");
  -
  -		//FunctionType 0
  -		if(this.functionType == 0)
  -		{
  -			if(this.domain != null)
  -			{
  -				//DOMAIN
  -				p.append("/Domain [ ");
  -				vectorSize = this.domain.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -						(Double)this.domain.elementAt(tempInt))
  -						+" ");
  -				}
  -				
  -				p.append("] \n");
  -			}			
  -			else
  -			{
  -				p.append("/Domain [ 0 1 ] \n");
  -			}
  -
  -			//SIZE
  -			if(this.size != null)
  -			{
  -				p.append("/Size [ ");
  -				vectorSize = this.size.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.size.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -			//ENCODE
  -			if(this.encode != null)
  -			{
  -				p.append("/Encode [ ");
  -				vectorSize = this.encode.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.encode.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Encode [ ");
  -				vectorSize = this.functions.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append("0 1 ");
  -				}
  -				p.append("] \n");
  -				
  -			}
  -			
  -			//BITSPERSAMPLE
  -			p.append("/BitsPerSample "+this.bitsPerSample);
  -			
  -			//ORDER (optional)
  -			if(this.order ==1 || this.order == 3)
  -			{
  -				p.append(" \n/Order "+this.order+" \n");
  -			}
  -			
  -			//RANGE
  -			if(this.range != null)
  -			{
  -				p.append("/Range [ ");
  -				vectorSize = this.range.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.range.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			
  -			//DECODE
  -			if(this.decode != null)
  -			{
  -				p.append("/Decode [ ");
  -				vectorSize = this.decode.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.decode.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			
  -			//LENGTH		
  -			if(this.functionDataStream != null)
  -			{
  -				p.append("/Length "+(this.functionDataStream.length()+1)
  -					+ " \n");
  -			}
  -			
  -			//FILTER?
  -			if (this.filter != null)
  -			{//if there's a filter
  -				vectorSize= this.filter.size();
  -				p.append("/Filter ");
  -				if (vectorSize == 1)
  -				{
  -					p.append("/"+((String)this.filter.elementAt(0))+" \n");
  -				}
  -				else
  -				{
  -					p.append("[ ");
  -					for(tempInt=0; tempInt <vectorSize; tempInt++)
  -					{
  -						p.append("/"+((String)this.filter.elementAt(0))+" ");
  -					}
  -					p.append("] \n");
  -				}
  -			}
  -			p.append(">> \n");
  -			
  -			//stream representing the function
  -			if(this.functionDataStream != null)
  -			{
  -				p.append("stream\n"+this.functionDataStream +"\nendstream\n");
  -			}
  -			
  -			p.append("endobj\n");
  -			
  -		}//end of if FunctionType 0
  -		else if(this.functionType == 2)
  -		{
  -			//DOMAIN
  -			if(this.domain != null)
  -			{
  -				p.append("/Domain [ ");
  -				vectorSize = this.domain.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.domain.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Domain [ 0 1 ] \n");
  -			}
  -
  -			
  -			//RANGE
  -			if(this.range != null)
  -			{
  -				p.append("/Range [ ");
  -				vectorSize = this.range.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.range.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			
  -			//FunctionType, C0, C1, N are required in PDF
  -			
  -			//C0
  -			if(this.cZero != null)
  -			{
  -				p.append("/C0 [ ");
  -				vectorSize = this.cZero.size();
  -				for(tempInt = 0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.cZero.elementAt(tempInt))+" ");
  -				}
  -				p.append("] \n");				
  -			}
  -			
  -			//C1
  -			if(this.cOne != null)
  -			{
  -				p.append("/C1 [ ");
  -				vectorSize = this.cOne.size();
  -				for(tempInt = 0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.cOne.elementAt(tempInt))+" ");
  -				}
  -				p.append("] \n");
  -			}
  -			
  -			//N: The interpolation Exponent
  -			p.append("/N "
  -				+pdfNumber.doubleOut(
  -					new Double(this.interpolationExponentN))
  -				+" \n");
  -			
  -			p.append(">> \nendobj\n");
  -
  -		}
  -		else if(this.functionType == 3)
  -		{//fix this up when my eyes uncross
  -			//DOMAIN
  -			if(this.domain != null)
  -			{
  -				p.append("/Domain [ ");
  -				vectorSize = this.domain.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.domain.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Domain [ 0 1 ] \n");
  -			}
  -
  -			//RANGE
  -			if(this.range != null)
  -			{
  -				p.append("/Range [ ");
  -				vectorSize = this.range.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.range.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -		
  -			//FUNCTIONS
  -			if(this.functions != null)
  -			{
  -				p.append("/Functions [ ");
  -				numberOfFunctions = this.functions.size();
  -				for(tempInt =0;tempInt < numberOfFunctions; tempInt++)
  -				{
  -					p.append( ((PDFFunction)this.functions.elementAt(tempInt)).referencePDF()+" ");
  -					
  -				}
  -				p.append("] \n");
  -			}
  -			
  -			
  -			//ENCODE
  -			if(this.encode != null)
  -			{
  -				p.append("/Encode [ ");
  -				vectorSize = this.encode.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.encode.elementAt(tempInt)) +" ");
  -				}
  -								
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Encode [ ");
  -				vectorSize = this.functions.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append("0 1 ");
  -				}
  -				p.append("] \n");
  -				
  -			}
  -			
  -			
  -			//BOUNDS, required, but can be empty
  -			p.append("/Bounds [ ");
  -			if(this.bounds != null)
  -			{
  -				
  -				vectorSize= this.bounds.size();
  -				for(tempInt = 0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.bounds.elementAt(tempInt))+" ");
  -				}
  -			
  -			}
  -			else
  -			{
  -				if(this.functions != null)
  -				{ 
  -					//if there are n functions,
  -					// there must be n-1 bounds.
  -					// so let each function handle an equal portion
  -					// of the whole. e.g. if there are 4, then [ 0.25 0.25 0.25 ]
  -					
  -					String functionsFraction = 
  -						pdfNumber.doubleOut(new Double(
  -							1.0 / ((double)numberOfFunctions)));
  -	
  -					for(tempInt =0;tempInt+1 < numberOfFunctions; tempInt++)
  -					{
  -						
  -						p.append( functionsFraction + " ");
  -					}
  -					functionsFraction = null; //clean reference.
  -					
  -				}
  -				
  -			}
  -			p.append("] \n");
  -			
  -			
  -			p.append(">> \nendobj\n");
  -		}
  -		else if(this.functionType == 4)
  -		{//fix this up when my eyes uncross
  -			//DOMAIN
  -			if(this.domain != null)
  -			{
  -				p.append("/Domain [ ");
  -				vectorSize = this.domain.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.domain.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Domain [ 0 1 ] \n");
  -			}
  -
  -			//RANGE
  -			if(this.range != null)
  -			{
  -				p.append("/Range [ ");
  -				vectorSize = this.range.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.range.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			
  -			//LENGTH		
  -			if(this.functionDataStream != null)
  -			{
  -				p.append("/Length "+(this.functionDataStream.length()+1)
  -					+ " \n");
  -			}
  -			
  -			p.append(">> \n");
  -			
  -			//stream representing the function
  -			if(this.functionDataStream != null)
  -			{
  -				p.append("stream\n{ "+this.functionDataStream +" } \nendstream\n");
  -			}
  -			
  -			p.append("endobj\n");
  -			
  -		}
  -		
  -		return (p.toString());
  -		
  -	}
  -}
  +/*-- $Id: PDFFunction.java,v 1.5 2000/12/18 02:28:32 kellyc Exp $ -- 
  +
  + ============================================================================
  +						 The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of	source code must	retain the above copyright  notice,
  +	 this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +	 this list of conditions and the following disclaimer in the documentation
  +	 and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +	 include  the following  acknowledgment:	"This product includes	software
  +	 developed	by the  Apache Software Foundation	(http://www.apache.org/)."
  +	 Alternately, this  acknowledgment may  appear in the software itself,	if
  +	 and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  +	 endorse  or promote  products derived  from this	software without	prior
  +	 written permission. For written permission, please contact
  +	 apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +	 "Apache" appear	in their name,  without prior written permission  of the
  +	 Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN	ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software	Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +
  +package org.apache.fop.pdf;
  +
  +//Java... 
  +import java.util.Vector;
  +
  +/**
  + * class representing a PDF Function.
  + * 
  + * PDF Functions represent parameterized mathematical formulas and sampled representations with
  + * arbitrary resolution. Functions are used in two areas: device-dependent
  + * rasterization information for halftoning and transfer
  + * functions, and color specification for smooth shading (a PDF 1.3 feature).
  + * 
  + * All PDF Functions have a FunctionType (0,2,3, or 4), a Domain, and a Range.
  + */
  +public class PDFFunction extends PDFObject {
  +	//Guts common to all function types
  +	/** Required: The Type of function (0,2,3,4) default is 0.*/
  +	protected int functionType =0; //Default
  +	
  +	/**
  +	 * Required: 2 * m Array of Double numbers which are possible inputs to the function
  +	 */
  +	protected Vector domain = null;
  +
  +	/**
  +	 * Required: 2 * n Array of Double numbers which are possible outputs to the function
  +	 */	 
  +	protected Vector range = null;
  +	
  +	/* ********************TYPE 0***************************** */
  +	//FunctionType 0 specific function guts
  +	/**
  +	 * Required: Array containing the Integer size of the Domain and Range, respectively.
  +	 * Note: This is really more like two seperate integers, sizeDomain, and sizeRange,
  +	 * but since they're expressed as an array in PDF, my implementation reflects that.
  +	 */ 
  +	protected Vector size = null;
  +	
  +	/** Required for Type 0: Number of Bits used to represent each sample value. Limited to 1,2,4,8,12,16,24, or 32 */
  +	protected int bitsPerSample = 1;	
  +	/** Optional for Type 0: order of interpolation between samples. Limited to linear (1) or cubic (3). Default is 1 */
  +	protected int order = 1;
  +	/**
  +	 * Optional for Type 0: A 2 * m array of Doubles which provides a linear mapping of input values to the domain.
  +	 * 
  +	 * Required for Type 3: A 2 * k array of Doubles that, taken in pairs, map each subset of the domain defined by Domain and the Bounds array to the domain of the corresponding function.
  +	 * Should be two values per function, usually (0,1), as in [0 1 0 1] for 2 functions.
  +	 */
  +	protected Vector encode = null;
  +	/**
  +	 * Optinoal for Type 0: A 2 * n array of Doubles which provides a linear mapping of sample values to the range. Defaults to Range.
  +	 */
  +	protected Vector decode = null;
  +	/** Optional For Type 0: A stream of sample values */
  +	/** Required For Type 4: Postscript Calculator function composed of arithmetic, boolean, and stack operators + boolean constants */
  +	protected StringBuffer functionDataStream = null;
  +	/**
  +	 * Required (?) For Type 0: A vector of Strings for the various filters to be used to decode the stream.
  +	 * These are how the string is compressed. Flate, LZW, etc.
  +	 */
  +	protected Vector filter = null;
  +	/* *************************TYPE 2************************** */
  +	/**
  +	 * Required For Type 2: An Array of n Doubles defining the function result when x=0. Default is [0].
  +	 */
  +	protected Vector cZero = null;
  +	/**
  +	 * Required For Type 2: An Array of n Doubles defining the function result when x=1. Default is [1].
  +	 */
  +	protected Vector cOne = null;
  +	/**
  +	 * Required for Type 2: The interpolation exponent.
  +	 * Each value x will return n results.
  +	 * Must be greater than 0.
  +	 */
  +	protected double interpolationExponentN = 1;
  +
  +	/* *************************TYPE 3************************** */
  +	/** Required for Type 3: An vector of PDFFunctions which form an array of k single input functions making up the stitching function. */
  +	protected Vector functions = null;
  +	/**
  +	 * Optional for Type 3: An array of (k-1) Doubles that, in combination with Domain, define the intervals to which each function from the Functions array apply. Bounds elements must be in order of increasing magnitude, and each value must be within the value of Domain.
  +	 * k is the number of functions.
  +	 * If you pass null, it will output (1/k) in an array of k-1 elements.
  +	 * This makes each function responsible for an equal amount of the stitching function.
  +	 * It makes the gradient even.
  +	 */
  +	protected Vector bounds = null;
  +   // See encode above, as it's also part of Type 3 Functions.
  +   
  +	/* *************************TYPE 4************************** */
  +	//See 'data' above.
  +	private PDFNumber pdfNumber = new PDFNumber();
  +	
  +	/**
  +	 * create an complete Function object of Type 0, A Sampled function.
  +	 * 
  +	 * Use null for an optional object parameter if you choose not to use it.
  +	 * For optional int parameters, pass the default.
  +	 * 
  +	 * @param theDomain Vector objects of Double objects.
  +	 * This is the domain of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theRange Vector objects of Double objects.
  +	 * This is the Range of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theSize A Vector object of Integer objects.
  +	 * This is the number of samples in each input dimension.
  +	 * I can't imagine there being more or less than two input dimensions,
  +	 * so maybe this should be an array of length 2.
  +	 * 
  +	 * See page 265 of the PDF 1.3 Spec.
  +	 * @param theBitsPerSample An int specifying the number of bits user to represent each sample value.
  +	 * Limited to 1,2,4,8,12,16,24 or 32.
  +	 * See page 265 of the 1.3 PDF Spec.
  +	 * @param theOrder The order of interpolation between samples. Default is 1 (one). Limited
  +	 * to 1 (one) or 3, which means linear or cubic-spline interpolation.
  +	 * 
  +	 * This attribute is optional.
  +	 * 
  +	 * See page 265 in the PDF 1.3 spec.
  +	 * @param theEncode Vector objects of Double objects.
  +	 * This is the linear mapping of input values intop the domain
  +	 * of the function's sample table. Default is hard to represent in
  +	 * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
  +	 * This attribute is optional.
  +	 * 
  +	 * See page 265 in the PDF 1.3 spec.
  +	 * @param theDecode Vector objects of Double objects.
  +	 * This is a linear mapping of sample values into the range.
  +	 * The default is just the range.
  +	 * 
  +	 * This attribute is optional.
  +	 * Read about it on page 265 of the PDF 1.3 spec.
  +	 * @param theFunctionDataStream The sample values that specify the function are provided in a stream.
  +	 * 
  +	 * This is optional, but is almost always used.
  +	 * 
  +	 * Page 265 of the PDF 1.3 spec has more.
  +	 * @param theFilter This is a vector of String objects which are the various filters that
  +	 * have are to be applied to the stream to make sense of it. Order matters,
  +	 * so watch out.
  +	 * 
  +	 * This is not documented in the Function section of the PDF 1.3 spec,
  +	 * it was deduced from samples that this is sometimes used, even if we may never
  +	 * use it in FOP. It is added for completeness sake.
  +	 * @param theNumber The object number of this PDF object.
  +	 * @param theFunctionType This is the type of function (0,2,3, or 4).
  +	 * It should be 0 as this is the constructor for sampled functions.
  +	 */
  +	public PDFFunction(int theNumber, int theFunctionType,
  +			Vector theDomain, Vector theRange,
  +			Vector theSize,int theBitsPerSample,
  +			int theOrder,Vector theEncode,Vector theDecode,
  +			StringBuffer theFunctionDataStream, Vector theFilter)
  +	{
  +		super(theNumber);
  +		
  +		this.functionType = 0; //dang well better be 0;
  +		this.size = theSize;
  +		this.bitsPerSample = theBitsPerSample; 
  +		this.order = theOrder; //int
  +		this.encode = theEncode;//vector of int
  +		this.decode = theDecode; //vector of int
  +		this.functionDataStream = theFunctionDataStream;
  +		this.filter = theFilter;//vector of Strings
  +		
  +		//the domain and range are actually two dimensional arrays.
  +		//so if there's not an even number of items, bad stuff
  +		//happens.
  +		this.domain =  theDomain;
  +		this.range =  theRange;
  +	}
  +	
  +	/**
  +	 * create an complete Function object of Type 2, an Exponential Interpolation function.
  +	 * 
  +	 * Use null for an optional object parameter if you choose not to use it.
  +	 * For optional int parameters, pass the default.
  +	 * 
  +	 * @param theNumber the object's number
  +	 * @param theDomain Vector objects of Double objects.
  +	 * This is the domain of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theRange Vector of Doubles that is the Range of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theCZero This is a vector of Double objects which defines the function result
  +	 * when x=0.
  +	 * 
  +	 * This attribute is optional.
  +	 * It's described on page 268 of the PDF 1.3 spec.
  +	 * @param theCOne This is a vector of Double objects which defines the function result
  +	 * when x=1.
  +	 * 
  +	 * This attribute is optional.
  +	 * It's described on page 268 of the PDF 1.3 spec.
  +	 * @param theInterpolationExponentN This is the inerpolation exponent.
  +	 * 
  +	 * This attribute is required.
  +	 * PDF Spec page 268
  +	 * @param theFunctionType The type of the function, which should be 2.
  +	 */
  +	public PDFFunction(int theNumber, int theFunctionType,
  +						Vector theDomain, Vector theRange,
  +						Vector theCZero, Vector theCOne,
  +						double theInterpolationExponentN)
  +	{
  +		super(theNumber);
  +		
  +		this.functionType = 2; //dang well better be 2;
  +		
  +		this.cZero = theCZero;
  +		this.cOne = theCOne;
  +		this.interpolationExponentN = theInterpolationExponentN;
  +		
  +
  +		this.domain = theDomain;
  +		this.range = theRange;
  +		
  +	}
  +
  +	/**
  +	 * create an complete Function object of Type 3, a Stitching function.
  +	 * 
  +	 * Use null for an optional object parameter if you choose not to use it.
  +	 * For optional int parameters, pass the default.
  +	 * 
  +	 * @param theNumber the object's number
  +	 * @param theDomain Vector objects of Double objects.
  +	 * This is the domain of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theRange Vector objects of Double objects.
  +	 * This is the Range of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theFunctions A Vector of the PDFFunction objects that the stitching function stitches.
  +	 * 
  +	 * This attributed is required.
  +	 * It is described on page 269 of the PDF spec.
  +	 * @param theBounds This is a vector of Doubles representing the numbers that,
  +	 * in conjunction with Domain define the intervals to which each function from
  +	 * the 'functions' object applies. It must be in order of increasing magnitude,
  +	 * and each must be within Domain.
  +	 * 
  +	 * It basically sets how much of the gradient each function handles.
  +	 * 
  +	 * This attributed is required.
  +	 * It's described on page 269 of the PDF 1.3 spec.
  +	 * @param theEncode Vector objects of Double objects.
  +	 * This is the linear mapping of input values intop the domain
  +	 * of the function's sample table. Default is hard to represent in
  +	 * ascii, but basically [0 (Size0 1) 0 (Size1 1)...].
  +	 * This attribute is required.
  +	 * 
  +	 * See page 270 in the PDF 1.3 spec.
  +	 * @param theFunctionType This is the function type. It should be 3,
  +	 * for a stitching function.
  +	 */
  +	public PDFFunction(int theNumber, int theFunctionType,
  +			Vector theDomain, Vector theRange,
  +			Vector theFunctions, Vector theBounds,
  +			Vector theEncode)
  +	{
  +		super(theNumber);
  +		
  +		this.functionType = 3; //dang well better be 3;
  +				
  +		this.functions = theFunctions;
  +		this.bounds = theBounds;
  +		this.encode = theEncode;
  +		this.domain = theDomain;
  +		this.range =  theRange;
  +
  +	}
  +	
  +	/**
  +	 * create an complete Function object of Type 4, a postscript calculator function.
  +	 * 
  +	 * Use null for an optional object parameter if you choose not to use it.
  +	 * For optional int parameters, pass the default.
  +	 * 
  +	 * @param theDomain Vector object of Double objects.
  +	 * This is the domain of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theRange Vector object of Double objects.
  +	 * This is the Range of the function.
  +	 * See page 264 of the PDF 1.3 Spec.
  +	 * @param theFunctionDataStream This is a stream of arithmetic, boolean, and stack operators and boolean constants.
  +	 * I end up enclosing it in the '{' and '}' braces for you, so don't do it
  +	 * yourself.
  +	 * 
  +	 * This attribute is required.
  +	 * It's described on page 269 of the PDF 1.3 spec.
  +	 * @param theNumber The object number of this PDF object.
  +	 * @param theFunctionType The type of function which should be 4, as this is
  +	 * a Postscript calculator function
  +	 */
  +	public PDFFunction(int theNumber, int theFunctionType,
  +			Vector theDomain, Vector theRange,
  +			StringBuffer theFunctionDataStream)
  +	{
  +		super(theNumber);
  +		
  +		this.functionType = 4; //dang well better be 4;
  +		this.functionDataStream = theFunctionDataStream;
  +
  +		this.domain =  theDomain;
  +		
  +		this.range = theRange;
  +
  +	}
  +	
  +
  +	 /**
  +	  * represent as PDF. Whatever the FunctionType is, the correct
  +	  * representation spits out. The sets of required and optional
  +	  * attributes are different for each type, but if a required
  +	  * attribute's object was constructed as null, then no error
  +	  * is raised. Instead, the malformed PDF that was requested
  +	  * by the construction is dutifully output.
  +	  * This policy should be reviewed.
  +	  * 
  +	  * @return the PDF string.
  +	  */ 
  +	public byte[] toPDF() {
  +		int vectorSize=0;
  +		int numberOfFunctions=0;
  +		int tempInt=0;
  +		StringBuffer p = new StringBuffer();
  +		p.append(this.number + " " +this.generation 
  +			+ " obj\n<< \n/FunctionType "+this.functionType+" \n");
  +
  +		//FunctionType 0
  +		if(this.functionType == 0)
  +		{
  +			if(this.domain != null)
  +			{
  +				//DOMAIN
  +				p.append("/Domain [ ");
  +				vectorSize = this.domain.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +						(Double)this.domain.elementAt(tempInt))
  +						+" ");
  +				}
  +				
  +				p.append("] \n");
  +			}			
  +			else
  +			{
  +				p.append("/Domain [ 0 1 ] \n");
  +			}
  +
  +			//SIZE
  +			if(this.size != null)
  +			{
  +				p.append("/Size [ ");
  +				vectorSize = this.size.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.size.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +			//ENCODE
  +			if(this.encode != null)
  +			{
  +				p.append("/Encode [ ");
  +				vectorSize = this.encode.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.encode.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Encode [ ");
  +				vectorSize = this.functions.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append("0 1 ");
  +				}
  +				p.append("] \n");
  +				
  +			}
  +			
  +			//BITSPERSAMPLE
  +			p.append("/BitsPerSample "+this.bitsPerSample);
  +			
  +			//ORDER (optional)
  +			if(this.order ==1 || this.order == 3)
  +			{
  +				p.append(" \n/Order "+this.order+" \n");
  +			}
  +			
  +			//RANGE
  +			if(this.range != null)
  +			{
  +				p.append("/Range [ ");
  +				vectorSize = this.range.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.range.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			
  +			//DECODE
  +			if(this.decode != null)
  +			{
  +				p.append("/Decode [ ");
  +				vectorSize = this.decode.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.decode.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			
  +			//LENGTH		
  +			if(this.functionDataStream != null)
  +			{
  +				p.append("/Length "+(this.functionDataStream.length()+1)
  +					+ " \n");
  +			}
  +			
  +			//FILTER?
  +			if (this.filter != null)
  +			{//if there's a filter
  +				vectorSize= this.filter.size();
  +				p.append("/Filter ");
  +				if (vectorSize == 1)
  +				{
  +					p.append("/"+((String)this.filter.elementAt(0))+" \n");
  +				}
  +				else
  +				{
  +					p.append("[ ");
  +					for(tempInt=0; tempInt <vectorSize; tempInt++)
  +					{
  +						p.append("/"+((String)this.filter.elementAt(0))+" ");
  +					}
  +					p.append("] \n");
  +				}
  +			}
  +			p.append(">> \n");
  +			
  +			//stream representing the function
  +			if(this.functionDataStream != null)
  +			{
  +				p.append("stream\n"+this.functionDataStream +"\nendstream\n");
  +			}
  +			
  +			p.append("endobj\n");
  +			
  +		}//end of if FunctionType 0
  +		else if(this.functionType == 2)
  +		{
  +			//DOMAIN
  +			if(this.domain != null)
  +			{
  +				p.append("/Domain [ ");
  +				vectorSize = this.domain.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.domain.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Domain [ 0 1 ] \n");
  +			}
  +
  +			
  +			//RANGE
  +			if(this.range != null)
  +			{
  +				p.append("/Range [ ");
  +				vectorSize = this.range.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.range.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			
  +			//FunctionType, C0, C1, N are required in PDF
  +			
  +			//C0
  +			if(this.cZero != null)
  +			{
  +				p.append("/C0 [ ");
  +				vectorSize = this.cZero.size();
  +				for(tempInt = 0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.cZero.elementAt(tempInt))+" ");
  +				}
  +				p.append("] \n");				
  +			}
  +			
  +			//C1
  +			if(this.cOne != null)
  +			{
  +				p.append("/C1 [ ");
  +				vectorSize = this.cOne.size();
  +				for(tempInt = 0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.cOne.elementAt(tempInt))+" ");
  +				}
  +				p.append("] \n");
  +			}
  +			
  +			//N: The interpolation Exponent
  +			p.append("/N "
  +				+pdfNumber.doubleOut(
  +					new Double(this.interpolationExponentN))
  +				+" \n");
  +			
  +			p.append(">> \nendobj\n");
  +
  +		}
  +		else if(this.functionType == 3)
  +		{//fix this up when my eyes uncross
  +			//DOMAIN
  +			if(this.domain != null)
  +			{
  +				p.append("/Domain [ ");
  +				vectorSize = this.domain.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.domain.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Domain [ 0 1 ] \n");
  +			}
  +
  +			//RANGE
  +			if(this.range != null)
  +			{
  +				p.append("/Range [ ");
  +				vectorSize = this.range.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.range.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +		
  +			//FUNCTIONS
  +			if(this.functions != null)
  +			{
  +				p.append("/Functions [ ");
  +				numberOfFunctions = this.functions.size();
  +				for(tempInt =0;tempInt < numberOfFunctions; tempInt++)
  +				{
  +					p.append( ((PDFFunction)this.functions.elementAt(tempInt)).referencePDF()+" ");
  +					
  +				}
  +				p.append("] \n");
  +			}
  +			
  +			
  +			//ENCODE
  +			if(this.encode != null)
  +			{
  +				p.append("/Encode [ ");
  +				vectorSize = this.encode.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.encode.elementAt(tempInt)) +" ");
  +				}
  +								
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Encode [ ");
  +				vectorSize = this.functions.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append("0 1 ");
  +				}
  +				p.append("] \n");
  +				
  +			}
  +			
  +			
  +			//BOUNDS, required, but can be empty
  +			p.append("/Bounds [ ");
  +			if(this.bounds != null)
  +			{
  +				
  +				vectorSize= this.bounds.size();
  +				for(tempInt = 0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.bounds.elementAt(tempInt))+" ");
  +				}
  +			
  +			}
  +			else
  +			{
  +				if(this.functions != null)
  +				{ 
  +					//if there are n functions,
  +					// there must be n-1 bounds.
  +					// so let each function handle an equal portion
  +					// of the whole. e.g. if there are 4, then [ 0.25 0.25 0.25 ]
  +					
  +					String functionsFraction = 
  +						pdfNumber.doubleOut(new Double(
  +							1.0 / ((double)numberOfFunctions)));
  +	
  +					for(tempInt =0;tempInt+1 < numberOfFunctions; tempInt++)
  +					{
  +						
  +						p.append( functionsFraction + " ");
  +					}
  +					functionsFraction = null; //clean reference.
  +					
  +				}
  +				
  +			}
  +			p.append("] \n");
  +			
  +			
  +			p.append(">> \nendobj\n");
  +		}
  +		else if(this.functionType == 4)
  +		{//fix this up when my eyes uncross
  +			//DOMAIN
  +			if(this.domain != null)
  +			{
  +				p.append("/Domain [ ");
  +				vectorSize = this.domain.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.domain.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Domain [ 0 1 ] \n");
  +			}
  +
  +			//RANGE
  +			if(this.range != null)
  +			{
  +				p.append("/Range [ ");
  +				vectorSize = this.range.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.range.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			
  +			//LENGTH		
  +			if(this.functionDataStream != null)
  +			{
  +				p.append("/Length "+(this.functionDataStream.length()+1)
  +					+ " \n");
  +			}
  +			
  +			p.append(">> \n");
  +			
  +			//stream representing the function
  +			if(this.functionDataStream != null)
  +			{
  +				p.append("stream\n{ "+this.functionDataStream +" } \nendstream\n");
  +			}
  +			
  +			p.append("endobj\n");
  +			
  +		}
  +		
  +		return (p.toString().getBytes());
  +		
  +	}
  +}
  
  
  
  1.3       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFGoTo.java
  
  Index: PDFGoTo.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFGoTo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PDFGoTo.java	2000/06/28 17:49:20	1.2
  +++ PDFGoTo.java	2000/12/18 02:28:32	1.3
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFGoTo.java,v 1.2 2000/06/28 17:49:20 jordan Exp $ -- 
  +/*-- $Id: PDFGoTo.java,v 1.3 2000/12/18 02:28:32 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -119,12 +119,12 @@
        *
        * @return the PDF string
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	String p = new String(this.number + " " + this.generation +
   			      " obj\n<<\n/S /GoTo\n" +
   			      "/D [" + this.pageReference + " /XYZ "+xPosition+" "+yPosition+" null]\n" + 
   			      ">>\nendobj\n"); 
  -	return p;
  +	return p.getBytes();
       }
   
       /* example
  
  
  
  1.2       +111 -111  xml-fop/src/org/apache/fop/pdf/PDFGoToRemote.java
  
  Index: PDFGoToRemote.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFGoToRemote.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFGoToRemote.java	2000/06/14 01:51:45	1.1
  +++ PDFGoToRemote.java	2000/12/18 02:28:32	1.2
  @@ -1,111 +1,111 @@
  -/*-- $Id: PDFGoToRemote.java,v 1.1 2000/06/14 01:51:45 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  -    endorse  or promote  products derived  from this  software without  prior
  -    written permission. For written permission, please contact
  -    apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.pdf;
  -
  -/**
  - * class representing a /GoToR object.
  - */
  -public class PDFGoToRemote extends PDFAction {
  -
  -    /** the file specification */
  -    protected PDFFileSpec pdfFileSpec;
  -
  -    /**
  -     * create an GoToR object.
  -     *
  -     * @param number the object's number
  -     * @param fileSpec the fileSpec associated with the action
  -     */
  -    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec) {
  -
  -	/* generic creation of object */
  -	super(number);
  -	
  -	this.pdfFileSpec = pdfFileSpec;
  -    }
  -
  -    /**
  -     * return the action string which will reference this object
  -     *
  -     * @return the action String
  -     */
  -    public String getAction()
  -    {
  -        return this.referencePDF();
  -    }
  -
  -    /**
  -     * represent the object in PDF
  -     *
  -     * @return the PDF string
  -     */
  -    public String toPDF() {
  -	String p = new String(this.number + " " + this.generation +
  -			      " obj\n" +
  -			      "<<\n/S /GoToR\n" +
  -			      "/F " + pdfFileSpec.referencePDF() + "\n" +
  -			      "/D [ 0 /XYZ null null null ]" +
  -			      " \n>>\nendobj\n"); 
  -	return p;
  -    }
  -
  -    
  -    /* example
  -       28 0 obj
  -       << 
  -       /S /GoToR 
  -       /F 29 0 R 
  -       /D [ 0 /XYZ -6 797 null ] 
  -       >> 
  -       endobj
  -    */
  -}
  +/*-- $Id: PDFGoToRemote.java,v 1.2 2000/12/18 02:28:32 kellyc Exp $ -- 
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  +    endorse  or promote  products derived  from this  software without  prior
  +    written permission. For written permission, please contact
  +    apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +
  +package org.apache.fop.pdf;
  +
  +/**
  + * class representing a /GoToR object.
  + */
  +public class PDFGoToRemote extends PDFAction {
  +
  +    /** the file specification */
  +    protected PDFFileSpec pdfFileSpec;
  +
  +    /**
  +     * create an GoToR object.
  +     *
  +     * @param number the object's number
  +     * @param fileSpec the fileSpec associated with the action
  +     */
  +    public PDFGoToRemote(int number, PDFFileSpec pdfFileSpec) {
  +
  +	/* generic creation of object */
  +	super(number);
  +	
  +	this.pdfFileSpec = pdfFileSpec;
  +    }
  +
  +    /**
  +     * return the action string which will reference this object
  +     *
  +     * @return the action String
  +     */
  +    public String getAction()
  +    {
  +        return this.referencePDF();
  +    }
  +
  +    /**
  +     * represent the object in PDF
  +     *
  +     * @return the PDF string
  +     */
  +    public byte[] toPDF() {
  +	String p = new String(this.number + " " + this.generation +
  +			      " obj\n" +
  +			      "<<\n/S /GoToR\n" +
  +			      "/F " + pdfFileSpec.referencePDF() + "\n" +
  +			      "/D [ 0 /XYZ null null null ]" +
  +			      " \n>>\nendobj\n"); 
  +	return p.getBytes();
  +    }
  +
  +    
  +    /* example
  +       28 0 obj
  +       << 
  +       /S /GoToR 
  +       /F 29 0 R 
  +       /D [ 0 /XYZ -6 797 null ] 
  +       >> 
  +       endobj
  +    */
  +}
  
  
  
  1.6       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFInfo.java
  
  Index: PDFInfo.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFInfo.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PDFInfo.java	1999/11/22 02:32:03	1.5
  +++ PDFInfo.java	2000/12/18 02:28:33	1.6
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFInfo.java,v 1.5 1999/11/22 02:32:03 jtauber Exp $ -- 
  +/*-- $Id: PDFInfo.java,v 1.6 2000/12/18 02:28:33 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -85,10 +85,10 @@
        *
        * @return the PDF
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	String p = this.number + " " + this.generation
   	    + " obj\n<< /Type /Info\n/Producer (" + this.producer
   	    + ") >>\nendobj\n";
  -	return p;
  +	return p.getBytes();
       }
   }
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFInternalLink.java
  
  Index: PDFInternalLink.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFInternalLink.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFInternalLink.java	2000/06/21 01:42:23	1.1
  +++ PDFInternalLink.java	2000/12/18 02:28:33	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFInternalLink.java,v 1.1 2000/06/21 01:42:23 jordan Exp $ -- 
  +/*-- $Id: PDFInternalLink.java,v 1.2 2000/12/18 02:28:33 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -84,8 +84,8 @@
        *
        * @return an empty string
        */
  -    public String toPDF() {	
  -	return "";
  +    public byte[] toPDF() {	
  +	return new byte[0];
       } 
       
   }
  
  
  
  1.5       +122 -122  xml-fop/src/org/apache/fop/pdf/PDFLink.java
  
  Index: PDFLink.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFLink.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PDFLink.java	2000/06/14 01:53:37	1.4
  +++ PDFLink.java	2000/12/18 02:28:33	1.5
  @@ -1,122 +1,122 @@
  -/*-- $Id: PDFLink.java,v 1.4 2000/06/14 01:53:37 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  -    endorse  or promote  products derived  from this  software without  prior
  -    written permission. For written permission, please contact
  -    apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.pdf;
  -
  -// Java
  -import java.awt.Rectangle;
  -
  -/**
  - * class representing an /Annot object of /Subtype /Link
  - */
  -public class PDFLink extends PDFObject {
  -
  -    float ulx;
  -    float uly;
  -    float brx;
  -    float bry;
  -    String color;
  -    PDFAction action;
  -	
  -    /**
  -     * create objects associated with a link annotation (GoToR)
  -     *
  -     * @param number the object's number
  -     * @param producer the application producing the PDF
  -     */
  -    public PDFLink(int number, Rectangle r) {
  -	/* generic creation of PDF object */
  -	super(number);
  -		
  -	this.ulx = r.x;
  -	this.uly = r.y;
  -	this.brx = r.x + r.width;
  -	this.bry = r.y - r.height;
  -	this.color = "0 0 0";	// just for now
  -		
  -    }
  -
  -    public void setAction(PDFAction action) {
  -	this.action = action;
  -    }
  -	
  -    /**
  -     * produce the PDF representation of the object
  -     *
  -     * @return the PDF
  -     */
  -    public String toPDF() {
  -	String p = this.number + " " + this.generation + " obj\n" +
  -	    "<< /Type /Annot\n" +
  -	    "/Subtype /Link\n" +
  -	    "/Rect [ " + (ulx/1000f) + " " + (uly/1000f) + " " +
  -	    (brx/1000f) + " " + (bry/1000f) + " ]\n"
  -	    + "/C [ " + this.color + " ]\n" + 
  -	    "/Border [ 0 0 0 ]\n" +
  -	    "/A " + this.action.getAction() + "\n" +
  -	    "/H /I\n>>\nendobj\n";
  -	return p;
  -    }
  -
  -    /* example
  -       19 0 obj
  -       << 
  -       /Type /Annot 
  -       /Subtype /Link 
  -       /Rect [ 176.032 678.48412 228.73579 692.356 ] 
  -       /C [ 0.86491 0.03421 0.02591 ] 
  -       /Border [ 0 0 1 ] 
  -       /A 28 0 R 
  -       /H /I 
  -       >> 
  -       endobj
  -    */
  -}
  +/*-- $Id: PDFLink.java,v 1.5 2000/12/18 02:28:33 kellyc Exp $ -- 
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  +    endorse  or promote  products derived  from this  software without  prior
  +    written permission. For written permission, please contact
  +    apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +
  +package org.apache.fop.pdf;
  +
  +// Java
  +import java.awt.Rectangle;
  +
  +/**
  + * class representing an /Annot object of /Subtype /Link
  + */
  +public class PDFLink extends PDFObject {
  +
  +    float ulx;
  +    float uly;
  +    float brx;
  +    float bry;
  +    String color;
  +    PDFAction action;
  +	
  +    /**
  +     * create objects associated with a link annotation (GoToR)
  +     *
  +     * @param number the object's number
  +     * @param producer the application producing the PDF
  +     */
  +    public PDFLink(int number, Rectangle r) {
  +	/* generic creation of PDF object */
  +	super(number);
  +		
  +	this.ulx = r.x;
  +	this.uly = r.y;
  +	this.brx = r.x + r.width;
  +	this.bry = r.y - r.height;
  +	this.color = "0 0 0";	// just for now
  +		
  +    }
  +
  +    public void setAction(PDFAction action) {
  +	this.action = action;
  +    }
  +	
  +    /**
  +     * produce the PDF representation of the object
  +     *
  +     * @return the PDF
  +     */
  +    public byte[] toPDF() {
  +	String p = this.number + " " + this.generation + " obj\n" +
  +	    "<< /Type /Annot\n" +
  +	    "/Subtype /Link\n" +
  +	    "/Rect [ " + (ulx/1000f) + " " + (uly/1000f) + " " +
  +	    (brx/1000f) + " " + (bry/1000f) + " ]\n"
  +	    + "/C [ " + this.color + " ]\n" + 
  +	    "/Border [ 0 0 0 ]\n" +
  +	    "/A " + this.action.getAction() + "\n" +
  +	    "/H /I\n>>\nendobj\n";
  +	return p.getBytes();
  +    }
  +
  +    /* example
  +       19 0 obj
  +       << 
  +       /Type /Annot 
  +       /Subtype /Link 
  +       /Rect [ 176.032 678.48412 228.73579 692.356 ] 
  +       /C [ 0.86491 0.03421 0.02591 ] 
  +       /Border [ 0 0 1 ] 
  +       /A 28 0 R 
  +       /H /I 
  +       >> 
  +       endobj
  +    */
  +}
  
  
  
  1.9       +9 -9      xml-fop/src/org/apache/fop/pdf/PDFObject.java
  
  Index: PDFObject.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFObject.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PDFObject.java	2000/06/21 01:43:13	1.8
  +++ PDFObject.java	2000/12/18 02:28:33	1.9
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFObject.java,v 1.8 2000/06/21 01:43:13 jordan Exp $ -- 
  +/*-- $Id: PDFObject.java,v 1.9 2000/12/18 02:28:33 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -52,7 +52,7 @@
   
   // Java
   import java.io.IOException;
  -import java.io.PrintWriter;
  +import java.io.OutputStream;
   
   /**
    * generic PDF object.
  @@ -89,13 +89,13 @@
       /**
        * write the PDF represention of this object
        *
  -     * @param writer the PrintWriter to write the PDF to
  -     * @return the number of characters written
  +     * @param stream the stream to write the PDF to
  +     * @return the number of bytes written
        */
  -    protected int output(PrintWriter writer) throws IOException {
  -	String pdf = this.toPDF();
  -	writer.write(pdf);
  -	return pdf.length();
  +    protected int output(OutputStream stream) throws IOException {
  +	byte[] pdf = this.toPDF();
  +	stream.write(pdf);
  +	return pdf.length;
       }
   
       /**
  @@ -113,5 +113,5 @@
        *
        * @return PDF string
        */
  -    abstract String toPDF();
  +    abstract byte[] toPDF();
   }
  
  
  
  1.10      +3 -3      xml-fop/src/org/apache/fop/pdf/PDFPage.java
  
  Index: PDFPage.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFPage.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PDFPage.java	2000/03/21 10:54:37	1.9
  +++ PDFPage.java	2000/12/18 02:28:33	1.10
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFPage.java,v 1.9 2000/03/21 10:54:37 arved Exp $ -- 
  +/*-- $Id: PDFPage.java,v 1.10 2000/12/18 02:28:33 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -138,7 +138,7 @@
        *
        * @return the PDF string
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	StringBuffer sb = new StringBuffer();
   
   	sb = sb.append(this.number + " " + this.generation + " obj\n" +
  @@ -155,6 +155,6 @@
   
   	sb = sb.append(">>\nendobj\n");
   
  -	return sb.toString();
  +	return sb.toString().getBytes();
       }
   }
  
  
  
  1.9       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFPages.java
  
  Index: PDFPages.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFPages.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PDFPages.java	2000/06/27 22:14:14	1.8
  +++ PDFPages.java	2000/12/18 02:28:33	1.9
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFPages.java,v 1.8 2000/06/27 22:14:14 fotis Exp $ -- 
  +/*-- $Id: PDFPages.java,v 1.9 2000/12/18 02:28:33 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -116,7 +116,7 @@
        *
        * @return the PDF string
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	StringBuffer p = new StringBuffer(this.number + " "
   					  + this.generation
   					  + " obj\n<< /Type /Pages\n/Count " 
  @@ -125,6 +125,6 @@
   	    p = p.append(((PDFObject)kids.elementAt(i)).referencePDF() + " ");
   	}
   	p = p.append("] >>\nendobj\n");
  -	return p.toString();
  +	return p.toString().getBytes();
       }
   }
  
  
  
  1.4       +86 -86    xml-fop/src/org/apache/fop/pdf/PDFPathPaint.java
  
  Index: PDFPathPaint.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFPathPaint.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PDFPathPaint.java	2000/05/15 13:00:19	1.3
  +++ PDFPathPaint.java	2000/12/18 02:28:33	1.4
  @@ -1,86 +1,86 @@
  -/*-- $Id: PDFPathPaint.java,v 1.3 2000/05/15 13:00:19 gears Exp $ -- 
  -
  - ============================================================================
  -						 The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of	source code must	retain the above copyright  notice,
  -	 this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -	 this list of conditions and the following disclaimer in the documentation
  -	 and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -	 include  the following  acknowledgment:	"This product includes	software
  -	 developed	by the  Apache Software Foundation	(http://www.apache.org/)."
  -	 Alternately, this  acknowledgment may  appear in the software itself,	if
  -	 and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  -	 endorse  or promote  products derived  from this	software without	prior
  -	 written permission. For written permission, please contact
  -	 apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -	 "Apache" appear	in their name,  without prior written permission  of the
  -	 Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN	ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software	Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -package org.apache.fop.pdf;
  -
  -import org.apache.fop.datatypes.ColorSpace;
  -
  -public abstract class PDFPathPaint extends PDFObject
  -{
  -
  -	//protected int colorspace = 0; //default is 0:RGB, not 1:CMYK
  -	protected ColorSpace colorSpace;
  -	
  -	public PDFPathPaint(int theNumber) {
  -		super(theNumber);
  -	
  -	}
  -	
  -	public PDFPathPaint(){
  -		//do nothing
  -	}
  -	
  -	public String getColorSpaceOut(boolean fillNotStroke)
  -	{
  -		return("");
  -	}
  -	
  -	public void setColorSpace(int theColorSpace)
  -	{
  -		this.colorSpace.setColorSpace(theColorSpace);
  -	}
  -	
  -	public int getColorSpace()
  -	{
  -		return(this.colorSpace.getColorSpace());
  -	}
  -	
  -}
  -
  +/*-- $Id: PDFPathPaint.java,v 1.4 2000/12/18 02:28:33 kellyc Exp $ -- 
  +
  + ============================================================================
  +						 The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of	source code must	retain the above copyright  notice,
  +	 this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +	 this list of conditions and the following disclaimer in the documentation
  +	 and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +	 include  the following  acknowledgment:	"This product includes	software
  +	 developed	by the  Apache Software Foundation	(http://www.apache.org/)."
  +	 Alternately, this  acknowledgment may  appear in the software itself,	if
  +	 and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  +	 endorse  or promote  products derived  from this	software without	prior
  +	 written permission. For written permission, please contact
  +	 apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +	 "Apache" appear	in their name,  without prior written permission  of the
  +	 Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN	ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software	Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +package org.apache.fop.pdf;
  +
  +import org.apache.fop.datatypes.ColorSpace;
  +
  +public abstract class PDFPathPaint extends PDFObject
  +{
  +
  +	//protected int colorspace = 0; //default is 0:RGB, not 1:CMYK
  +	protected ColorSpace colorSpace;
  +	
  +	public PDFPathPaint(int theNumber) {
  +		super(theNumber);
  +	
  +	}
  +	
  +	public PDFPathPaint(){
  +		//do nothing
  +	}
  +	
  +	public String getColorSpaceOut(boolean fillNotStroke)
  +	{
  +		return("");
  +	}
  +	
  +	public void setColorSpace(int theColorSpace)
  +	{
  +		this.colorSpace.setColorSpace(theColorSpace);
  +	}
  +	
  +	public int getColorSpace()
  +	{
  +		return(this.colorSpace.getColorSpace());
  +	}
  +	
  +}
  +
  
  
  
  1.6       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFPattern.java
  
  Index: PDFPattern.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFPattern.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PDFPattern.java	2000/11/10 00:53:42	1.5
  +++ PDFPattern.java	2000/12/18 02:28:34	1.6
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFPattern.java,v 1.5 2000/11/10 00:53:42 keiron Exp $ --
  +/*-- $Id: PDFPattern.java,v 1.6 2000/12/18 02:28:34 kellyc Exp $ --
   
    ============================================================================
   						 The Apache Software License, Version 1.1
  @@ -241,7 +241,7 @@
   	  *
   	  * @return the PDF string.
   	  */
  -	public String toPDF() {
  +	public byte[] toPDF() {
   
   
   		int vectorSize=0;
  @@ -357,7 +357,7 @@
   
   		
   
  -		return (p.toString());
  +		return (p.toString().getBytes());
   
   	}
   }
  
  
  
  1.2       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFRectangle.java
  
  Index: PDFRectangle.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFRectangle.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFRectangle.java	2000/11/02 12:48:30	1.1
  +++ PDFRectangle.java	2000/12/18 02:28:34	1.2
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFRectangle.java,v 1.1 2000/11/02 12:48:30 fotis Exp $ --
  +/*-- $Id: PDFRectangle.java,v 1.2 2000/12/18 02:28:34 kellyc Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -97,7 +97,7 @@
   	 *
   	 * @return the PDF
   	 */
  -    public String toPDF() {
  -		return " [" + llx + " " + lly + " " + urx + " " + ury + "] ";
  +    public byte[] toPDF() {
  +		return (" [" + llx + " " + lly + " " + urx + " " + ury + "] ").getBytes();
   	}
   }
  
  
  
  1.9       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFResources.java
  
  Index: PDFResources.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFResources.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PDFResources.java	2000/04/21 19:35:53	1.8
  +++ PDFResources.java	2000/12/18 02:28:34	1.9
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFResources.java,v 1.8 2000/04/21 19:35:53 gears Exp $ -- 
  +/*-- $Id: PDFResources.java,v 1.9 2000/12/18 02:28:34 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -107,7 +107,7 @@
        *
        * @return the PDF
        */
  -	public String toPDF() {
  +	public byte[] toPDF() {
   		StringBuffer p = new StringBuffer(this.number + " "
   						+ this.generation
   						+ " obj\n<< \n");
  @@ -187,6 +187,6 @@
   
   		p = p.append(">> \nendobj\n");
   
  -		return p.toString();
  +		return p.toString().getBytes();
   	}    
   }
  
  
  
  1.6       +3 -3      xml-fop/src/org/apache/fop/pdf/PDFRoot.java
  
  Index: PDFRoot.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFRoot.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PDFRoot.java	1999/11/22 02:32:05	1.5
  +++ PDFRoot.java	2000/12/18 02:28:34	1.6
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFRoot.java,v 1.5 1999/11/22 02:32:05 jtauber Exp $ -- 
  +/*-- $Id: PDFRoot.java,v 1.6 2000/12/18 02:28:34 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -94,10 +94,10 @@
        *
        * @return the PDF string
        */
  -    public String toPDF() {
  +    public byte[] toPDF() {
   	String p = this.number + " " + this.generation
   	    + " obj\n<< /Type /Catalog\n/Pages " 
   	    + this.rootPages.referencePDF() + " >>\nendobj\n";
  -	return p;
  +	return p.getBytes();
       }
   }
  
  
  
  1.5       +596 -596  xml-fop/src/org/apache/fop/pdf/PDFShading.java
  
  Index: PDFShading.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFShading.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PDFShading.java	2000/05/15 13:00:20	1.4
  +++ PDFShading.java	2000/12/18 02:28:34	1.5
  @@ -1,596 +1,596 @@
  -/*-- $Id: PDFShading.java,v 1.4 2000/05/15 13:00:20 gears Exp $ -- 
  -
  - ============================================================================
  -						 The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of	source code must	retain the above copyright  notice,
  -	 this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -	 this list of conditions and the following disclaimer in the documentation
  -	 and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -	 include  the following  acknowledgment:	"This product includes	software
  -	 developed	by the  Apache Software Foundation	(http://www.apache.org/)."
  -	 Alternately, this  acknowledgment may  appear in the software itself,	if
  -	 and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  -	 endorse  or promote  products derived  from this	software without	prior
  -	 written permission. For written permission, please contact
  -	 apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -	 "Apache" appear	in their name,  without prior written permission  of the
  -	 Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN	ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software	Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.pdf;
  -
  -//Java... 
  -import java.util.Vector;
  -
  -
  -//FOP
  -import org.apache.fop.datatypes.ColorSpace;
  -
  -/**
  - * class representing a PDF Smooth Shading object.
  - * 
  - * PDF Functions represent parameterized mathematical formulas and sampled representations with
  - * arbitrary resolution. Functions are used in two areas: device-dependent
  - * rasterization information for halftoning and transfer
  - * functions, and color specification for smooth shading (a PDF 1.3 feature).
  - * 
  - * All PDF Functions have a shadingType (0,2,3, or 4), a Domain, and a Range.
  - */
  -public class PDFShading extends PDFObject {
  -	//Guts common to all function types
  -	/** The name of the Shading e.g. "Shading1" */
  -	protected String shadingName = null;
  -	
  -	/**
  -	 * Required: The Type of shading (1,2,3,4,5,6,7)
  -	 */
  -	protected int shadingType = 3; //Default
  -	
  -	/**
  -	 * A ColorSpace representing the colorspace. "DeviceRGB" is an example.
  -	 */
  -	//protected StringBuffer colorSpace = null;
  -   protected ColorSpace colorSpace=null;
  -	/**
  -	 * The background color. Since shading is opaque,
  -	 * this is very rarely used.
  -	 */
  -	protected Vector background = null;
  -	/**
  -	 * Optional: A Vector specifying the clipping rectangle
  -	 */
  -	protected Vector bBox = null;
  -
  -	/**
  -	 * Optional: A flag whether or not to filter the shading function
  -	 * to prevent aliasing artifacts. Default is false.
  -	 */
  -	protected boolean antiAlias = false;
  -	
  -	/**
  -	 * Optional for Type 1: Array of four numbers, xmin, xmax, ymin, ymax. Default is [0 1 0 1]
  -	 * Optional for Type 2: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
  -	 * Optional for Type 3: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
  -	 */
  -	
  -	protected Vector domain = null;
  -   
  -   /** Optional for Type 1: A transformation matrix */
  -   protected Vector matrix = null;
  -   
  -   /**
  -    * Required for Type 1, 2, and 3: 
  -    * The object of the color mapping function (usually type 2 or 3).
  -    * Optional for Type 4,5,6, and 7: When it's nearly the same thing.
  -    */
  -   protected PDFFunction function = null;
  -	
  -	/** Required for Type 2: An Array of four numbers specifying the starting and ending coordinate pairs 
  -	 * Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1] specifying the centers and radii of
  -	 * the starting and ending circles.
  -	 */
  -	protected Vector coords = null;
  -	
  -	/**
  -	 * Required for Type 2+3: An Array of two boolean values specifying whether to extend the
  -	 * start and end colors past the start and end points,
  -	 * respectively. Default is false, false.
  -	 */
  -	protected Vector extend = null;
  -	
  -	/**
  -	 * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate.
  -	 * Allowed to be 1,2,4,8,12,16,24, or 32.
  -	 */
  -	protected int bitsPerCoordinate = 0;
  -
  -	/**
  -	 * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent the edge flag for each vertex.
  -	 * Allowed to be 2,4,or 8, while the Edge flag itself is allowed to be 0,1 or 2.
  -	 */
  -	protected int bitsPerFlag = 0;
  -
  -	/**
  -	 * Required for Type 4,5,6, and 7: Array of Doubles which specifies how to decode coordinate and color component values.
  -	 * Each type has a differing number of decode array members, so check the spec.
  -	 * Page 303 in PDF Spec 1.3
  -	 */
  -	protected Vector decode = null;
  -
  -	/**
  -	 * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate.
  -	 * Allowed to be 1,2,4,8,12, or 16
  -	 */
  -	protected int bitsPerComponent = 0;
  -
  -	/**
  -	 * Required for Type 5:The number of vertices in each "row" of the lattice; it must be greater than or equal to 2.
  -	 */
  -	protected int verticesPerRow = 0;
  -	
  -	private PDFNumber pdfNumber = new PDFNumber();
  -	
  -	/**
  -	 * Constructor for type function based shading
  -	 * 
  -	 * @param theNumber The object number of this PDF object
  -	 * @param theShadingName The name of the shading pattern. Can be anything
  -	 * without spaces. "Shading1" or "Sh1" are good examples.
  -	 * @param theShadingType The type of shading object, which should be 1 for function
  -	 * based shading.
  -	 * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
  -	 * @param theBackground An array of color components appropriate to the
  -	 * colorspace key specifying a single color value.
  -	 * This key is used by the f operator buy ignored by the sh operator.
  -	 * @param theBBox Vector of double's representing a rectangle
  -	 * in the coordinate space that is current at the
  -	 * time of shading is imaged. Temporary clipping
  -	 * boundary.
  -	 * @param theAntiAlias Whether or not to anti-alias.
  -	 * @param theDomain Optional vector of Doubles specifying the domain.
  -	 * @param theMatrix Vector of Doubles specifying the matrix.
  -	 * If it's a pattern, then the matrix maps it to pattern space.
  -	 * If it's a shading, then it maps it to current user space.
  -	 * It's optional, the default is the identity matrix
  -	 * @param theFunction The PDF Function that maps an (x,y) location to a color
  -	 */
  -	public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace,
  -		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  -		Vector theDomain, Vector theMatrix, PDFFunction theFunction)
  -	{
  -		super(theNumber);
  -		this.shadingName = theShadingName;
  -		this.shadingType = theShadingType; //1
  -		this.colorSpace=theColorSpace;
  -		this.background= theBackground;
  -		this.bBox = theBBox;
  -		this.antiAlias = theAntiAlias;
  -		
  -		this.domain = theDomain;
  -		this.matrix = theMatrix;
  -		this.function = theFunction;
  -	
  -	}
  -
  -		/**
  -		 * Constructor for Type 2 and 3
  -		 * 
  -		 * @param theNumber The object number of this PDF object.
  -		 * @param theShadingName The name of the shading pattern. Can be anything
  -		 * without spaces. "Shading1" or "Sh1" are good examples.
  -		 * @param theShadingType 2 or 3 for axial or radial shading
  -		 * @param theColorSpace "DeviceRGB" or similar.
  -		 * @param theBackground theBackground An array of color components appropriate to the
  -		 * colorspace key specifying a single color value.
  -		 * This key is used by the f operator buy ignored by the sh operator.
  -		 * @param theBBox Vector of double's representing a rectangle
  -		 * in the coordinate space that is current at the
  -		 * time of shading is imaged. Temporary clipping
  -		 * boundary.
  -		 * @param theAntiAlias Default is false
  -		 * @param theCoords Vector of four (type 2) or 6 (type 3) Double
  -		 * @param theDomain Vector of Doubles specifying the domain
  -		 * @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function
  -		 * @param theExtend Vector of Booleans of whether to extend teh start and end colors past the start and end points
  -		 * The default is [false, false]
  -		 */
  -	public PDFShading(int theNumber, String theShadingName,
  -		int theShadingType, ColorSpace theColorSpace,
  -		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  -		Vector theCoords, Vector theDomain, PDFFunction theFunction,
  -		Vector theExtend)
  -	{
  -		super(theNumber);
  -		this.shadingName = theShadingName;
  -		this.shadingType=theShadingType; //2 or 3
  -		this.colorSpace=theColorSpace;
  -		this.background= theBackground;
  -		this.bBox = theBBox;
  -		this.antiAlias = theAntiAlias;
  -
  -		this.coords = theCoords;
  -		this.domain = theDomain;
  -		this.function = theFunction;
  -		this.extend=theExtend;
  -	
  -	}
  -	
  -	/**
  -	 * Constructor for Type 4,6, or 7
  -	 * 
  -	 * @param theNumber The object number of this PDF object.
  -	 * @param theShadingType 4, 6, or 7 depending on whether it's
  -	 * Free-form gouraud-shaded triangle meshes, coons patch meshes, 
  -	 * or tensor product patch meshes, respectively.
  -	 * @param theShadingName The name of the shading pattern. Can be anything
  -	 * without spaces. "Shading1" or "Sh1" are good examples.
  -	 * @param theColorSpace "DeviceRGB" or similar.
  -	 * @param theBackground theBackground An array of color components appropriate to the
  -	 * colorspace key specifying a single color value.
  -	 * This key is used by the f operator buy ignored by the sh operator.
  -	 * @param theBBox Vector of double's representing a rectangle
  -	 * in the coordinate space that is current at the
  -	 * time of shading is imaged. Temporary clipping
  -	 * boundary.
  -	 * @param theAntiAlias Default is false
  -	 * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32.
  -	 * @param theBitsPerComponent 1,2,4,8,12, and 16
  -	 * @param theBitsPerFlag 2,4,8.
  -	 * @param theDecode Vector of Doubles see PDF 1.3 spec pages 303 to 312.
  -	 * @param theFunction the PDFFunction
  -	 */
  -	public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace,
  -		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  -		int theBitsPerCoordinate, int theBitsPerComponent,
  -		int theBitsPerFlag, Vector theDecode, PDFFunction theFunction)
  -	{
  -		super(theNumber);
  -		
  -		this.shadingType = theShadingType;//4,6 or 7
  -		this.colorSpace = theColorSpace;
  -		this.background= theBackground;
  -		this.bBox = theBBox;
  -		this.antiAlias = theAntiAlias;
  -		
  -		this.bitsPerCoordinate = theBitsPerCoordinate;
  -		this.bitsPerComponent = theBitsPerComponent;
  -		this.bitsPerFlag = theBitsPerFlag;
  -		this.decode = theDecode;
  -		this.function =theFunction;
  -	}
  -
  -	/**
  -	 * Constructor for type 5
  -	 * 
  -	 * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
  -	 * @param theShadingName The name of the shading pattern. Can be anything
  -	 * without spaces. "Shading1" or "Sh1" are good examples.
  -	 * @param theColorSpace "DeviceRGB" or similar.
  -	 * @param theBackground theBackground An array of color components appropriate to the
  -	 * colorspace key specifying a single color value.
  -	 * This key is used by the f operator buy ignored by the sh operator.
  -	 * @param theBBox Vector of double's representing a rectangle
  -	 * in the coordinate space that is current at the
  -	 * time of shading is imaged. Temporary clipping
  -	 * boundary.
  -	 * @param theAntiAlias Default is false
  -	 * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32
  -	 * @param theBitsPerComponent 1,2,4,8,12,24,32
  -	 * @param theDecode Vector of Doubles. See page 305 in PDF 1.3 spec.
  -	 * @param theVerticesPerRow number of vertices in each "row" of the lattice.
  -	 * @param theFunction The PDFFunction that's mapped on to this shape
  -	 * @param theNumber the object number of this PDF object.
  -	 */
  -	public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace,
  -		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  -		int theBitsPerCoordinate, int theBitsPerComponent,
  -		Vector theDecode, int theVerticesPerRow, PDFFunction theFunction)
  -	{
  -		super(theNumber);
  -		this.shadingName = theShadingName;
  -		this.shadingType = theShadingType;//5
  -		this.colorSpace=theColorSpace;
  -		this.background= theBackground;
  -		this.bBox = theBBox;
  -		this.antiAlias = theAntiAlias;
  -		
  -		this.bitsPerCoordinate = theBitsPerCoordinate;
  -		this.bitsPerComponent = theBitsPerComponent;
  -		this.decode = theDecode;
  -		this.verticesPerRow = theVerticesPerRow;
  -		this.function = theFunction;
  -	
  -	}
  -	
  -	public String getName() {
  -		return (this.shadingName);
  -   }
  -   
  -	 /**
  -	  * represent as PDF. Whatever the shadingType is, the correct
  -	  * representation spits out. The sets of required and optional
  -	  * attributes are different for each type, but if a required
  -	  * attribute's object was constructed as null, then no error
  -	  * is raised. Instead, the malformed PDF that was requested
  -	  * by the construction is dutifully output.
  -	  * This policy should be reviewed.
  -	  * 
  -	  * @return the PDF string.
  -	  */ 
  -	public String toPDF() {
  -		int vectorSize;
  -		int tempInt;
  -		StringBuffer p = new StringBuffer();
  -		p.append(this.number + " " + this.generation 
  -			+ " obj\n<< \n/ShadingType "+this.shadingType+" \n");
  -		if(this.colorSpace != null)
  -		{
  -			p.append("/ColorSpace /"
  -				+this.colorSpace.getColorSpacePDFString()+" \n");
  -		}
  -		
  -		if(this.background != null)
  -		{
  -			p.append("/Background [ ");
  -			vectorSize = this.background.size();
  -			for(tempInt=0; tempInt < vectorSize; tempInt++)
  -			{
  -				p.append(pdfNumber.doubleOut(
  -				(Double)this.background.elementAt(tempInt)) +" ");
  -			}
  -			p.append("] \n");
  -		}
  -		
  -		if(this.bBox != null)
  -		{//I've never seen an example, so I guess this is right.
  -			p.append("/BBox [ ");
  -			vectorSize = this.bBox.size();
  -			for(tempInt=0; tempInt < vectorSize; tempInt++)
  -			{
  -				p.append(pdfNumber.doubleOut(
  -				(Double)this.bBox.elementAt(tempInt)) +" ");
  -			}
  -			p.append("] \n");
  -		}
  -		
  -		if(this.antiAlias)
  -		{
  -			p.append("/AntiAlias "+this.antiAlias+" \n");
  -		}
  -		
  -		//Here's where we differentiate based on what type it is.
  -		if(this.shadingType == 1)
  -		{//function based shading
  -			if(this.domain != null)
  -			{
  -				p.append("/Domain [ ");
  -				vectorSize = this.domain.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.domain.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Domain [ 0 1 ] \n");
  -			}
  -			
  -			if(this.matrix != null)
  -			{
  -				p.append("/Matrix [ ");
  -				vectorSize = this.matrix.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.matrix.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -
  -			if(this.function != null)
  -			{
  -				p.append("/Function ");
  -				p.append(this.function.referencePDF()+" \n");
  -			}
  -		}
  -		else if((this.shadingType == 2)
  -		|| (this.shadingType == 3))
  -		{//2 is axial shading (linear gradient)
  -		//3 is radial shading (circular gradient)	
  -			if(this.coords != null)
  -			{
  -				p.append("/Coords [ ");
  -				vectorSize = this.coords.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.coords.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -			
  -			//DOMAIN
  -			if(this.domain != null)
  -			{
  -				p.append("/Domain [ ");
  -				vectorSize = this.domain.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(pdfNumber.doubleOut(
  -					(Double)this.domain.elementAt(tempInt)) +" ");
  -				}
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Domain [ 0 1 ] \n");
  -			}
  -			
  -			if(this.extend != null)
  -			{
  -				p.append("/Extend [ ");
  -				vectorSize = this.extend.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(((Boolean)this.extend.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -			else
  -			{
  -				p.append("/Extend [ true true ] \n");
  -			}
  -
  -
  -			if(this.function != null)
  -			{
  -				p.append("/Function ");
  -				p.append(this.function.referencePDF()+" \n");
  -			}
  -			
  -			
  -		}
  -		
  -		else if ((this.shadingType == 4) ||
  -					(this.shadingType == 6) ||
  -					(this.shadingType == 7))
  -		{//4:Free-form Gouraud-shaded triangle meshes
  -		// 6:coons patch meshes
  -		// 7://tensor product patch meshes (which no one ever uses)
  -			if(this.bitsPerCoordinate > 0)
  -			{
  -				p.append("/BitsPerCoordinate "+this.bitsPerCoordinate+" \n");
  -			}
  -			else
  -			{
  -				p.append("/BitsPerCoordinate 1 \n");
  -			}
  -			
  -			if(this.bitsPerComponent > 0)
  -			{
  -				p.append("/BitsPerComponent "+this.bitsPerComponent+" \n");
  -			}
  -			else
  -			{
  -				p.append("/BitsPerComponent 1 \n");
  -			}
  -			
  -			if(this.bitsPerFlag > 0)
  -			{
  -				p.append("/BitsPerFlag "+this.bitsPerFlag+" \n");
  -			}
  -			else
  -			{
  -				p.append("/BitsPerFlag 2 \n");
  -			}
  -
  -			if(this.decode != null)
  -			{
  -				p.append("/Decode [ ");
  -				vectorSize = this.decode.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(((Boolean)this.decode.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -		
  -			if(this.function != null)
  -			{
  -				p.append("/Function ");
  -				p.append(this.function.referencePDF()+" \n");
  -			}
  -			
  -		}
  -
  -		else if (this.shadingType == 5)
  -		{ //Lattice Free form gouraud-shaded triangle mesh
  -		 
  -			if(this.bitsPerCoordinate > 0)
  -			{
  -				p.append("/BitsPerCoordinate "+this.bitsPerCoordinate+" \n");
  -			}
  -			else
  -			{
  -				p.append("/BitsPerCoordinate 1 \n");
  -			}
  -			
  -			if(this.bitsPerComponent > 0)
  -			{
  -				p.append("/BitsPerComponent "+this.bitsPerComponent+" \n");
  -			}
  -			else
  -			{
  -				p.append("/BitsPerComponent 1 \n");
  -			}			
  -
  -			if(this.decode != null)
  -			{
  -				p.append("/Decode [ ");
  -				vectorSize = this.decode.size();
  -				for(tempInt=0; tempInt < vectorSize; tempInt++)
  -				{
  -					p.append(((Boolean)this.decode.elementAt(tempInt)) +" ");
  -				}
  -				
  -				p.append("] \n");
  -			}
  -		
  -			if(this.function != null)
  -			{
  -				p.append("/Function ");
  -				p.append(this.function.referencePDF()+" \n");
  -			}
  -			
  -			if(this.verticesPerRow > 0)
  -			{
  -				p.append("/VerticesPerRow "+this.verticesPerRow+" \n");
  -			}
  -			else
  -			{
  -				p.append("/VerticesPerRow 2 \n");
  -			}
  -			
  -		}
  -
  -		p.append(">> \nendobj\n");
  -	
  -		return(p.toString());
  -	}
  -}
  +/*-- $Id: PDFShading.java,v 1.5 2000/12/18 02:28:34 kellyc Exp $ -- 
  +
  + ============================================================================
  +						 The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +	 Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of	source code must	retain the above copyright  notice,
  +	 this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +	 this list of conditions and the following disclaimer in the documentation
  +	 and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +	 include  the following  acknowledgment:	"This product includes	software
  +	 developed	by the  Apache Software Foundation	(http://www.apache.org/)."
  +	 Alternately, this  acknowledgment may  appear in the software itself,	if
  +	 and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
  +	 endorse  or promote  products derived  from this	software without	prior
  +	 written permission. For written permission, please contact
  +	 apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +	 "Apache" appear	in their name,  without prior written permission  of the
  +	 Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.	IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE	FOUNDATION	OR ITS CONTRIBUTORS	BE LIABLE FOR	ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,	EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY	THEORY OF LIABILITY,  WHETHER  IN CONTRACT,	STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN	ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software	Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +
  +package org.apache.fop.pdf;
  +
  +//Java... 
  +import java.util.Vector;
  +
  +
  +//FOP
  +import org.apache.fop.datatypes.ColorSpace;
  +
  +/**
  + * class representing a PDF Smooth Shading object.
  + * 
  + * PDF Functions represent parameterized mathematical formulas and sampled representations with
  + * arbitrary resolution. Functions are used in two areas: device-dependent
  + * rasterization information for halftoning and transfer
  + * functions, and color specification for smooth shading (a PDF 1.3 feature).
  + * 
  + * All PDF Functions have a shadingType (0,2,3, or 4), a Domain, and a Range.
  + */
  +public class PDFShading extends PDFObject {
  +	//Guts common to all function types
  +	/** The name of the Shading e.g. "Shading1" */
  +	protected String shadingName = null;
  +	
  +	/**
  +	 * Required: The Type of shading (1,2,3,4,5,6,7)
  +	 */
  +	protected int shadingType = 3; //Default
  +	
  +	/**
  +	 * A ColorSpace representing the colorspace. "DeviceRGB" is an example.
  +	 */
  +	//protected StringBuffer colorSpace = null;
  +   protected ColorSpace colorSpace=null;
  +	/**
  +	 * The background color. Since shading is opaque,
  +	 * this is very rarely used.
  +	 */
  +	protected Vector background = null;
  +	/**
  +	 * Optional: A Vector specifying the clipping rectangle
  +	 */
  +	protected Vector bBox = null;
  +
  +	/**
  +	 * Optional: A flag whether or not to filter the shading function
  +	 * to prevent aliasing artifacts. Default is false.
  +	 */
  +	protected boolean antiAlias = false;
  +	
  +	/**
  +	 * Optional for Type 1: Array of four numbers, xmin, xmax, ymin, ymax. Default is [0 1 0 1]
  +	 * Optional for Type 2: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
  +	 * Optional for Type 3: An array of two numbers between which the blend varies between start and end points. Default is 0, 1.
  +	 */
  +	
  +	protected Vector domain = null;
  +   
  +   /** Optional for Type 1: A transformation matrix */
  +   protected Vector matrix = null;
  +   
  +   /**
  +    * Required for Type 1, 2, and 3: 
  +    * The object of the color mapping function (usually type 2 or 3).
  +    * Optional for Type 4,5,6, and 7: When it's nearly the same thing.
  +    */
  +   protected PDFFunction function = null;
  +	
  +	/** Required for Type 2: An Array of four numbers specifying the starting and ending coordinate pairs 
  +	 * Required for Type 3: An Array of six numbers [x0,y0,r0,x1,y1,r1] specifying the centers and radii of
  +	 * the starting and ending circles.
  +	 */
  +	protected Vector coords = null;
  +	
  +	/**
  +	 * Required for Type 2+3: An Array of two boolean values specifying whether to extend the
  +	 * start and end colors past the start and end points,
  +	 * respectively. Default is false, false.
  +	 */
  +	protected Vector extend = null;
  +	
  +	/**
  +	 * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each vertex coordinate.
  +	 * Allowed to be 1,2,4,8,12,16,24, or 32.
  +	 */
  +	protected int bitsPerCoordinate = 0;
  +
  +	/**
  +	 * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent the edge flag for each vertex.
  +	 * Allowed to be 2,4,or 8, while the Edge flag itself is allowed to be 0,1 or 2.
  +	 */
  +	protected int bitsPerFlag = 0;
  +
  +	/**
  +	 * Required for Type 4,5,6, and 7: Array of Doubles which specifies how to decode coordinate and color component values.
  +	 * Each type has a differing number of decode array members, so check the spec.
  +	 * Page 303 in PDF Spec 1.3
  +	 */
  +	protected Vector decode = null;
  +
  +	/**
  +	 * Required for Type 4,5,6, and 7: Specifies the number of bits used to represent each color coordinate.
  +	 * Allowed to be 1,2,4,8,12, or 16
  +	 */
  +	protected int bitsPerComponent = 0;
  +
  +	/**
  +	 * Required for Type 5:The number of vertices in each "row" of the lattice; it must be greater than or equal to 2.
  +	 */
  +	protected int verticesPerRow = 0;
  +	
  +	private PDFNumber pdfNumber = new PDFNumber();
  +	
  +	/**
  +	 * Constructor for type function based shading
  +	 * 
  +	 * @param theNumber The object number of this PDF object
  +	 * @param theShadingName The name of the shading pattern. Can be anything
  +	 * without spaces. "Shading1" or "Sh1" are good examples.
  +	 * @param theShadingType The type of shading object, which should be 1 for function
  +	 * based shading.
  +	 * @param theColorSpace The colorspace is 'DeviceRGB' or something similar.
  +	 * @param theBackground An array of color components appropriate to the
  +	 * colorspace key specifying a single color value.
  +	 * This key is used by the f operator buy ignored by the sh operator.
  +	 * @param theBBox Vector of double's representing a rectangle
  +	 * in the coordinate space that is current at the
  +	 * time of shading is imaged. Temporary clipping
  +	 * boundary.
  +	 * @param theAntiAlias Whether or not to anti-alias.
  +	 * @param theDomain Optional vector of Doubles specifying the domain.
  +	 * @param theMatrix Vector of Doubles specifying the matrix.
  +	 * If it's a pattern, then the matrix maps it to pattern space.
  +	 * If it's a shading, then it maps it to current user space.
  +	 * It's optional, the default is the identity matrix
  +	 * @param theFunction The PDF Function that maps an (x,y) location to a color
  +	 */
  +	public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace,
  +		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  +		Vector theDomain, Vector theMatrix, PDFFunction theFunction)
  +	{
  +		super(theNumber);
  +		this.shadingName = theShadingName;
  +		this.shadingType = theShadingType; //1
  +		this.colorSpace=theColorSpace;
  +		this.background= theBackground;
  +		this.bBox = theBBox;
  +		this.antiAlias = theAntiAlias;
  +		
  +		this.domain = theDomain;
  +		this.matrix = theMatrix;
  +		this.function = theFunction;
  +	
  +	}
  +
  +		/**
  +		 * Constructor for Type 2 and 3
  +		 * 
  +		 * @param theNumber The object number of this PDF object.
  +		 * @param theShadingName The name of the shading pattern. Can be anything
  +		 * without spaces. "Shading1" or "Sh1" are good examples.
  +		 * @param theShadingType 2 or 3 for axial or radial shading
  +		 * @param theColorSpace "DeviceRGB" or similar.
  +		 * @param theBackground theBackground An array of color components appropriate to the
  +		 * colorspace key specifying a single color value.
  +		 * This key is used by the f operator buy ignored by the sh operator.
  +		 * @param theBBox Vector of double's representing a rectangle
  +		 * in the coordinate space that is current at the
  +		 * time of shading is imaged. Temporary clipping
  +		 * boundary.
  +		 * @param theAntiAlias Default is false
  +		 * @param theCoords Vector of four (type 2) or 6 (type 3) Double
  +		 * @param theDomain Vector of Doubles specifying the domain
  +		 * @param theFunction the Stitching (PDFfunction type 3) function, even if it's stitching a single function
  +		 * @param theExtend Vector of Booleans of whether to extend teh start and end colors past the start and end points
  +		 * The default is [false, false]
  +		 */
  +	public PDFShading(int theNumber, String theShadingName,
  +		int theShadingType, ColorSpace theColorSpace,
  +		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  +		Vector theCoords, Vector theDomain, PDFFunction theFunction,
  +		Vector theExtend)
  +	{
  +		super(theNumber);
  +		this.shadingName = theShadingName;
  +		this.shadingType=theShadingType; //2 or 3
  +		this.colorSpace=theColorSpace;
  +		this.background= theBackground;
  +		this.bBox = theBBox;
  +		this.antiAlias = theAntiAlias;
  +
  +		this.coords = theCoords;
  +		this.domain = theDomain;
  +		this.function = theFunction;
  +		this.extend=theExtend;
  +	
  +	}
  +	
  +	/**
  +	 * Constructor for Type 4,6, or 7
  +	 * 
  +	 * @param theNumber The object number of this PDF object.
  +	 * @param theShadingType 4, 6, or 7 depending on whether it's
  +	 * Free-form gouraud-shaded triangle meshes, coons patch meshes, 
  +	 * or tensor product patch meshes, respectively.
  +	 * @param theShadingName The name of the shading pattern. Can be anything
  +	 * without spaces. "Shading1" or "Sh1" are good examples.
  +	 * @param theColorSpace "DeviceRGB" or similar.
  +	 * @param theBackground theBackground An array of color components appropriate to the
  +	 * colorspace key specifying a single color value.
  +	 * This key is used by the f operator buy ignored by the sh operator.
  +	 * @param theBBox Vector of double's representing a rectangle
  +	 * in the coordinate space that is current at the
  +	 * time of shading is imaged. Temporary clipping
  +	 * boundary.
  +	 * @param theAntiAlias Default is false
  +	 * @param theBitsPerCoordinate 1,2,4,8,12,16,24 or 32.
  +	 * @param theBitsPerComponent 1,2,4,8,12, and 16
  +	 * @param theBitsPerFlag 2,4,8.
  +	 * @param theDecode Vector of Doubles see PDF 1.3 spec pages 303 to 312.
  +	 * @param theFunction the PDFFunction
  +	 */
  +	public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace,
  +		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  +		int theBitsPerCoordinate, int theBitsPerComponent,
  +		int theBitsPerFlag, Vector theDecode, PDFFunction theFunction)
  +	{
  +		super(theNumber);
  +		
  +		this.shadingType = theShadingType;//4,6 or 7
  +		this.colorSpace = theColorSpace;
  +		this.background= theBackground;
  +		this.bBox = theBBox;
  +		this.antiAlias = theAntiAlias;
  +		
  +		this.bitsPerCoordinate = theBitsPerCoordinate;
  +		this.bitsPerComponent = theBitsPerComponent;
  +		this.bitsPerFlag = theBitsPerFlag;
  +		this.decode = theDecode;
  +		this.function =theFunction;
  +	}
  +
  +	/**
  +	 * Constructor for type 5
  +	 * 
  +	 * @param theShadingType 5 for lattice-Form Gouraud shaded-triangle mesh
  +	 * @param theShadingName The name of the shading pattern. Can be anything
  +	 * without spaces. "Shading1" or "Sh1" are good examples.
  +	 * @param theColorSpace "DeviceRGB" or similar.
  +	 * @param theBackground theBackground An array of color components appropriate to the
  +	 * colorspace key specifying a single color value.
  +	 * This key is used by the f operator buy ignored by the sh operator.
  +	 * @param theBBox Vector of double's representing a rectangle
  +	 * in the coordinate space that is current at the
  +	 * time of shading is imaged. Temporary clipping
  +	 * boundary.
  +	 * @param theAntiAlias Default is false
  +	 * @param theBitsPerCoordinate 1,2,4,8,12,16, 24, or 32
  +	 * @param theBitsPerComponent 1,2,4,8,12,24,32
  +	 * @param theDecode Vector of Doubles. See page 305 in PDF 1.3 spec.
  +	 * @param theVerticesPerRow number of vertices in each "row" of the lattice.
  +	 * @param theFunction The PDFFunction that's mapped on to this shape
  +	 * @param theNumber the object number of this PDF object.
  +	 */
  +	public PDFShading(int theNumber, String theShadingName, int theShadingType, ColorSpace theColorSpace,
  +		Vector theBackground, Vector theBBox, boolean theAntiAlias,
  +		int theBitsPerCoordinate, int theBitsPerComponent,
  +		Vector theDecode, int theVerticesPerRow, PDFFunction theFunction)
  +	{
  +		super(theNumber);
  +		this.shadingName = theShadingName;
  +		this.shadingType = theShadingType;//5
  +		this.colorSpace=theColorSpace;
  +		this.background= theBackground;
  +		this.bBox = theBBox;
  +		this.antiAlias = theAntiAlias;
  +		
  +		this.bitsPerCoordinate = theBitsPerCoordinate;
  +		this.bitsPerComponent = theBitsPerComponent;
  +		this.decode = theDecode;
  +		this.verticesPerRow = theVerticesPerRow;
  +		this.function = theFunction;
  +	
  +	}
  +	
  +	public String getName() {
  +		return (this.shadingName);
  +   }
  +   
  +	 /**
  +	  * represent as PDF. Whatever the shadingType is, the correct
  +	  * representation spits out. The sets of required and optional
  +	  * attributes are different for each type, but if a required
  +	  * attribute's object was constructed as null, then no error
  +	  * is raised. Instead, the malformed PDF that was requested
  +	  * by the construction is dutifully output.
  +	  * This policy should be reviewed.
  +	  * 
  +	  * @return the PDF string.
  +	  */ 
  +	public byte[] toPDF() {
  +		int vectorSize;
  +		int tempInt;
  +		StringBuffer p = new StringBuffer();
  +		p.append(this.number + " " + this.generation 
  +			+ " obj\n<< \n/ShadingType "+this.shadingType+" \n");
  +		if(this.colorSpace != null)
  +		{
  +			p.append("/ColorSpace /"
  +				+this.colorSpace.getColorSpacePDFString()+" \n");
  +		}
  +		
  +		if(this.background != null)
  +		{
  +			p.append("/Background [ ");
  +			vectorSize = this.background.size();
  +			for(tempInt=0; tempInt < vectorSize; tempInt++)
  +			{
  +				p.append(pdfNumber.doubleOut(
  +				(Double)this.background.elementAt(tempInt)) +" ");
  +			}
  +			p.append("] \n");
  +		}
  +		
  +		if(this.bBox != null)
  +		{//I've never seen an example, so I guess this is right.
  +			p.append("/BBox [ ");
  +			vectorSize = this.bBox.size();
  +			for(tempInt=0; tempInt < vectorSize; tempInt++)
  +			{
  +				p.append(pdfNumber.doubleOut(
  +				(Double)this.bBox.elementAt(tempInt)) +" ");
  +			}
  +			p.append("] \n");
  +		}
  +		
  +		if(this.antiAlias)
  +		{
  +			p.append("/AntiAlias "+this.antiAlias+" \n");
  +		}
  +		
  +		//Here's where we differentiate based on what type it is.
  +		if(this.shadingType == 1)
  +		{//function based shading
  +			if(this.domain != null)
  +			{
  +				p.append("/Domain [ ");
  +				vectorSize = this.domain.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.domain.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Domain [ 0 1 ] \n");
  +			}
  +			
  +			if(this.matrix != null)
  +			{
  +				p.append("/Matrix [ ");
  +				vectorSize = this.matrix.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.matrix.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +
  +			if(this.function != null)
  +			{
  +				p.append("/Function ");
  +				p.append(this.function.referencePDF()+" \n");
  +			}
  +		}
  +		else if((this.shadingType == 2)
  +		|| (this.shadingType == 3))
  +		{//2 is axial shading (linear gradient)
  +		//3 is radial shading (circular gradient)	
  +			if(this.coords != null)
  +			{
  +				p.append("/Coords [ ");
  +				vectorSize = this.coords.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.coords.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +			
  +			//DOMAIN
  +			if(this.domain != null)
  +			{
  +				p.append("/Domain [ ");
  +				vectorSize = this.domain.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(pdfNumber.doubleOut(
  +					(Double)this.domain.elementAt(tempInt)) +" ");
  +				}
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Domain [ 0 1 ] \n");
  +			}
  +			
  +			if(this.extend != null)
  +			{
  +				p.append("/Extend [ ");
  +				vectorSize = this.extend.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(((Boolean)this.extend.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +			else
  +			{
  +				p.append("/Extend [ true true ] \n");
  +			}
  +
  +
  +			if(this.function != null)
  +			{
  +				p.append("/Function ");
  +				p.append(this.function.referencePDF()+" \n");
  +			}
  +			
  +			
  +		}
  +		
  +		else if ((this.shadingType == 4) ||
  +					(this.shadingType == 6) ||
  +					(this.shadingType == 7))
  +		{//4:Free-form Gouraud-shaded triangle meshes
  +		// 6:coons patch meshes
  +		// 7://tensor product patch meshes (which no one ever uses)
  +			if(this.bitsPerCoordinate > 0)
  +			{
  +				p.append("/BitsPerCoordinate "+this.bitsPerCoordinate+" \n");
  +			}
  +			else
  +			{
  +				p.append("/BitsPerCoordinate 1 \n");
  +			}
  +			
  +			if(this.bitsPerComponent > 0)
  +			{
  +				p.append("/BitsPerComponent "+this.bitsPerComponent+" \n");
  +			}
  +			else
  +			{
  +				p.append("/BitsPerComponent 1 \n");
  +			}
  +			
  +			if(this.bitsPerFlag > 0)
  +			{
  +				p.append("/BitsPerFlag "+this.bitsPerFlag+" \n");
  +			}
  +			else
  +			{
  +				p.append("/BitsPerFlag 2 \n");
  +			}
  +
  +			if(this.decode != null)
  +			{
  +				p.append("/Decode [ ");
  +				vectorSize = this.decode.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(((Boolean)this.decode.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +		
  +			if(this.function != null)
  +			{
  +				p.append("/Function ");
  +				p.append(this.function.referencePDF()+" \n");
  +			}
  +			
  +		}
  +
  +		else if (this.shadingType == 5)
  +		{ //Lattice Free form gouraud-shaded triangle mesh
  +		 
  +			if(this.bitsPerCoordinate > 0)
  +			{
  +				p.append("/BitsPerCoordinate "+this.bitsPerCoordinate+" \n");
  +			}
  +			else
  +			{
  +				p.append("/BitsPerCoordinate 1 \n");
  +			}
  +			
  +			if(this.bitsPerComponent > 0)
  +			{
  +				p.append("/BitsPerComponent "+this.bitsPerComponent+" \n");
  +			}
  +			else
  +			{
  +				p.append("/BitsPerComponent 1 \n");
  +			}			
  +
  +			if(this.decode != null)
  +			{
  +				p.append("/Decode [ ");
  +				vectorSize = this.decode.size();
  +				for(tempInt=0; tempInt < vectorSize; tempInt++)
  +				{
  +					p.append(((Boolean)this.decode.elementAt(tempInt)) +" ");
  +				}
  +				
  +				p.append("] \n");
  +			}
  +		
  +			if(this.function != null)
  +			{
  +				p.append("/Function ");
  +				p.append(this.function.referencePDF()+" \n");
  +			}
  +			
  +			if(this.verticesPerRow > 0)
  +			{
  +				p.append("/VerticesPerRow "+this.verticesPerRow+" \n");
  +			}
  +			else
  +			{
  +				p.append("/VerticesPerRow 2 \n");
  +			}
  +			
  +		}
  +
  +		p.append(">> \nendobj\n");
  +	
  +		return(p.toString().getBytes());
  +	}
  +}
  
  
  
  1.6       +268 -27   xml-fop/src/org/apache/fop/pdf/PDFStream.java
  
  Index: PDFStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFStream.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PDFStream.java	1999/11/22 02:32:05	1.5
  +++ PDFStream.java	2000/12/18 02:28:34	1.6
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFStream.java,v 1.5 1999/11/22 02:32:05 jtauber Exp $ -- 
  +/*-- $Id: PDFStream.java,v 1.6 2000/12/18 02:28:34 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -50,6 +50,14 @@
    */
   package org.apache.fop.pdf;
   
  +import java.io.ByteArrayOutputStream;
  +import java.io.OutputStream;
  +import java.io.IOException;
  +import java.util.Vector;
  +import java.util.Enumeration;
  +import org.apache.fop.configuration.Configuration;
  +import org.apache.fop.messaging.MessageHandler;
  +
   /**
    * class representing a PDF stream.
    * 
  @@ -61,8 +69,11 @@
   public class PDFStream extends PDFObject {
   
       /** the stream of PDF commands */
  -    protected StringBuffer data = new StringBuffer();
  +    private ByteArrayOutputStream _data;
   
  +    /** the filters that should be applied */
  +    private Vector _filters;
  +    
       /**
        * create an empty stream object
        *
  @@ -70,6 +81,8 @@
        */
       public PDFStream(int number) {
   	super(number);
  +	_data = new ByteArrayOutputStream();
  +	_filters = new Vector();
       }
   
       /**
  @@ -78,8 +91,71 @@
        * @param s the string of PDF to add
        */
       public void add(String s) {
  -	this.data = this.data.append(s);
  +	try {
  +	    _data.write(s.getBytes());
  +	}
  +	catch (IOException ex) {
  +	    ex.printStackTrace();
  +	}
  +	
  +    }
  +
  +    /**
  +     * Add a filter for compression of the stream. Filters are
  +     * applied in the order they are added. This should always be a 
  +     * new instance of the particular filter of choice. The applied
  +     * flag in the filter is marked true after it has been applied to the
  +     * data.
  +     */
  +    public void addFilter(PDFFilter filter) 
  +    {
  +	if (filter != null) {
  +	    _filters.add(filter);
  +	}
  +
  +    }
  +
  +    public void addFilter(String filterType) 
  +    {
  +	if (filterType.equals("flate")) {
  +	    addFilter(new FlateFilter());
  +	}
  +	else if (filterType.equals("ascii-85")) {
  +	    addFilter(new ASCII85Filter());
  +	}
  +	else if (filterType.equals("ascii-hex")) {
  +	    addFilter(new ASCIIHexFilter());
  +	}
  +	else {
  +	    MessageHandler.errorln("Unsupported filter type in stream-filter-list: "+filterType);
  +	}
  +    }
  +    
  +
  +    protected void addDefaultFilters() 
  +    {
  +	Vector filters = Configuration.getListValue("stream-filter-list",
  +						    Configuration.PDF);
  +	if (filters == null) {
  +	    // try getting it as a String
  +	    String filter = Configuration.getStringValue("stream-filter-list",
  +							 Configuration.PDF);
  +	    if (filter == null) {
  +		// built-in default to flate
  +		addFilter(new FlateFilter());
  +	    }
  +	    else {
  +		addFilter(filter);
  +	    }
  +	}
  +	else {
  +	    for (int i=0; i < filters.size(); i++) {
  +		String v = (String)filters.elementAt(i);
  +		addFilter(v);
  +	    }
  +	}
       }
  +    
   
       /**
        * append an array of xRGB pixels, ASCII Hex Encoding it first
  @@ -89,39 +165,204 @@
        * @param height the height of the image in pixels
        */
       public void addImageArray(int[] pixels, int width, int height) {
  -	for (int i = 0; i < height; i++) {
  -	    for (int j = 0; j < width; j++) {
  -		int p = pixels[i * width + j];
  -		int r = (p >> 16) & 0xFF;
  -		int g = (p >>  8) & 0xFF;
  -		int b = (p      ) & 0xFF;
  -		if (r < 16) {
  -		    this.data = this.data.append(0);
  -		}
  -		this.data = this.data.append(Integer.toHexString(r));
  -		if (g < 16) {
  -		    this.data = this.data.append(0);
  +	try {
  +	    for (int i = 0; i < height; i++) {
  +		for (int j = 0; j < width; j++) {
  +		    int p = pixels[i * width + j];
  +		    int r = (p >> 16) & 0xFF;
  +		    int g = (p >>  8) & 0xFF;
  +		    int b = (p      ) & 0xFF;
  +		    if (r < 16) {
  +			_data.write('0');
  +		    }
  +		    _data.write(Integer.toHexString(r).getBytes());
  +		    if (g < 16) {
  +			_data.write('0');
  +		    }
  +		    _data.write(Integer.toHexString(g).getBytes());
  +		    if (b < 16) {
  +			_data.write('0');
  +		    }
  +		    _data.write(Integer.toHexString(b).getBytes());
  +		    _data.write(' ');
   		}
  -		this.data = this.data.append(Integer.toHexString(g));
  -		if (b < 16) {
  -		    this.data = this.data.append(0);
  -		}
  -		this.data = this.data.append(Integer.toHexString(b));
  -		this.data = this.data.append(" ");
   	    }
  +	    _data.write(">\n".getBytes());
  +	}
  +	catch (IOException ex) {
  +	    ex.printStackTrace();
   	}
  -	this.data = this.data.append(">\n");
  +	
       }
   
  +    public void setData(byte[] data) 
  +	throws IOException
  +    {
  +	_data.reset();
  +	_data.write(data);
  +    }
  +    
  +    public byte[] getData() 
  +    {
  +	return _data.toByteArray();
  +    }
  +    
  +    public int getDataLength() 
  +    {
  +	return _data.size();
  +    }
  +    
  +    
  +
       /**
        * represent as PDF.
        *
        * @return the PDF string.
        */ 
  -    public String toPDF() {
  -	String p = this.number + " " + this.generation
  -	    + " obj\n<< /Length " + (this.data.length()+1)
  -	    + " >>\nstream\n" + this.data + "\nendstream\nendobj\n";
  -	return p;
  +    /*
  +    public byte[] toPDF() {
  +	byte[] d = _data.toByteArray();
  +	ByteArrayOutputStream s = new ByteArrayOutputStream();
  +       	String p = this.number + " " + this.generation
  +	    + " obj\n<< /Length " + (d.length+1)
  +	    + " >>\nstream\n";
  +	s.write(p.getBytes());
  +	s.write(d);
  +	s.write("\nendstream\nendobj\n".getBytes());
  +	return s.toByteArray();
  +    }
  +    */
  +    public byte[] toPDF() {
  +	throw new UnsupportedOperationException();
  +    }
  +    
  +
  +    // overload the base object method so we don't have to copy 
  +    // byte arrays around so much
  +    protected int output(OutputStream stream) throws IOException 
  +    {
  +	int length = 0;
  +	String filterEntry = applyFilters();
  +	byte[] p = (this.number + " " + this.generation
  +		    + " obj\n<< /Length " + (_data.size()+1) + " "
  +		    + filterEntry + " >>\n").getBytes();
  +	
  +	stream.write(p);
  +	length += p.length;
  +	length += outputStreamData(stream);
  +	p = "endobj\n".getBytes();
  +	stream.write(p);
  +	length += p.length;
  +	return length;
  +	
  +    }
  +
  +    /**
  +     * Output just the stream data enclosed by stream/endstream markers
  +     */
  +    protected int outputStreamData(OutputStream stream) throws IOException
  +    {
  +	int length = 0;
  +	byte[] p ="stream\n".getBytes();
  +	stream.write(p);
  +	length += p.length;
  +	_data.writeTo(stream);
  +	length += _data.size();
  +	p = "\nendstream\n".getBytes();
  +	stream.write(p);
  +	length += p.length;
  +	return length;
  +	
       }
  +    
  +    
  +    /**
  +     * Apply the filters to the data
  +     * in the order given and return the /Filter and /DecodeParms
  +     * entries for the stream dictionary. If the filters have already
  +     * been applied to the data (either externally, or internally)
  +     * then the dictionary entries are built and returned.
  +     */
  +    protected String applyFilters() throws IOException
  +    {
  +	if (_filters.size() > 0) {
  +	    Vector names = new Vector();
  +	    Vector parms = new Vector();
  +	    
  +	    // run the filters
  +	    Enumeration e = _filters.elements();
  +	    while (e.hasMoreElements()) {
  +		PDFFilter filter = (PDFFilter)e.nextElement();
  +		// apply the filter encoding if neccessary
  +		if (!filter.isApplied()) {
  +		    byte[] tmp = filter.encode(_data.toByteArray());
  +		    _data.reset();
  +		    _data.write(tmp);
  +		    filter.setApplied(true);
  +		}
  +		// place the names in our local vector in reverse order
  +		names.add(0, filter.getName()); 
  +		parms.add(0, filter.getDecodeParms());
  +	    }
  +	    	    
  +	    // now build up the filter entries for the dictionary
  +	    return buildFilterEntries(names) + buildDecodeParms(parms);
  +	}    
  +	return "";
  +	
  +    }
  +    
  +    private String buildFilterEntries(Vector names) 
  +    {
  +	StringBuffer sb = new StringBuffer();
  +	sb.append("/Filter ");
  +	if (names.size() > 1) {
  +	    sb.append("[ ");
  +	}
  +	Enumeration e = names.elements();
  +	while (e.hasMoreElements()) {
  +	    sb.append((String)e.nextElement());
  +	    sb.append(" ");
  +	}
  +	if (names.size() > 1) {
  +	    sb.append("]");
  +	}
  +	sb.append("\n");
  +	return sb.toString();
  +    }
  +
  +    private String buildDecodeParms(Vector parms) 
  +    {
  +	StringBuffer sb = new StringBuffer();
  +	boolean needParmsEntry = false;
  +	sb.append("/DecodeParms ");
  +	
  +	if (parms.size() > 1) {
  +	    sb.append("[ ");
  +	}
  +	Enumeration e = parms.elements();
  +	while (e.hasMoreElements()) {
  +	    String s = (String)e.nextElement();
  +	    if (s != null) {
  +		sb.append(s);
  +		needParmsEntry = true;
  +	    }
  +	    else {
  +		sb.append("null");
  +	    }
  +	    sb.append(" ");
  +	}
  +	if (parms.size() > 1) {
  +	    sb.append("]");
  +	}
  +	sb.append("\n");
  +	if (needParmsEntry) {
  +	    return sb.toString();
  +	}
  +	else {
  +	    return "";
  +	}
  +    }
  +    
  +
   }
  
  
  
  1.2       +91 -91    xml-fop/src/org/apache/fop/pdf/PDFUri.java
  
  Index: PDFUri.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFUri.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PDFUri.java	2000/06/14 01:52:49	1.1
  +++ PDFUri.java	2000/12/18 02:28:34	1.2
  @@ -1,91 +1,91 @@
  -/*-- $Id: PDFUri.java,v 1.1 2000/06/14 01:52:49 arved Exp $ -- 
  -
  - ============================================================================
  -                   The Apache Software License, Version 1.1
  - ============================================================================
  - 
  -    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  - 
  - Redistribution and use in source and binary forms, with or without modifica-
  - tion, are permitted provided that the following conditions are met:
  - 
  - 1. Redistributions of  source code must  retain the above copyright  notice,
  -    this list of conditions and the following disclaimer.
  - 
  - 2. Redistributions in binary form must reproduce the above copyright notice,
  -    this list of conditions and the following disclaimer in the documentation
  -    and/or other materials provided with the distribution.
  - 
  - 3. The end-user documentation included with the redistribution, if any, must
  -    include  the following  acknowledgment:  "This product includes  software
  -    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  -    Alternately, this  acknowledgment may  appear in the software itself,  if
  -    and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  -    endorse  or promote  products derived  from this  software without  prior
  -    written permission. For written permission, please contact
  -    apache@apache.org.
  - 
  - 5. Products  derived from this software may not  be called "Apache", nor may
  -    "Apache" appear  in their name,  without prior written permission  of the
  -    Apache Software Foundation.
  - 
  - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  - FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  - APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  - INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  - DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  - OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  - ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  - (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  - This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation and was  originally created by
  - James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  - Software Foundation, please see <http://www.apache.org/>.
  - 
  - */
  -
  -package org.apache.fop.pdf;
  -
  -/**
  - * class used to create a PDF Uri link
  - */
  -public class PDFUri extends PDFAction {
  -
  -    
  -    String uri;
  -
  -    /**
  -     * create a Uri instance.
  -     *
  -     * @param uri the uri to which the link should point     
  -     */
  -    public PDFUri(String uri) {
  -
  -	this.uri=uri;
  -    }
  -
  -    /**
  -     * returns the action ncecessary for a uri
  -     *     
  -     * @return the action to place next to /A within a Link
  -     */
  -    public String getAction()
  -    {
  -        return "<< /URI ("+uri+")\n/S /URI >>";
  -    }
  -
  -    /**
  -     * there is nothing to return for the toPDF method, as it should not be called 
  -     *
  -     * @return an empty string
  -     */
  -    public String toPDF() {	
  -	return "";
  -    } 
  -    
  -}
  +/*-- $Id: PDFUri.java,v 1.2 2000/12/18 02:28:34 kellyc Exp $ -- 
  +
  + ============================================================================
  +                   The Apache Software License, Version 1.1
  + ============================================================================
  + 
  +    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
  + 
  + Redistribution and use in source and binary forms, with or without modifica-
  + tion, are permitted provided that the following conditions are met:
  + 
  + 1. Redistributions of  source code must  retain the above copyright  notice,
  +    this list of conditions and the following disclaimer.
  + 
  + 2. Redistributions in binary form must reproduce the above copyright notice,
  +    this list of conditions and the following disclaimer in the documentation
  +    and/or other materials provided with the distribution.
  + 
  + 3. The end-user documentation included with the redistribution, if any, must
  +    include  the following  acknowledgment:  "This product includes  software
  +    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +    Alternately, this  acknowledgment may  appear in the software itself,  if
  +    and wherever such third-party acknowledgments normally appear.
  + 
  + 4. The names "FOP" and  "Apache Software Foundation"  must not be used to
  +    endorse  or promote  products derived  from this  software without  prior
  +    written permission. For written permission, please contact
  +    apache@apache.org.
  + 
  + 5. Products  derived from this software may not  be called "Apache", nor may
  +    "Apache" appear  in their name,  without prior written permission  of the
  +    Apache Software Foundation.
  + 
  + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  + FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  + APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  + INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  + DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  + OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  + ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  + (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  + 
  + This software  consists of voluntary contributions made  by many individuals
  + on  behalf of the Apache Software  Foundation and was  originally created by
  + James Tauber <jt...@jtauber.com>. For more  information on the Apache 
  + Software Foundation, please see <http://www.apache.org/>.
  + 
  + */
  +
  +package org.apache.fop.pdf;
  +
  +/**
  + * class used to create a PDF Uri link
  + */
  +public class PDFUri extends PDFAction {
  +
  +    
  +    String uri;
  +
  +    /**
  +     * create a Uri instance.
  +     *
  +     * @param uri the uri to which the link should point     
  +     */
  +    public PDFUri(String uri) {
  +
  +	this.uri=uri;
  +    }
  +
  +    /**
  +     * returns the action ncecessary for a uri
  +     *     
  +     * @return the action to place next to /A within a Link
  +     */
  +    public String getAction()
  +    {
  +        return "<< /URI ("+uri+")\n/S /URI >>";
  +    }
  +
  +    /**
  +     * there is nothing to return for the toPDF method, as it should not be called 
  +     *
  +     * @return an empty string
  +     */
  +    public byte[] toPDF() {	
  +	return new byte[0];
  +    } 
  +    
  +}
  
  
  
  1.10      +20 -17    xml-fop/src/org/apache/fop/pdf/PDFXObject.java
  
  Index: PDFXObject.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFXObject.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PDFXObject.java	2000/06/27 22:14:15	1.9
  +++ PDFXObject.java	2000/12/18 02:28:34	1.10
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFXObject.java,v 1.9 2000/06/27 22:14:15 fotis Exp $ -- 
  +/*-- $Id: PDFXObject.java,v 1.10 2000/12/18 02:28:34 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -56,7 +56,7 @@
   // Java
   import java.io.IOException;
   import org.apache.fop.messaging.MessageHandler;
  -import java.io.PrintWriter;
  +import java.io.OutputStream;
   
   // FOP
   import org.apache.fop.datatypes.ColorSpace;
  @@ -98,21 +98,24 @@
       /**
        * represent as PDF
        */
  -    protected int output(PrintWriter writer) throws IOException {
  +    protected int output(OutputStream stream) throws IOException {
   	int length=0;
   	int i=0;
   	int x,y;
   
   	try {
  -		PDFBinaryStream imgStream = new PDFBinaryStream();
  +	    // delegate the stream work to PDFStream
  +	    PDFStream imgStream = new PDFStream(0);
  +	    
   		imgStream.setData(fopimage.getBitmaps());
  -		imgStream.encode(new PDFFilter(PDFFilter.FLATE_DECODE));
  -		imgStream.encode(new PDFFilter(PDFFilter.ASCII_HEX_DECODE));
  +		imgStream.addFilter(new FlateFilter());
  +		String dictEntries = imgStream.applyFilters();
   
   		String p = this.number + " " + this.generation + " obj\n";
   		p = p + "<</Type /XObject\n";
   		p = p + "/Subtype /Image\n";
   		p = p + "/Name /Im" + Xnum + "\n";
  +		p = p + "/Length " + imgStream.getDataLength();
   		p = p + "/Width " + fopimage.getWidth() + "\n";
   		p = p + "/Height " + fopimage.getHeight() + "\n";
   		p = p + "/BitsPerComponent " + fopimage.getBitsPerPixel() + "\n";
  @@ -122,30 +125,30 @@
   			PDFColor transp = fopimage.getTransparentColor();
   			p = p + "/Mask [" + transp.red255() + " " + transp.red255() + " " + transp.green255() + " " + transp.green255() + " " + transp.blue255() + " " + transp.blue255() + "]\n";
   		}
  -		p = p + imgStream.getPDFDictionary();
  +		p = p + dictEntries;
   		p = p + ">>\n";
   
   		// don't know if it's the good place (other objects can have references to it)
   		fopimage.close();
   
   		// push the pdf dictionary on the writer
  -		writer.write(p);
  -		length += p.length();
  +		byte[] pdfBytes = p.getBytes();
  +		stream.write(pdfBytes);
  +		length += pdfBytes.length;
   		// push all the image data on  the writer and takes care of length for trailer
  -		length += imgStream.outputPDFStream(writer);
  +		length += imgStream.outputStreamData(stream);
   
  -		p = "endobj\n";
  -		writer.write(p);
  -		length += p.length();
  +		pdfBytes = ("endobj\n").getBytes();
  +		stream.write(pdfBytes);
  +		length += pdfBytes.length;
   	} catch (FopImageException imgex) {
  -MessageHandler.errorln("Error in XObject : " + imgex.getMessage());
  -	} catch (PDFFilterException filterex) {
  -MessageHandler.errorln("Error in XObject : " + filterex.getMessage());
  +	    MessageHandler.errorln("Error in XObject : " + imgex.getMessage());
   	}
  +
   	return length;
       }
       
  -    String toPDF() {
  +    byte[] toPDF() {
   /* Not used any more
   	String p = this.number + " " + this.generation + " obj\n";
   	p = p + "<</Type /XObject\n";
  
  
  
  1.1                  xml-fop/src/org/apache/fop/pdf/ASCII85Filter.java
  
  Index: ASCII85Filter.java
  ===================================================================
  /*-- $Id: ASCII85Filter.java,v 1.1 2000/12/18 02:28:31 kellyc Exp $ -- 
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
      Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
   
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
   
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
   
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
   
   4. The names "Fop" and  "Apache Software Foundation"  must not be used to
      endorse  or promote  products derived  from this  software without  prior
      written permission. For written permission, please contact
      apache@apache.org.
   
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
   
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   James Tauber <jt...@jtauber.com>. For more  information on the Apache 
   Software Foundation, please see <http://www.apache.org/>.
   
   */
  package org.apache.fop.pdf;
  
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  
  public class ASCII85Filter extends PDFFilter
  {
      private static final char ASCII85_ZERO = 'z';
      private static final char ASCII85_START = '!';
      private static final String ASCII85_EOD   = "~>";
      
      private static final long base85_4 = 85;
      private static final long base85_3 = base85_4 * base85_4;
      private static final long base85_2 = base85_3 * base85_4;
      private static final long base85_1 = base85_2 * base85_4;
      
  
     
      public String getName() 
      {
  	return "/ASCII85Decode";
      }
      
      public String getDecodeParms() 
      {
  	return null;
      }
  
      public byte[] encode(byte[] data) 
      {
  	
  	StringBuffer buffer = new StringBuffer();
  	int i;
  	int total = 0;
  	int diff = 0;
  	
  	for (i = 0; i+3 < data.length; i+=4) {
  	    byte b1 = data[i];
  	    byte b2 = data[i+1];
  	    byte b3 = data[i+2];
  	    byte b4 = data[i+3];
  	    
  	    long val = ((b1 << 24) & 0xff000000L) 
  		+ ((b2 << 16) & 0xff0000L) 
  		+ ((b3 << 8) & 0xff00L) 
  		+ (b4 & 0xffL);
  	    String conv = convertLong(val);
  	    
  	    buffer.append(conv);
  
  	    
  	}
  
  	
  	if (i < data.length) {
  	    int n = data.length - i;
  	    byte b1,b2,b3,b4;
  	    b1 = data[i++];
  	    if (i < data.length) {
  		b2 = data[i++];
  	    }
  	    else {
  		b2 = 0;
  	    }
  	    if (i < data.length) {
  		b3 = data[i++];
  	    }
  	    else {
  		b3 = 0;
  	    }
  	    // assert i = data.length
  	    b4 = 0;
  	   
  	    long val = ((b1 << 24) & 0xff000000L) 
  		+ ((b2 << 16) & 0xff0000L) 
  		+ ((b3 << 8) & 0xff00L) 
  		+ (b4 & 0xffL);
  	    String converted = convertLong(val);
  	    
  	    // special rule for handling zeros at the end
  	    if (val == 0) {
  		converted = "!!!!!";
  	    }
  	    buffer.append(converted.substring(0,n));
  	}
  	buffer.append(ASCII85_EOD);
  	return buffer.toString().getBytes();
  	
      }
      
      private String convertLong(long val) 
      {
  	val = val & 0xffffffff;
  	if (val < 0) {
  	    val = -val;
  	}
  	
  	if (val == 0) {
  	    return new Character(ASCII85_ZERO).toString();
  	}
  	else {
  	    byte c1 = (byte)((val / base85_1) & 0xFF);
  	    byte c2 = (byte)(((val - (c1 * base85_1)) / base85_2) & 0xFF);
  	    byte c3 = (byte)(((val 
  		       - (c1 * base85_1) 
  		       - (c2 * base85_2) 
  		       ) / base85_3) & 0xFF);
  	    byte c4 = (byte)(((val 
  		       - (c1 * base85_1) 
  		       - (c2 * base85_2)
  		       - (c3 * base85_3)
  		       ) / base85_4) & 0xFF);
  	    byte c5 = (byte)(((val 
  		       - (c1 * base85_1) 
  		       - (c2 * base85_2)
  		       - (c3 * base85_3)
  		       - (c4 * base85_4))) & 0xFF);
  			
  	    char[] ret = {(char)(c1+ASCII85_START),
  			   (char)(c2+ASCII85_START),
  			   (char)(c3+ASCII85_START),
  			   (char)(c4+ASCII85_START),
  			   (char)(c5+ASCII85_START)};
  	    for (int i = 0; i< ret.length; i++) {
  		if (ret[i] < 33 || ret[i] > 117) {
  		    System.out.println("illegal char value "+new Integer(ret[i]));
  		}
  	    }
  	    
  	    return new String(ret);
  	    	    
  	}	
      }
  
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/pdf/ASCIIHexFilter.java
  
  Index: ASCIIHexFilter.java
  ===================================================================
  /*-- $Id: ASCIIHexFilter.java,v 1.1 2000/12/18 02:28:31 kellyc Exp $ -- 
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
      Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
   
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
   
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
   
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
   
   4. The names "Fop" and  "Apache Software Foundation"  must not be used to
      endorse  or promote  products derived  from this  software without  prior
      written permission. For written permission, please contact
      apache@apache.org.
   
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
   
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   James Tauber <jt...@jtauber.com>. For more  information on the Apache 
   Software Foundation, please see <http://www.apache.org/>.
   
   */
  package org.apache.fop.pdf;
  
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  
  public class ASCIIHexFilter extends PDFFilter
  {
      private static final String ASCIIHEX_EOD = ">";
      
  
      public String getName() 
      {
  	return "/ASCIIHexDecode";
      }
      
      public String getDecodeParms() 
      {
  	return null;
      }
  
      public byte[] encode(byte[] data) 
      {
  	
  	StringBuffer buffer = new StringBuffer();
  	for (int i = 0; i < data.length; i++) {
  	    int val = (int) (data[i] & 0xFF);
  	    if (val < 16) buffer.append("0");
  	    buffer.append(Integer.toHexString(val));
  	}
  	buffer.append(ASCIIHEX_EOD);
  	
  	return buffer.toString().getBytes();
  	
      }
      
  }
  
  
  
  1.1                  xml-fop/src/org/apache/fop/pdf/FlateFilter.java
  
  Index: FlateFilter.java
  ===================================================================
  /*-- $Id: FlateFilter.java,v 1.1 2000/12/18 02:28:31 kellyc Exp $ -- 
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
      Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
   
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
   
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
   
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
   
   4. The names "Fop" and  "Apache Software Foundation"  must not be used to
      endorse  or promote  products derived  from this  software without  prior
      written permission. For written permission, please contact
      apache@apache.org.
   
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
   
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   James Tauber <jt...@jtauber.com>. For more  information on the Apache 
   Software Foundation, please see <http://www.apache.org/>.
   
   */
  package org.apache.fop.pdf;
  
  import java.io.ByteArrayOutputStream;
  import java.io.IOException;
  import java.util.zip.DeflaterOutputStream;
  
  /**
   * A filter to deflate a stream. Note that the attributes for
   * prediction, colors, bitsPerComponent, and columns are not supported
   * when this filter is used to handle the data compression. They are
   * only valid for externally encoded data such as that from a graphics
   * file. 
   */
  public class FlateFilter extends PDFFilter {
  
      public static final int PREDICTION_NONE = 1;
      public static final int PREDICTION_TIFF2 = 2;
      public static final int PREDICTION_PNG_NONE = 10;
      public static final int PREDICTION_PNG_SUB  = 11;
      public static final int PREDICTION_PNG_UP   = 12;
      public static final int PREDICTION_PNG_AVG  = 13;
      public static final int PREDICTION_PNG_PAETH= 14;
      public static final int PREDICTION_PNG_OPT  = 15;
     
      
      private int _predictor = PREDICTION_NONE;
      private int _colors;
      private int _bitsPerComponent;
      private int _columns;
      
      public String getName() 
      {
  	return "/FlateDecode";
      }
      
      public String getDecodeParms() 
      {
  	if (_predictor > PREDICTION_NONE) {
  	    StringBuffer sb = new StringBuffer();
  	    sb.append("<< /Predictor ");
  	    sb.append(_predictor);
  	    if (_colors > 0) {
  		sb.append(" /Colors "+_colors);
  	    }
  	    if (_bitsPerComponent > 0) {
  		sb.append(" /BitsPerComponent "+_bitsPerComponent);
  	    }
  	    if (_columns > 0) {
  		sb.append(" /Columns "+_columns);
  	    }
  	    sb.append(" >> ");
  	    return sb.toString();
  	}
  	return null;
      }
      
  
      /**
       * Encode the given data and return it. Note: a side effect of
       * this method is that it resets the prediction to the default
       * because these attributes are not supported. So the DecodeParms
       * should be retrieved after calling this method.  
       */
      public byte[] encode(byte[] data) 
      {
  	ByteArrayOutputStream outArrayStream = new ByteArrayOutputStream();
   	_predictor = PREDICTION_NONE;
  	try {
   	    DeflaterOutputStream compressedStream = 
  		new DeflaterOutputStream(outArrayStream);
  	    compressedStream.write(data, 0, data.length);
   	    compressedStream.flush();
   	    compressedStream.close();
   	}
   	catch (IOException e) {
   	    org.apache.fop.messaging.MessageHandler.error("Fatal error: "+
  							  e.getMessage());
   	    e.printStackTrace();
   	}
   	
   	return outArrayStream.toByteArray();
      }
      
      public void setPredictor(int predictor)
  	throws PDFFilterException
      {
  	_predictor = predictor;
  	
      }
  
      public int getPredictor() 
      {
  	return _predictor;
      }
      
      
      public void setColors(int colors)
  	throws PDFFilterException
      {
  	if (_predictor != PREDICTION_NONE) {
  	    _colors = colors;
  	}
  	else {
  	    throw new PDFFilterException
  		("Prediction must not be PREDICTION_NONE in order to set Colors");
  	}
      }
  
      public int getColors() 
      {
  	return _colors;
      }
      
  
      public void setBitsPerComponent(int bits) 
  	throws PDFFilterException
      {
  	if (_predictor != PREDICTION_NONE) {
  	    _bitsPerComponent = bits;
  	}
      	else {
  	    throw new PDFFilterException
  		("Prediction must not be PREDICTION_NONE in order to set bitsPerComponent");
  	}
      }
  
      public int getBitsPerComponent() 
      {
  	return _bitsPerComponent;
      }
      
  
      public void setColumns(int columns)
  	throws PDFFilterException
      {
  	if (_predictor != PREDICTION_NONE) {
  	    _columns = columns;
  	}
  	else {
  	    throw new PDFFilterException
  		("Prediction must not be PREDICTION_NONE in order to set Columns");
  	}
      }
  
      public int getColumns() 
      {
  	return _columns;
      }
      
  
  }
  
  
  
  1.10      +3 -3      xml-fop/src/org/apache/fop/render/Renderer.java
  
  Index: Renderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/Renderer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Renderer.java	2000/11/25 17:04:21	1.9
  +++ Renderer.java	2000/12/18 02:28:39	1.10
  @@ -1,4 +1,4 @@
  -/*-- $Id: Renderer.java,v 1.9 2000/11/25 17:04:21 fotis Exp $ -- 
  +/*-- $Id: Renderer.java,v 1.10 2000/12/18 02:28:39 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -57,7 +57,7 @@
   import org.apache.fop.layout.*;
   
   // Java
  -import java.io.PrintWriter;
  +import java.io.OutputStream;
   import java.io.IOException;
   
   /**
  @@ -75,7 +75,7 @@
       public void setProducer(String producer);
   
       /** render the given area tree to the given writer */
  -    public void render(AreaTree areaTree, PrintWriter writer) throws IOException, FOPException;
  +    public void render(AreaTree areaTree, OutputStream stream) throws IOException, FOPException;
    
       /** render the given area container */
       public void renderAreaContainer(AreaContainer area);
  
  
  
  1.14      +1 -1      xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java
  
  Index: AWTRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/awt/AWTRenderer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AWTRenderer.java	2000/11/25 17:04:22	1.13
  +++ AWTRenderer.java	2000/12/18 02:28:40	1.14
  @@ -258,7 +258,7 @@
       }
   
       public void render(AreaTree areaTree,
  -                       PrintWriter writer) throws IOException {
  +                       OutputStream stream) throws IOException {
           tree = areaTree;
           render(areaTree, 0);
       }
  
  
  
  1.42      +5 -5      xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- PDFRenderer.java	2000/12/02 22:04:06	1.41
  +++ PDFRenderer.java	2000/12/18 02:28:40	1.42
  @@ -1,4 +1,4 @@
  -/*-- $Id: PDFRenderer.java,v 1.41 2000/12/02 22:04:06 fotis Exp $ --
  +/*-- $Id: PDFRenderer.java,v 1.42 2000/12/18 02:28:40 kellyc Exp $ --
   
    ============================================================================
   				   The Apache Software License, Version 1.1
  @@ -78,7 +78,7 @@
   
   // Java
   import java.io.IOException;
  -import java.io.PrintWriter;
  +import java.io.OutputStream;
   import java.util.Enumeration;
   import java.awt.Rectangle;
   import java.util.Vector;
  @@ -160,10 +160,10 @@
          * render the areas into PDF
          *
          * @param areaTree the laid-out area tree
  -       * @param writer the PrintWriter to write the PDF with
  +       * @param stream the OutputStream to write the PDF to
          */
       public void render(AreaTree areaTree,
  -                       PrintWriter writer) throws IOException, FOPException {
  +                       OutputStream stream) throws IOException, FOPException {
           MessageHandler.logln("rendering areas to PDF");
           idReferences = areaTree.getIDReferences();
           this.pdfResources = this.pdfDoc.getResources();
  @@ -181,7 +181,7 @@
           }
   
           MessageHandler.logln("writing out PDF");
  -        this.pdfDoc.output(writer);
  +        this.pdfDoc.output(stream);
       }
   
       /**
  
  
  
  1.12      +4 -3      xml-fop/src/org/apache/fop/render/xml/XMLRenderer.java
  
  Index: XMLRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/xml/XMLRenderer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- XMLRenderer.java	2000/11/25 17:04:24	1.11
  +++ XMLRenderer.java	2000/12/18 02:28:40	1.12
  @@ -1,4 +1,4 @@
  -/*-- $Id: XMLRenderer.java,v 1.11 2000/11/25 17:04:24 fotis Exp $ -- 
  +/*-- $Id: XMLRenderer.java,v 1.12 2000/12/18 02:28:40 kellyc Exp $ -- 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -64,6 +64,7 @@
   // Java
   import java.io.IOException;
   import java.io.PrintWriter;
  +import java.io.OutputStream;
   import java.util.Enumeration;
   
   /**
  @@ -95,10 +96,10 @@
        * @param areaTree the laid-out area tree
        * @param writer the PrintWriter to give the XML to
        */
  -    public void render(AreaTree areaTree, PrintWriter writer)
  +    public void render(AreaTree areaTree, OutputStream stream)
   	throws IOException {
   	MessageHandler.logln("rendering areas to XML");
  -	this.writer = writer;
  +	this.writer = new PrintWriter(stream);
   	this.writer.write("<?xml version=\"1.0\"?>\n<!-- produced by "
   			  + this.producer + " -->\n");
   	writeStartTag("<AreaTree>");