[ad_1]
Some ideas may be useful instead of all the comments.. 🙂
At the risk of stating the obvious, do it in steps. For example …
Use
avax.imageio.ImageIOto create ajava.awt.image.BufferedImageWrap it as a
com.itextpdf.text.ImageEmbed it in a
com.itextpdf.text.PdfDocumentUse
com.itextpdf.text.DocumentWriterto write thecom.itextpdf.text.PdfDocumentto ajava.io.ByteArrayOutputStreamGet the
byte[]and wrap it in ajava.io.ByteArrayInputStream
It is theoretically possible to do the transformation without buffering the image in memory, but the existing APIs don’t support this. (You would have a lot of coding to do it in Java. It would be better to look for a standalone image-to-pdf conversion utility.)
You should be able to avoid the intermediate byte[] buffer using a PipedOutputStream / PipedInputStream pair.
2
[ad_2]
solved convert image inputstream to pdf inputstream – Java