package com.test;
import java.awt.Toolkit;
import
java.awt.image.BufferedImage;
import
org.apache.pdfbox.pdmodel.PDDocument;
import
org.apache.pdfbox.util.PDFImageWriter;
public class PDFBoxPreviewTest {
/**
* @param args
*/
public static void main(String[] args)
{
try {
String
path = "D:\\temp\\a.pdf";
PDFBoxPreviewTest
t = new PDFBoxPreviewTest();
t.getDocument(path);
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
private PDDocument
getDocument(String path) throws Exception {
PDDocument
document = null;
document
= PDDocument.load(path);
PDFImageWriter
writer = new PDFImageWriter();
boolean success =
writer.writeImage(document, "jpg", "", 1, 1,
"myFileName", BufferedImage.TYPE_INT_RGB, Toolkit
.getDefaultToolkit().getScreenResolution());
System.out.println(success);
return document;
}
}
3. myFileName.jpg will be generated!
Source Code can be found here:
http://test-pdfbox.googlecode.com/svn/trunk/
Source Code can be found here:
http://test-pdfbox.googlecode.com/svn/trunk/
You can convert PDF to any image format and vice versa with Aspose.PDF for Java library also. It offers many sample codes that developers can use to embed in their application.
ReplyDeleteJava Development: Useful Api Converting Pdf To Image >>>>> Download Now
Delete>>>>> Download Full
Java Development: Useful Api Converting Pdf To Image >>>>> Download LINK
>>>>> Download Now
Java Development: Useful Api Converting Pdf To Image >>>>> Download Full
>>>>> Download LINK f9
Useful API converting PDF to image
ReplyDelete