When attempting to include some jpeg files into a PDF using iText I get an error: Premature EOF while reading JPG
The images are loaded from android phones and most can be embedded into the pdf file, however some can not.
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: com.itextpdf.text.Jpeg.processParameters(Jpeg.java:219) iText version is: 5.5.5
I have put an image that causes the error onto a public dropbox folder: https://dl.dropboxusercontent.com/u/46349359/image.jpg The image is 1.6 MB and is displayed without a problem in html or using other image display tools.