How to convert byte array to image in itext pdf and display in pdf. This is what i am doing but i am getting nullpointer exception..
Base64 decoder = new Base64();
byte[] imageByte = decoder.decode(imageInBase64EncodedString);
Image image = null;
try {
image = Image.getInstance(imageByte);
} catch (BadElementException e1) {
e1.printStackTrace();
} catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
image.scalePercent(15f); <-----Here i am getting NullPointer Exception
image.scaleAbsoluteWidth(520f);
image.setAbsolutePosition(40f,725f);
document.add(image);
}catch(Exception e){
e.printStackTrace();
}
I am not understanding why image is not created even i pass them bytes.