pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe de Rochambeau <phi...@free.fr>
Subject Re: "About to return NULL from unhandled branch"
Date Tue, 21 Oct 2014 20:03:39 GMT
Hi Tilman,

the situation which causes the message to be displayed doesn’t prevent my PDFs from being
generated, so it doesn’t really matter.

Many thanks from looking into this « bug ».

Cheers,

Philippe



By the
Le 21 oct. 2014 à 19:17, Tilman Hausherr <THausherr@t-online.de> a écrit :

> Hi,
> 
> I have changed the message in issue PDFBOX-2443 <https://issues.apache.org/jira/browse/PDFBOX-2443>.
The message is now DEBUG level and less scary, hopefully. The message won't go away, this
a "grown code with lots of stuff problem" that has been changed in 2.0 by an API redesign.
> 
> I hope that is OK for you, and that whatever you do with PDFBox works. If not, just post
it here.
> 
> Tilman
> 
> Am 21.10.2014 um 18:39 schrieb Tilman Hausherr:
>> I was able to reproduce the message after setting up log4j properly.
>> 
>> The good news is that your PDF is produced. In the source code, it is an INFO and
not a WARNING or an ERROR, although I admit it is scary.
>> 
>> I'll see if I can fix this...
>> 
>> Tilman
>> 
>> Am 20.10.2014 um 19:10 schrieb Tilman Hausherr:
>>> Hi,
>>> 
>>> I was able to run that code and create a PDF, although I don't have your jpeg
file, I used another.
>>> 
>>> Please upload that jpeg somewhere, or email it to me, or post the URL.
>>> 
>>> Tilman
>>> 
>>> Am 20.10.2014 um 10:13 schrieb phiroc@free.fr:
>>>> Hi Tilman,
>>>> 
>>>> please find below the shortest possible code to reproduce the error, as requested.
>>>> 
>>>> The message I get is as follows:
>>>> 
>>>> Oct 20, 2014 10:08:45 AM org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage
getColorSpace
>>>> INFO: About to return NULL from unhandled branch. filter = COSName{DCTDecode}
>>>> 
>>>> My pom.xml contains the following entries:
>>>> 
>>>> <properties>
>>>>       <pdfbox.version>1.8.7</pdfbox.version>
>>>> ...
>>>> <dependency>
>>>>        <groupId>org.apache.pdfbox</groupId>
>>>>        <artifactId>pdfbox</artifactId>
>>>>        <version>${pdfbox.version}</version>
>>>> </dependency>
>>>> ...
>>>> 
>>>> Best regards,
>>>> 
>>>> 
>>>> Philippe
>>>> 
>>>> -------------------------------------
>>>> 
>>>> public class App {
>>>> 
>>>>     public static void main(String[] args) {
>>>>         new App();
>>>>     }
>>>>          public App() {
>>>> 
>>>>         go();
>>>>        } // end main
>>>>          private void go() {
>>>> 
>>>>         try {
>>>> 
>>>>             PDDocument doc = new PDDocument();
>>>> 
>>>>             PDPage page = null;
>>>>             PDPageContentStream pcs = null;
>>>>             page = addNewPage(doc, PDPage.PAGE_SIZE_A4);
>>>>             pcs = new PDPageContentStream(doc, page);
>>>>                          loadLogoImage(
>>>>                 new File(
>>>>                     "/home/p/Desktop/data/img/doodle.jpg"
>>>>                 ),
>>>>                 doc,
>>>>                 pcs);
>>>>               pcs.close();
>>>> 
>>>>             doc.save(
>>>>                 "/home/p/Desktop/data/pdf/test.pdf");
>>>>             doc.close();
>>>>                      } catch (IOException ioe) {
>>>>             ioe.printStackTrace();
>>>>         } catch (Exception e) {
>>>>             e.printStackTrace();
>>>>         }
>>>> 
>>>>     } // end test
>>>> 
>>>>    private PDPage addNewPage(PDDocument doc, PDRectangle rect) {
>>>> 
>>>>        PDPage page = new PDPage(rect);
>>>>        doc.addPage(page);
>>>>        return page;
>>>> 
>>>>    }
>>>> 
>>>>    public void loadLogoImage(
>>>>        final File pathToImage,
>>>>        PDDocument pdDocument,
>>>>        PDPageContentStream pdPageContentStream) {
>>>> 
>>>>        InputStream logoInputStream = null;
>>>>        PDJpeg logoImage = null;
>>>> 
>>>>        if (pathToImage.exists()) {
>>>>            try {
>>>>                logoInputStream = new FileInputStream(pathToImage);
>>>>            } catch (FileNotFoundException fnfe) {
>>>>                fnfe.printStackTrace();
>>>>            }
>>>>        } else {
>>>>            System.err.println("Invalid path to logo image: " + pathToImage.toString());
>>>>            return;
>>>>        }
>>>> 
>>>>        if (logoInputStream != null) {
>>>>            try {
>>>>                logoImage = new PDJpeg(pdDocument, logoInputStream);
>>>>                if (logoImage != null) {
>>>>                    pdPageContentStream.drawImage(logoImage, 100, 100);
>>>>                }
>>>>            } catch (IOException e) {
>>>>                e.printStackTrace();
>>>>            }
>>>>        } else {
>>>>            System.err.println("Could not draw image because input stream
is null.");
>>>>        }
>>>> 
>>>>    }
>>>> 
>>>> 
>>>> 
>>>> }
>>>> 
>>>> --------------------------------
>>>> 
>>>> 
>>>> 
>>>> ----- Mail original -----
>>>> De: "Tilman Hausherr" <THausherr@t-online.de>
>>>> À: users@pdfbox.apache.org
>>>> Envoyé: Samedi 18 Octobre 2014 14:23:01
>>>> Objet: Re: "About to return NULL from unhandled branch"
>>>> 
>>>> If you are sure that you get this error with 1.8.7, then please post the
>>>> shortest possible code that reproduces the error.
>>>> 
>>>> I just used the PDFToImage or PDFReader commands from the command line
>>>> application, which calls PDPage.convertToImage().
>>>> 
>>>> Tilman
>>>> 
>>>> Am 18.10.2014 um 14:16 schrieb Tilman Hausherr:
>>>>> Hi,
>>>>> 
>>>>> I downloaded the file at the link you gave me (I assume you don't want
>>>>> it to become public), and I didn't get the error you mention, I get
>>>>> many warnings:
>>>>> 
>>>>> Okt 18, 2014 1:52:00 PM
>>>>> org.apache.pdfbox.util.operator.pagedrawer.ClosePath process
>>>>> WARNUNG: java.awt.geom.IllegalPathStateException: missing initial
>>>>> moveto in path definition
>>>>> java.awt.geom.IllegalPathStateException: missing initial moveto in
>>>>> path definition
>>>>>     at java.awt.geom.Path2D$Float.needRoom(Unknown Source)
>>>>>     at java.awt.geom.Path2D.closePath(Unknown Source)
>>>>>     at
>>>>> org.apache.pdfbox.util.operator.pagedrawer.ClosePath.process(ClosePath.java:55)

>>>>>     at
>>>>> org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)

>>>>>     at
>>>>> org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)

>>>>>     at
>>>>> org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)

>>>>>     at
>>>>> org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)

>>>>>     at
>>>>> org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:139)
>>>>>     at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:801)
>>>>>     at
>>>>> org.apache.pdfbox.util.PDFImageWriter.writeImage(PDFImageWriter.java:130)

>>>>>     at org.apache.pdfbox.PDFToImage.main(PDFToImage.java:226)
>>>>>     at org.apache.pdfbox.PDFBox.main(PDFBox.java:96)
>>>>> 
>>>>> The reason are sequences like this in the PDF:
>>>>> 
>>>>> 708 388.2756347656 m
>>>>> 708 380.2756347656 l
>>>>> S
>>>>> h
>>>>> /F1 8 Tf
>>>>> 0 0 0 rg
>>>>> BT
>>>>> 31 381.2756347656 Td
>>>>> 9.52 TL
>>>>> () Tj
>>>>> T*
>>>>> ET
>>>>> h
>>>>> 
>>>>> 
>>>>> 
>>>>> h = closepath ("connects the end of a subpath back to its starting
>>>>> point"). The last "h" doesn't have a starting point.
>>>>> 
>>>>> However the pages are rendered, I tested with 1.8.7, 1.8.6, 1.8.8 and
>>>>> 2.0.
>>>>> 
>>>>> Either you are using a much older version, or you uploaded the wrong
>>>>> file.
>>>>> 
>>>>> Tilman
>>>>> 
>>>>> 
>>>>> 
>>>>> Am 16.10.2014 um 18:35 schrieb Tilman Hausherr:
>>>>>> That error is a follow-up error on another error. There was probably
>>>>>> a problem with the DCTDecode filter, i.e. a JPEG in the PDF. Please
>>>>>> upload the PDF somewhere, as you can't attach it here.
>>>>>> 
>>>>>> Tilman
>>>>>> 
>>>>>> Am 16.10.2014 um 14:36 schrieb phiroc@free.fr:
>>>>>>> Hi,
>>>>>>> 
>>>>>>> When I run a Java program that uses the PdfBox 1.8.7 API, the
>>>>>>> following message appears several times:
>>>>>>> 
>>>>>>> "About to return NULL from unhandled branch. filter =
>>>>>>> COSName{DCTDecode}"
>>>>>>> 
>>>>>>> Does anyone have any idea what might cause it?
>>>>>>> 
>>>>>>> Many thanks.
>>>>>>> 
>>>>>>> Cheers,
>>>>>>> 
>>>>>>> Philippe
>>> 
>> 
> 


Mime
View raw message