0
pdfrenderer
を使用してPDFファイルページを画像に変換しようとしていますが、以下のコンパイル時のエラー。これを是正する方法は?
私のコード
File file = new File("image.png");
System.out.println("Inside readFromFiles!!!!!");
String fname = new File(getFilesDir(), "Android Tutorial.pdf")
.getAbsolutePath();
FileChannel fChannel = new FileInputStream(fname).getChannel();
ByteBuffer buffer = fChannel.map(FileChannel.MapMode.READ_ONLY, 0,
fChannel.size());
System.out.println("Buffer" + buffer);
PDFFile pdfFile = new PDFFile(buffer);
PDFPage page = pdfFile.getPage(0);
System.out.println("page" + page);
Rectangle rect = new Rectangle((int) page.getBBox().getWidth(),
(int) page.getBBox().getHeight());
System.out.println("Rect" + rect);
Image img = page.getImage(rect.width, rect.height, rect, null);
System.out.println("img" + img);
RenderedImage rImage = (RenderedImage) img;
ImageIO.write(rImage, "png", file);
System.out.println("Image Created");
私が得るエラーは以下のとおりです。
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): FATAL EXCEPTION: main
03-2210:56:16.834:ERROR/AndroidRuntime(9572):java.lang.NoClassDefFoundError:java.awt.geom.Rectangle2D$Float
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at com.sun.pdfview.PDFFile.parseRect(PDFFile.java:1523)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at com.sun.pdfview.PDFFile.createPage(PDFFile.java:1419)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at com.sun.pdfview.PDFFile.getPage(PDFFile.java:1330)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at com.sun.pdfview.PDFFile.getPage(PDFFile.java:1301)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at com.example.PdfLibraryActivity.PdfLibraryActivity.readFromFiles(PdfLibraryActivity.java:137)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at com.example.PdfLibraryActivity.PdfLibraryActivity.onCreate(PdfLibraryActivity.java:42)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-22 10:56:16.834: ERROR/AndroidRuntime(9572): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
http://stackoverflow.com/questions/3897775/using-awt-with-android –