I've created a PDF document (with iText) in a file and can diplay it on the screen with:
Document document = new Document();
PdfWriter.getInstance(document, filename);
document.open();
// ... write something to document
document.close();
Desktop.getDesktop().open(new File(filename)); // works fine :-)
But on the machine of the customer my program will not have access to the filesystem, so I tried this:
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document,baos);
document.open();
// ... write something to document
document.close();
Which works, BUT then (of course)
Desktop.getDesktop().open(new File(baos)); //doesn't work :-(
It's not possible to show the PDF with Desktop.getDesktop().open
.
Is there a way to display the PDF stored in the ByteArrayOutputStream anyway?