I am working on a web-app that allows user to send some pictures to server and then server sends back a pdf file which contains those pictures and some additional data. I was able to receive pictures on my server side. Basically I have them as byte[]. To create pdf file I use iText. In order to embed pictures I have to use com.lowagie.text.Image object. However, how to create instance of com.lowagie.text.Image from byte[] that I have?

1

1 Answer

In com.lowagie.text.Image there is a method getInstance() that is overloaded to take different inputs, including String filename and byte[] imgb. (See )

com.lowagie.text.Image image01 = com.lowagie.text.Image.getInstance("test.jpg"); document.add(image01); byte[] byte_array = ....... com.lowagie.text.Image image02 = com.lowagie.text.Image.getInstance(byte_array); document.add(image02); 
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.