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 2019/05/15 16:44:00 UTC

[jira] [Closed] (PDFBOX-4547) PDFRendtion : Infinite loop

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

Tilman Hausherr closed PDFBOX-4547.
-----------------------------------
    Resolution: Not A Bug

Yeah, it's always good to update to the latest version. I'm closing this issue. If you want me to Analyse the file (10 seconds is slow, but may be OK for certain complex files), reopen the issue and attach the file.

> PDFRendtion : Infinite loop
> ---------------------------
>
>                 Key: PDFBOX-4547
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4547
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.15
>            Reporter: Bhavesh Kharwa
>            Priority: Critical
>
> while processing pdf file for generate rendtion, the following method _processStreamOperators_ of *org.apache.pdfbox.contentstream.PDFStreamEngine* class goes into infinite loop. I am using library pdfbox-2.0.15
> {code:java}
>  private void processStreamOperators(PDContentStream contentStream) throws IOException
>     {
>         List<COSBase> arguments = new ArrayList<COSBase>();
>         PDFStreamParser parser = new PDFStreamParser(contentStream);
>         Object token = parser.parseNextToken();
>         while (token != null)
>         {
>             if (token instanceof COSObject)
>             {
>                 arguments.add(((COSObject) token).getObject());
>             }
>             else if (token instanceof Operator)
>             {
>                 processOperator((Operator) token, arguments);
>                 arguments = new ArrayList<COSBase>();
>             }
>             else
>             {
>                 arguments.add((COSBase) token);
>             }
>             token = parser.parseNextToken();
>         }
>     }
> {code}
> Generate rendition code for pdf as below:
> {code:java}
> try (final PDDocument pdf = PDDocument.load(imageBytes)) {
> 		if (pdf != null && pdf.getNumberOfPages() > 0) {
> 			PDFRenderer renderer = new PDFRenderer(pdf);
> 			BufferedImage image = renderer.renderImage(0, 1);
> 			final BufferedImage scaledImage;
> 			if (image.getWidth() > rendition.getWidth()) {
> 				scaledImage = Thumbnails.of(image).width(rendition.getWidth()).asBufferedImage();
> 			} else {
> 				scaledImage = image;
> 			}
> 			outputBytes = ImageUtils.writeBufferedImageToBytes(scaledImage, mimeType);
> 				}
> 			}
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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