Reputation: 566
broken converted image I try to convert a pdf to an image file.... it works fine, but it deletes a line in one of the rectangles.... I can't figure out why.....
public static void main(String[] args) throws FileNotFoundException, IOException
{
PDDocument doc = PDDocument.load(new FileInputStream(new File(".....pdf")));
PDDocumentCatalog docCatalog = doc.getDocumentCatalog();
List pages = docCatalog.getAllPages();
for (Object pageObj : pages)
{
PDPage page = (PDPage) pageObj;
BufferedImage pdfImage = page.convertToImage();
ImageIO.write(pdfImage, "png", new File("/......png"));
}
doc.close();
}
Before I deleted all text of the pdf.... could it be that it is still hassling with one of the text width, which then overwrites the rectangles line ?
Plse see pdf here...
Upvotes: 0
Views: 403
Reputation: 96003
When trying to reproduce the problem, it turned out that the current PDFBox 1.7.1 properly renders the image. The problem only occurred when using the old version 0.7.3.
Thus, if using Maven, use
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.7.1</version>
</dependency>
or a newer version of this dependency in case of such trouble.
Upvotes: 1