When I try to include some jpeg files in PDF using iText, I get the error message: Premature EOF while reading JPG
Images are downloaded from Android phones, and most of them can be embedded in a pdf file, but some cannot.
PushbuttonField ad = pdfForm.getNewPushbuttonFromField(fieldName); if(ad != null) { ad.setLayout(PushbuttonField.LAYOUT_ICON_ONLY); ad.setProportionalIcon(true); try { ad.setImage(Image.getInstance(basePath + "/" + r.value)); } catch (Exception e) { log.log(Level.SEVERE, "Image error detail", e); } pdfForm.replacePushbuttonField(fieldName, ad.getField()); }
The error occurs during setImage at the address: com.itextpdf.text.Jpeg.processParameters (Jpeg.java:219) iText version: 5.5.5
I put an image that causes an error in the Dropbox public folder: https://dl.dropboxusercontent.com/u/46349359/image.jpg The image is 1.6 MB and is displayed without problems in html or using other image display tools.
source share