PDF格式转换为图像中的Android [英] Convert pdf to image in Android
本文介绍了PDF格式转换为图像中的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我跟了这等话题,以获得一个PDF图像
I have followed this other topic to get a image from pdf
<一个href=\"http://stackoverflow.com/questions/11292417/how-to-convert-pdf-to-image-in-android-using-pdfbox-getting-error-to-import-ja\">how将PDF转换为图像在android系统?使用PDFBOX得到错误导入java.awt中和的javax
我想使用此图片为PDF preVIEW,这是德code,我有
I want to use this image as a pdf preview, this is de code that I have
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)
谁能帮我?
非常感谢你!
推荐答案
该方法的getImage
需要4个参数,但你通过5.检查的文件,并提供正确的参数。
The method getImage
requires 4 parameters but you have passed 5. Check the documentation and provide correct parameters.
这篇关于PDF格式转换为图像中的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文