0

この他のトピックに従って、pdfから画像を取得しました

PDFを画像に変換するには?

この画像を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)

誰でも私を助けることができますか?

どうもありがとうございました!

4

1 に答える 1

0

このメソッドgetImageには 4 つのパラメーターが必要ですが、5 つを渡しました。ドキュメントを確認し、正しいパラメーターを指定してください。

于 2013-09-21T11:55:41.710 に答える