Not able to display the blob image dynamicaly from mysql database in itext table

I am trying to display an image from db in the itext table using below code

DAO Class

Blob imageBlob = rs.getBlob("VECHICLE_IMAGE");

byte[] imgData = imageBlob.getBytes(1,(int)imageBlob.length());

vechileDetailsReportBean.setVechileImageByte(imgData);

Controller Class

PdfPTable nestedTable = new PdfPTable(2);

nestedTable.addCell(new PdfPCell(new Phrase("Image")));

Image image = Image.getInstance(listVechileDetailsReportBean.get(i).getVechileImageByte());

image.scaleAbsolute(300,300);

nestedTable.addCell(new PdfPCell(image));

DB Desc

enter code here

[Vechile detail Table][1]

Getting Below error

RegNo:::S234442::Image::com.mysql.cj.jdbc.Blob@22c4fafe

java.io.IOException: The byte array is not a recognized imageformat.

at com.itextpdf.text.Image.getInstance(Image.java:473)

at com.itextpdf.text.Image.getInstance(Image.java:374)

Kindly suggest me how to display the image in itext from db dynamically...

Read More »

By: StackOverFlow - 5 days ago

Related Posts