[
https://issues.apache.org/jira/browse/PDFBOX-4561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr closed PDFBOX-4561.
-----------------------------------
Resolution: Duplicate
Duplicate of PDFBOX-1752. See somewhat complicated solution at the bottom.
Alternatively build
https://github.com/jai-imageio/jai-imageio-jpeg2000
and use the result.
> Blank line/dot appears when converting PDF to PNG
> -------------------------------------------------
>
> Key: PDFBOX-4561
> URL: https://issues.apache.org/jira/browse/PDFBOX-4561
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.15
> Reporter: Luppens Patrice
> Priority: Major
> Labels: JPEG2000, JPXDecode, JPXFilter
> Attachments: PdfBox_Test.pdf, thefilename0.png
>
>
> I have the following test:
> @Test
> public void testPDFBoxBug() throws IOException {
> ClassLoader classLoader = getClass().getClassLoader();
> File file = new File(classLoader.getResource("PdfBox_Test.pdf").getFile());
> byte[] bytes = Files.readAllBytes(file.toPath());
> convertPDFToPNG(bytes);
> }
> private List<String> convertPDFToPNGLight(byte[] input) throws IOException {
> List<String> convertedPNGs = new ArrayList<>();
> PDDocument doc = PDDocument.load(input);
> PDFRenderer renderer = new PDFRenderer(doc);
> for(int i = 0; i < doc.getNumberOfPages() ; i++) {
> BufferedImage img = null;
> img = renderer.renderImageWithDPI(i, 96);
> ByteArrayOutputStream out2 = new ByteArrayOutputStream();
> ImageIO.write(img, "PNG", out2);
> out2.size();
> convertedPNGs.add(Base64Utils.encodeToString(out2.toByteArray()));
> try (OutputStream outputStream = new FileOutputStream("target/thefilename" +
> i + ".png")) {
> out2.writeTo(outputStream);
> }
> }
> doc.close();
> return convertedPNGs;
> }
>
> My input and output are in attachment.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]