You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2020/04/17 19:57:00 UTC
[jira] [Comment Edited] (PDFBOX-4815) Gray background preview
becomes black squares
[ https://issues.apache.org/jira/browse/PDFBOX-4815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17086032#comment-17086032 ]
Tilman Hausherr edited comment on PDFBOX-4815 at 4/17/20, 7:56 PM:
-------------------------------------------------------------------
Sadly this is a known java problem (I can't find the issue now). Java has to render the attached stencil image at a lower resolution but fails to smooth things out.
That is likely a scanned image with a gray background and the scanner produced a dither pattern.
was (Author: tilman):
Sadly this is a known java problem (I can't find the issue now). Java has to render the attached stencil image at a lower resolution but fails to smooth things out.
> Gray background preview becomes black squares
> ---------------------------------------------
>
> Key: PDFBOX-4815
> URL: https://issues.apache.org/jira/browse/PDFBOX-4815
> Project: PDFBox
> Issue Type: Bug
> Components: Rendering
> Affects Versions: 2.0.16
> Reporter: Pascal Huynh
> Priority: Major
> Attachments: Stencil-1107-1587152039354.png, payslip.pdf, preview.png
>
>
> Hello, I have an issue with a PDF with gray background in some parts. This gray background becomes multiple black squares when trying to preview the document.
> Analyzing images extracted from the pdf, it appears the gray background is not a plain gray background but more a set of gray and black pixels.
> Is there a way to handle this kind of background for the preview and have the same visual rendering than the pdf?
> Source code :
> {code:java}
> @Test
> public void shouldPreview() throws IOException {
> String source = "payslip.pdf";
> String result = "preview.png";
> try (InputStream buffered = new BufferedInputStream(new FileInputStream(new File(source)));
> PDDocument doc = PDDocument.load(buffered, MemoryUsageSetting.setupMixed( 500L * 1024L))) {
> BufferedImage image = new PDFRenderer(doc).renderImageWithDPI(0, 300, ImageType.RGB);
> ImageIO.write(image, "png", new File(result));
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org