Create an Instance of Com. Lowagie. Text. Image from Byte[]
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...
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 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);