[ 
https://issues.apache.org/jira/browse/PDFBOX-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16959914#comment-16959914
 ] 

Joseph Jezerinac commented on PDFBOX-4674:
------------------------------------------

This was created from PDF box (later modified by aspose) using the following:

 
{code:java}
final PDImageXObject pdImageXObject = JPEGFactory.createFromImage(pdDocument, 
bufferedImage, imageCompressionQuality);
try (PDPageContentStream contentStream = new PDPageContentStream(pdDocument, 
pdPage)) {
  contentStream.drawImage(pdImageXObject, 0, 0, pageSize.getWidth(), 
pageSize.getHeight());
}
{code}
 

 

But the bufferedImage did have image type of BufferedImage.TYPE_USHORT_555_RGB, 
I guess this is not compatible with JPEGFactory / drawImage (it would be nice 
if worked).

 

Testing above was done using Chrome PDF viewer which opens fine but your right 
this is invalid document.  Thanks again [~mkl].

> PDF Page Render Background Image has Gray Smudges
> -------------------------------------------------
>
>                 Key: PDFBOX-4674
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4674
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.17
>            Reporter: Joseph Jezerinac
>            Priority: Major
>         Attachments: bad_page_image.pdf, es-page-image2455431271065294360.png
>
>
> The following text produces a PNG that has gray smudges in it.  I've attached 
> the pdf and the PNG that is produced.
>  
> {code:java}
> public class TestPdfPageImage {
>     @Test
>     public void testGetPageImage() throws IOException {
>         try (PDDocument pdDocument = 
> PDDocument.load(FileUtils.toFile(getClass().getResource("/bad_page_image.pdf"))))
>  {
>             final PDFRenderer pdfRenderer = new PDFRenderer(pdDocument);
>             final BufferedImage bufferedImage = pdfRenderer.renderImage(0);
>             final Path tempPath = Files.createTempFile("es-page-image", 
> ".png");
>             try {
>                 final File tempFile = tempPath.toFile();
>                 ImageIO.write(bufferedImage, "png", tempFile);
>                 Assert.assertTrue(Files.size(tempPath) > 0);
>             } finally {
>                 Files.delete(tempPath);
>             }
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to