I am building a scanner-upload-to-pdf applet. I can sucessfully scan and
upload Group4 compressed multi-page TIFF files via an applet onto our
application server. I can convert these tiff files using the supplied
Tiff2Pdf.java sample provided.
What I am having trouble doing is placing code to take the compressed tiff
images from a ByteArrayOutputStream (using the jai code from Sun) and extact
each tiff and insert them into a PDF file and then upload that pdf onto our
app server.
I've tried converting the output stream to an input stream and then placing
into a RandomAccessFileOrArray with:
ra = new RandomAccessFileOrArray(new
ByteArrayInputStream(output.toByteArray()));
It appears to get the image ok because it shows the scaled width and height,
but when I get to document.add(img), I get the exception as show below:
Processing: page 1 scaledWidth=2016.0 scaledHeight=2645.0
DocumentException: java.lang.NullPointerException
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.write(Unknown Source)
at java.io.FilterOutputStream.write(Unknown Source)
at
com.lowagie.text.pdf.OutputStreamCounter.write(OutputStreamCounter.java:107)
at com.lowagie.text.pdf.PdfStream.toPdf(PdfStream.java:270)
at
com.lowagie.text.pdf.PdfIndirectObject.writeTo(PdfIndirectObject.java:167)
at com.lowagie.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:370)
at com.lowagie.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:350)
at com.lowagie.text.pdf.PdfWriter$PdfBody.add(PdfWriter.java:303)
at com.lowagie.text.pdf.PdfWriter.addToBody(PdfWriter.java:1851)
at com.lowagie.text.pdf.PdfWriter.add(PdfWriter.java:992)
at
com.lowagie.text.pdf.PdfWriter.addDirectImageSimple(PdfWriter.java:971)
at
com.lowagie.text.pdf.PdfContentByte.addImage(PdfContentByte.java:1015)
at com.lowagie.text.pdf.PdfContentByte.addImage(PdfContentByte.java:977)
at UploadApplet.toPDF(UploadApplet.java:189)
at UploadApplet.init(UploadApplet.java:83)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Any guidance is greatly appreciated.
Regards,
Ken Ricci
-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions