Hi,
I have written below code to read the PDF file and convert the PAGE to image.I am able to create it sucessfully but the image is getting created for dimension of 480*343 pixels (72 DPI).
But the orginal documents dimension is 1667X1192 pixels (250 DPI).How to get this values.And create the Image.
Please let me know.
import javax.swing.JFrame;
//This com.adobe.acrobat.PDFDocument is the third party api,Where i download from adobe
import com.adobe.acrobat.PDFDocument;
public class demo2 {
public static void main(java.lang.String[] args) {
JFrame frm = new JFrame();
PDFDocument doc = null;
try {
doc = new PDFDocument(new java.io.File("d:/3.pdf"));
int nFile = 0;
int nScale = 1;
int x = (int) doc.getPageSize(nFile).x * nScale;
System.out.println("The Page Size Of X is--->" + x);
int y = (int) doc.getPageSize(nFile).y * nScale;
System.out.println("The page Size Of Y is--->" + y);
int nColorModel = java.awt.image.BufferedImage.TYPE_3BYTE_BGR;
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(
x, y, nColorModel);
image.getGraphics().fillRect(0, 0, x, y);
com.adobe.acrobat.sidecar.AffineTransform af = new com.adobe.acrobat.sidecar.AffineTransform(
nScale, 0, 0, nScale, 0, 0);
// doc.drawPage(nFile, image, af, new java.awt.Rectangle(400, 400),
// frm);
javax.imageio.ImageIO.write(image, "png", new java.io.File(
"d:/Test.jpg"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific