简体   繁体   English

无法从数据库中检索签名出现此错误 java.io.IOException:字节数组不是可识别的图像格式

[英]Couldn't retrieve signature from database got this error java.io.IOException: The byte array is not a recognized imageformat

I am successfully stored user signatures into database.我已成功将用户签名存储到数据库中。 but, when I try to retrieve list of user signatures in a loop into pdf document, I got this java.io.IOException thrown at the line Image signpr = Image.getInstance(userSign);但是,当我尝试在 pdf 文档中循环检索用户签名列表时,我在Image signpr = Image.getInstance(userSign);行抛出了这个 java.io.IOException : as The byte array is not a recognized imageformat. : 因为字节数组不是可识别的图像格式。 Can anyone please tell me how to resolve this issue.谁能告诉我如何解决这个问题。

Below is my code下面是我的代码

PdfPTable userTable = new PdfPTable(1);
if (user.size() != 0) {

    userTable .setWidthPercentage(100.0f);
    userTable .setWidths(new float[] { 6.5f });

    for (int i = 0; i < user.size(); i++) {
        for (User e : user) {
            
            byte[] userSign = e.getuserSigns().getBytes(); 
            if(userSign!=null) {
                Image signpr = Image.getInstance(userSign); //sign
                signpr.scaleToFit(100,80);
                signpr.setAbsolutePosition(450, 80); 
                doc.add(signpr);
            }                           
            PdfPCell userName = new PdfPCell(new Phrase(e.getuserNames()));
            userName.setHorizontalAlignment(Element.ALIGN_CENTER);
            userTable .addCell(userName);
            
            userName.setBorder(Rectangle.NO_BORDER);
        }
    }
}
doc.add(userTable);

ALTER DATABASE your_db SET bytea_output TO 'escape'; ALTER DATABASE your_db SET bytea_output TO 'escape';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM