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/07/07 23:49:40 UTC

[jira] [Updated] (PDFBOX-1533) When merging certain PDF's several odd looking empty pages occure in the result

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

Tilman Hausherr updated PDFBOX-1533:
------------------------------------

    Description: 
Unfortunately I cannot attach a input file for this case as it contains confidential customer data, but I'll try to explain the problem in depth so you hopefully are able to track it down.

When we merge certain PDF's with the PDFMergerUtility the result contains several empty pages at the end of the document. It seems like that only certain pdf versions are effected (i.p.: 1.5 (Acrobat 6.x)). 

I tracked the problem down to the the following part in the appendDocument method of the PDFMergerUtility:
{code}
 //finally append the pages
        List<PDPage> pages = srcCatalog.getAllPages();
        Iterator<PDPage> pageIter = pages.iterator();
        while( pageIter.hasNext() )
        {
            PDPage page = pageIter.next();
            PDPage newPage =
                new PDPage( (COSDictionary)cloner.cloneForNewDocument( page.getCOSDictionary() ) );
            newPage.setCropBox( page.findCropBox() );
            newPage.setMediaBox( page.findMediaBox() );
            newPage.setRotation( page.findRotation() );
            destination.addPage( newPage );
        }
{code}
The problem is that call to srcCatalog.getAllPages(); returns for example 6 PDPage objects, but for the same input document, the call to source.getNumberOfPages() returns only 2. Thus we add 4 odd empty pages to the result document.

I hope this description is good enough to figure out the problem. Don't hesitate to ask for further details.

  was:
Unfortunately I cannot attach a input file for this case as it contains confidential customer data, but I'll try to explain the problem in depth so you hopefully are able to track it down.

When we merg certain PDF's with the PDFMergerUtility the result contains serveral empty pages at the end of the document. It seems like that only certain pdf versions are effected (i.p.: 1.5 (Acrobat 6.x)). 
I tracked the problem down to the the following part in the appendDocument method of the PDFMergerUtility:

 //finally append the pages
        List<PDPage> pages = srcCatalog.getAllPages();
        Iterator<PDPage> pageIter = pages.iterator();
        while( pageIter.hasNext() )
        {
            PDPage page = pageIter.next();
            PDPage newPage =
                new PDPage( (COSDictionary)cloner.cloneForNewDocument( page.getCOSDictionary() ) );
            newPage.setCropBox( page.findCropBox() );
            newPage.setMediaBox( page.findMediaBox() );
            newPage.setRotation( page.findRotation() );
            destination.addPage( newPage );
        }

The problem is that call to srcCatalog.getAllPages(); returns for expamle 6 PDPage objects, but for the same input document, the call to source.getNumberOfPages() returns only 2. Thus we add 4 odd empty pages to the result document.

I hope this description is good enought to figure out the problem. Don't hesitate to ask for further details.


> When merging certain PDF's several odd looking empty pages occure in the result
> -------------------------------------------------------------------------------
>
>                 Key: PDFBOX-1533
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1533
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.7.1, 1.8.4
>            Reporter: Christian Connert
>         Attachments: sample_pdf.zip
>
>
> Unfortunately I cannot attach a input file for this case as it contains confidential customer data, but I'll try to explain the problem in depth so you hopefully are able to track it down.
> When we merge certain PDF's with the PDFMergerUtility the result contains several empty pages at the end of the document. It seems like that only certain pdf versions are effected (i.p.: 1.5 (Acrobat 6.x)). 
> I tracked the problem down to the the following part in the appendDocument method of the PDFMergerUtility:
> {code}
>  //finally append the pages
>         List<PDPage> pages = srcCatalog.getAllPages();
>         Iterator<PDPage> pageIter = pages.iterator();
>         while( pageIter.hasNext() )
>         {
>             PDPage page = pageIter.next();
>             PDPage newPage =
>                 new PDPage( (COSDictionary)cloner.cloneForNewDocument( page.getCOSDictionary() ) );
>             newPage.setCropBox( page.findCropBox() );
>             newPage.setMediaBox( page.findMediaBox() );
>             newPage.setRotation( page.findRotation() );
>             destination.addPage( newPage );
>         }
> {code}
> The problem is that call to srcCatalog.getAllPages(); returns for example 6 PDPage objects, but for the same input document, the call to source.getNumberOfPages() returns only 2. Thus we add 4 odd empty pages to the result document.
> I hope this description is good enough to figure out the problem. Don't hesitate to ask for further details.



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