2016-07-24 91 views
0

在嘗試包括利用iText我得到一個錯誤的一些JPEG文件轉換成PDF:讀取JPG過早EOF同時讀取JPG利用iText

圖像是從Android手機上加載和最可 過早的EOF嵌入到PDF文件中,但有些不能。

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()); 
} 

錯誤發生在setImage期間:com.itextpdf.text.Jpeg.processParameters(Jpeg.java:219) iText的版本是:5.5.5

我已經把使所述圖像錯誤到公共保管箱文件夾中:https://dl.dropboxusercontent.com/u/46349359/image.jpg 圖像爲1.6 MB,在html中顯示沒有問題或使用其他圖像顯示工具。

+0

但是圖像存在於指定位置? – EJP

+0

是的,它存在。 – nap

+0

繼續我以前的評論,我跑了一些測試,我重命名文件,所以它不會被發現。報告的錯誤是java.io.FileNotFoundException。 – nap

回答

0

正如Amedee所說,這個問題是重複的。已經爲我工作的具體解決方法是:

  1. 安裝ImageMagick的
  2. 此前利用iText運行添加圖像文件image.jpg文件轉換成PDF: 「image.jpg文件轉換image.jpg文件」
  3. 然後添加jpeg