Index: src/org/apache/fop/pdf/PDFDocument.java
===================================================================
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
retrieving revision 1.30.2.5
diff -u -r1.30.2.5 PDFDocument.java
--- src/org/apache/fop/pdf/PDFDocument.java	8 Nov 2002 10:25:26 -0000	1.30.2.5
+++ src/org/apache/fop/pdf/PDFDocument.java	12 Nov 2002 21:27:56 -0000
@@ -231,7 +231,6 @@
     /**
      * make an /Info object
      *
-     * @param producer string indicating application producing the PDF
      * @return the created /Info object
      */
     protected PDFInfo makeInfo() {
@@ -1181,7 +1180,7 @@
     /**
      * write the entire document out
      *
-     * @param writer the OutputStream to output the document to
+     * @param stream the OutputStream to output the document to
      */
     public void output(OutputStream stream) throws IOException {
 
@@ -1215,11 +1214,16 @@
      * and outputting AreaTrees.
      *
      * @param stream the OutputStream to write the header to
-     * @return the number of bytes written
      */
     public void outputHeader(OutputStream stream)
     throws IOException {
-        this.position=0;
+    	
+    	// prevent to output 2 times the header
+    	// it seems that if you have a Xalan transformer as SAXReader,
+    	// it calls two times the startDocument SAX callback.
+        if (this.position>0) {
+            return;
+        }
 
         byte[] pdf;
         try {
@@ -1237,7 +1241,6 @@
         };
         stream.write(bin);
         this.position += bin.length;
-
         this.resources.setXObjects(xObjects);
     }
 
@@ -1278,6 +1281,9 @@
             trailer = pdf.getBytes();
         }
         stream.write(trailer);
+
+    	// reset position to 0
+        this.position= 0;
     }
 
     /**
