i have a pdf file(attached).
My objective is to convert a pdf to an image using pdfbox AS IT IS,(same as using snipping tool in windows).
The pdf has all kinds of shapes and text .
i am using the following code:
PDDocument doc = PDDocument.load("Hello World.pdf");
PDPage firstPage = (PDPage) doc.getDocumentCatalog().getAllPages().get(67);
BufferedImage bufferedImage = firstPage.convertToImage(imageType,screenResolution);
ImageIO.write(bufferedImage, "png",new File("out.png"));
when i use the code, the image file gives totally wrong outputs(out.png attached)
how do i make pdfbox take something like a direct snapshot image?
also, i noticed that the image quality of the png is not so good, is there any way to increase the resolution of the generated image?
EDIT:
here is the pdf(see page number 68)
https://drive.google.com/file/d/0B0ZiP71EQHz2NVZUcElvbFNreEU/edit?usp=sharing
EDIT 2:
it seems that all the text isvanishing.
i also tried using the PDFImageWriter class
test.writeImage(doc, "png", null, 68, 69, "final.png",TYPE_USHORT_GRAY,200 );
same result
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…