Gema Peña Chimeno created PDFBOX-1704:
-----------------------------------------

             Summary: Null MediaBox value in the first page of a list of pages 
obtained using getAllPages()
                 Key: PDFBOX-1704
                 URL: https://issues.apache.org/jira/browse/PDFBOX-1704
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 1.8.2
            Reporter: Gema Peña Chimeno
            Priority: Minor


Tryng to set pages in a PDF file generated using PDFMergerUtility (see 
PDFBOX-1703) we are getting the pages, setting the number page and creating a 
new PDF file. 

In some cases the first page of the new file has the cut image. After debugging 
the code we realize that the value of the field mediaBox of the first page is 
null, and that produce strange affect in the new PDF:

        File result
        List allPages
        PDDocument doc
        PDDocument docWithPages

        docWithPages = new PDDocument()
        doc = PDDocument.load(tmpPdfFile);

        allPages = doc.getDocumentCatalog().getAllPages();
        for(PDPage page : allPages) {
            docWithPages.addPage(page)
        }

        result = new File(pdfPathAndName)
        docWithPages.save(result)

If fact, to solve the problem, we add these line before addPage line:

                if (!page.mediaBox) {
                    page.mediaBox = page.artBox
                }



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to