I'm using embedded code. I start with a string, which is the file name and path. That is the input parameter to create a FileOutputStream object. That is the input parameter to create a BufferedOutputStream object. I never tell it to write anything to this stream. The BufferedOutputStream can be used as an input parameter to the FopFactory.newFop method. Then I use the getDefaultHandler method from the Fop object that creates and make a SAXResult object. The SAXResult is the input to a javax Transformer. The transform method of the Transformer creates the PDF when using this type of OutputStream. It writes it but it doesn't finish it so I have to manually execute the close method of the BufferedOutputStream after the transform.
I was only using this to test if this fixed a problem with the font. I changed it back to the other type of OutputStream and switched the fop.jar back to the 0.95 and that fixed my font issue, where I'm trying to pass in unicode to print a checkbox. 0.95 prints a box. 1.0 prints a #. I'm back to using a ByteArrayOutputStream as the input to the newFop method so it works for everything. With this method, the transform doesn't create the file. The output is all held in memory. Then I use the toByteArray method to get the data from the ByteArrayOutputStream, to create a ByteArrayInputStream, which I then pass in to PDDocument.load from the pdfbox project which creates a Pageable object. I can then either save this object which generates a PDF, or I can pass it to the java.awt.print.PrinterJob object to send to the printer. Surely this is a longer explanation than you're asking for. The short answer is I'm well aware of how the output streams work, but I thought if the transform was writing to it which should be a complete process that it would close it when it's done. -----Original Message----- From: paul womack [mailto:[email protected]] Sent: Wednesday, August 25, 2010 8:49 AM To: [email protected] Subject: Re: Invalid PDF Created Eric Douglas wrote: > I resolved this. After the transform I didn't close the output stream. > Apparently that left some bytes hanging. Apparently? You said: > If I try to create a PDF directly from the transform with FOP 1.0, by > passing a BufferedOutputStream created from a FileOutputStream into the > FopFactory.newFop, it's creating an incomplete PDF. Am I missing > something or where should this come from? You might want to review your understanding of what BufferedOutputStream and FileOutputStream do. BugBear --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
