我想在我的應用程序中顯示pdf的拇指圖像。我正在使用this的答案。但我不知道如何在android中使用它,因爲Rectangle2D不能在java中使用。我試着用RectFand修改代碼:Thumb from pdf android
File file = new File(arrayOfResults.get(arg0).filePath);
RandomAccessFile raf = new RandomAccessFile(file, "r");
FileChannel channel = raf.getChannel();
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY,
0, channel.size());
PDFFile pdffile = new PDFFile(buf);
// draw the first page to an image
PDFPage page = pdffile.getPage(0);
// get the width and height for the doc at the default zoom
RectF rect = new RectF(0, 0, (int) page.getWidth(),
(int) page.getHeight());
但應用程序崩潰並出現以下錯誤:
java.lang.NoClassDefFoundError: java.awt.geom.Rectangle2D$Double
at com.sun.pdfview.PDFFile.parseNormalisedRectangle(PDFFile.java:1874)
請幫助。
java.awt。*不是Android框架的一部分...所以你不能在Android上使用這個庫... – Selvin
@Selvin http://andpdf.sourceforge.net/看到那裏,他用它在Android應用程序。 – berserk