You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "bai yuan (Jira)" <ji...@apache.org> on 2024/11/12 07:48:00 UTC

[jira] [Created] (PDFBOX-5898) Converting PDF to images using PDFBox results in unexpected outcomes.

bai yuan created PDFBOX-5898:
--------------------------------

             Summary: Converting PDF to images using PDFBox results in unexpected outcomes.
                 Key: PDFBOX-5898
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5898
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 2.0.24
            Reporter: bai yuan
         Attachments: image-2024-11-12-15-45-48-011.png, test2.pdf

Running the following code, many fine red lines appear in the image.
{code:java}
        String pdfFilePath = path + "test2.pdf";
        String outputDir = path + "/out/";

        try {
            PDDocument document = PDDocument.load(new File(pdfFilePath));
            PDFRenderer pdfRenderer = new PDFRenderer(document);

            for (int page = 0; page < document.getNumberOfPages(); page++) {
                BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
                ImageIO.write(bim, "PNG", new File(outputDir + "page-" + (page + 1) + ".png"));
            }

            document.close();
            System.out.println("PDF converted to images successfully.");
        } catch (Exception e) {
            e.printStackTrace();
        }
{code}

 !image-2024-11-12-15-45-48-011.png! 




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org