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

Adam Nichols commented on PDFBOX-911:
-------------------------------------

I downloaded the PDF and found that it had 4 pages (not 2).  I checked 
getNumberOfPages() and it returned 4, so I'm unable to reproduce the problem.  
Here's the exact code I'm using:

    public void testPdfBox911() {
        String inputpath = "C:\\Temp\\PDFBOX-911\\test.pdf";
        PDDocument doc = null;
        try {
            doc = PDDocument.load(inputpath);
            assertEquals(4, doc.getNumberOfPages());
        } catch (Exception e) {
            e.printStackTrace();
            fail("Threw exception!");
        } finally {
            if(doc != null)
                try { doc.close(); } catch(Exception e) {}
        }
    }

For some insight on how PDF determines the number of pages, here's how I looked 
into the issue.  I opened the pdf in a text editor and found that it was 
compressed, so I uncompressed it using a program called PDF toolkit (i.e. pdftk 
test.pdf output test.unc.pdf uncompress) and looked at the uncompressed 
version.  I found the root was object 1 0, and /Pages was 4 0 which had the 
four pages.  So everything seems to be okay here as far as I can tell.


> Method PDDocument.getNumberOfPages() returns wrong number of pages
> ------------------------------------------------------------------
>
>                 Key: PDFBOX-911
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-911
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.3.1
>         Environment: Windows XP, Eclipse 3.5.2 Galileo
>            Reporter: nielsen
>         Attachments: test.pdf
>
>
> Hello,
> I use PDFbox and are very pleased.
> For one PDF file however getNumberOfPages() returns the wrong number of pages 
> (1 instead of 2 pages).
> Test code:
>         File xx = new File("c:\\temp\\test.pdf");
>         PDDocument pdoc = PDDocument.load(xx);    
>         int x = pdoc.getNumberOfPages();
> The PDF file could be provided.
> Thanks in advance.
> Regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to