> -----Original Message----- > From: Luke Shannon [mailto:[EMAIL PROTECTED] >
Hi, I see you've already discovered it yourself, but here's a bit more info on why I think it went wrong... > Below is my code. > > When I run it in IE it get a Pop up message telling me the "File does not > begin with '%PDF-'". This is weird to me because I am not trying > to send it back through the response object, I don't know why the browser is even > looking at it. > It may be weird, but it does point out one serious mistake: > //get the content > String pdfFileContent = out.toString(); PDF is not 'just text', so it's wrong to use a String to represent it. That is not to say a PDF can't be opened in a text-editor --it can, but changing a character and saving can seriously muck up the binary portions of the file... not to mention prepend it with UTF-garbage. The error message is Acrobat's IE-plugin complaining, and refers to the PDF specification. A PDF file is supposed to start with: %PDF-{version-number} followed by a few (three or four... will have to look that up :-)) non-text bytes. These latter bytes will become 'characters' when you pass them through a String, so the end-result is likely a corrupt PDF file, even if you're not trying to display it. > When I run it in FireFox I get my success message printed, and > the document created. However when I trying and open it I am > told there is a Sharing Violation. > The writer was closed before I printed the success statement so I > am not sure where the conflict came from. Well... I don't fully agree. Keep in mind that in your initial code, the physical PDF-file was referenced (for read/write access) by three different objects: one File, and an OutputStream and a FileWriter wrapped around that File. Only the latter of the three explicitly closed, which may have caused the conflict to occur. Open a PDF for writing in Acrobat, ask FOP to render that PDF and you'll receive an error. Open it in Adobe Reader, ask FOP again, and it might work, since the first handle on the file is read-only. (Since I tried the first only on Windows, the latter only on Mac, this phenomenon could as well be OS-dependent.) Greetz, Andreas --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]