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 2014/05/20 21:40:40 UTC

[jira] [Closed] (PDFBOX-2086) Problem with creating image for pdf created from Word, CutePDF

     [ https://issues.apache.org/jira/browse/PDFBOX-2086?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tilman Hausherr closed PDFBOX-2086.
-----------------------------------

    Resolution: Invalid

Thanks for attaching the images, this is clearly not a PDFBox problem so I'm closing it. You can't resize to something smaller than a pixel; and a resize will always lose something. Yes, yours looks messy. I got a slightly better result by rendering with 5 dpi. However then you can't predict the size :-(

> Problem with creating image for pdf created from Word, CutePDF
> --------------------------------------------------------------
>
>                 Key: PDFBOX-2086
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2086
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.0
>         Environment: Windows
>            Reporter: Divya George
>            Priority: Minor
>         Attachments: Toby Flenderson-Simple Talk-2014-05.pdf, afterResize.jpg, beforeResize.jpg
>
>
> Our application has a web service that needs to convert the first page of a pdf document to a image resized image. I'm using the snapshot version 2.0.0 of pdfbox to accomplish this. This works for some pdf documents, but when I create a pdf document from Microsoft Word 2013 or CutePDF, it fails to generate the resized image.
> The final image displayed is this symbol: ÿØ
> and this is the information displayed in the logs.
> 2014-05-14 17:29:45,662 DEBUG [http-bio-8080-exec-5] (TTFGlyph2D.java:227) - ABCDEE+Calibri: Glyph not found:3
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: PDFOperator{ET}
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: PDFOperator{BT}
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSInt{1}
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSInt{0}
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSInt{0}
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSInt{1}
> 2014-05-14 17:29:45,663 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSFloat{72.024}
> 2014-05-14 17:29:45,664 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSFloat{684.1}
> 2014-05-14 17:29:45,664 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: PDFOperator{Tm}
> 2014-05-14 17:29:45,664 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: COSArray{[COSString{ }]}
> 2014-05-14 17:29:45,664 DEBUG [http-bio-8080-exec-5] (PDFStreamEngine.java:246) - processing substream token: PDFOperator{TJ}
> 2014-05-14 17:29:45,664 DEBUG [http-bio-8080-exec-5] (Encoding.java:242) - No character for name space
> 2014-05-14 17:29:45,665 DEBUG [http-bio-8080-exec-5] (TTFGlyph2D.java:227) - ABCDEE+Calibri: Glyph not found:3
> I tried changing the fonts in Word and also tried using CutePDF to generate the PDF document, but still see the wrong output. Our application receives pdfs from different sources and we have no control as to how the pdf is generated.
> Here is the snippet of the code I use.
>    PDDocument pdf = PDDocument.loadNonSeq(new  File(orginalFileName), null);
>   PDFRenderer renderer = new PDFRenderer(pdf);
>  // create the image
> BufferedImage image = renderer.renderImageWithDPI(0, 96, ImageType.RGB);
> BufferedImage scaledImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
> Graphics2D graphics2D = scaledImage.createGraphics();
>    		graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
> graphics2D.drawImage(image, 0, 0, width, height, null);
> graphics2D.dispose();
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> ImageIO.write(scaledImage, "jpg", baos);
> baos.flush();
> baos.close();
> pdf.close();
> return baos;
> If I write image to the buffered output stream,I get the original image, but it fails when I use the resized image.
> Please let me know if there is something I'm missing or if I should be using a different method to create the image. The pdf that I use is attached.
> Divya 



--
This message was sent by Atlassian JIRA
(v6.2#6252)