Reputation: 29
I am developping a web Application in grails and trying to create a pdf document using itext.
it works fine when i got a path (local and on my server) but know i need to do it without creating it physically.
what i don't want: PdfCopy copy = new PdfCopy(documentPDF,new FileOutputStream(mypath))
what i want : //PdfCopy copy = new PdfCopy(documentPDF,new FileOutputStream())
so i tried using ObjectOutPutStream instead of using FileOutputStream but it doesn't work.
I hope you understood what i am expecting for.
Thx in advance
Upvotes: 0
Views: 348
Reputation: 12228
Use a byte array output stream. Then you'll have the data
ByteArrayOutputStream baos = new ByteArrayOutputStream()
PdfCopy copy = new PdfCopy(documentPDF, baos)
byte[] data = baos.toByteArray()
Upvotes: 1