0
我跟了這等話題從PDF獲得一個圖像PDF格式轉換爲圖像中的Android
How to convert a pdf to an image?
我想用這個圖片爲PDF預覽,這是我
德碼private Bitmap showPage(int page, float zoom) throws Exception {
Bitmap b=null;
try {
mPdfPage = mPdfFile.getPage(page, true);
float wi = mPdfPage.getWidth();
float hei = mPdfPage.getHeight();
RectF clip = null;
Bitmap bi = mPdfPage.getImage((int)(wi*zoom), (int)(hei*zoom), clip, true, true);
b=bi;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
File f = new File(Environment.getExternalStorageDirectory()+ File.separator + "Firstpdf.jpg");
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
Log.e("amit","Go to page bitmap______SAVE");
} catch (Throwable e) {
}
return b;
}
,但在這一行
Bitmap bi = mPdfPage.getImage((int)(wi*zoom), (int)(hei*zoom), clip, true, true);
我得到這個錯誤
The method getImage(int, int, Rectangle2D, ImageObserver) in the type PDFPage is not applicable for the arguments (int, int, RectF, boolean, boolean)
任何人都可以幫助我嗎?
非常感謝!
在[這篇文章](http://stackoverflow.com/questions/8814758/need-help-to-convert-a-pdf-page-into-bitmap-in-android-java)他使用3個參數,但我不能,我正在使用PDFRenderer.jar,也許它是不正確的庫 – aloj
在[此鏈接](http://www.java2s.com/Open-Source/Android-Open-Source-App/Media /Android-Pdf-Viewer-Library/com/sun/pdfview/PDFPage.java.htm)有一個帶有3個參數的方法實現,它返回一個Bitmap(getImage(int width,int height,RectF clip)),但是I無法訪問,我只能使用4個參數的方法並返回一個Image – aloj