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

Tilman Hausherr commented on PDFBOX-3815:
-----------------------------------------

That strategy might not be the best one: you are losing document level 
information, especially metadata.

I tried reproducing the effect with a large number of files with this code, but 
nothing happened:
{code}
try (PDDocument doc = PDDocument.load(f))
{
    if (doc.getNumberOfPages() > 1)
    {
        int oldPageCount = doc.getNumberOfPages();
        doc.getPages().remove(0);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        if (doc.isEncrypted())
        {
            doc.setAllSecurityToBeRemoved(true);
        }
        doc.save(baos);
        try (PDDocument doc2 = PDDocument.load(baos.toByteArray())) 
        {
            int newPageCount = doc2.getNumberOfPages();
            if (oldPageCount - 1 != newPageCount)
            {
                System.err.println("unterschiedlich: " + f);
            }
        }
    }
}
{code}
I could do some research if you can post a screenshot of the page structure 
with PDFDebugger command line app. Click "View, Show internal structure", and 
then go to Root/Pages and expand that structure.

> Removing the first page doesn't work
> ------------------------------------
>
>                 Key: PDFBOX-3815
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3815
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.6
>         Environment: Windows 10, Java 8; PDF 1.5
>            Reporter: Sascha Becher
>
> Does nothing to page 1:
> try (PDDocument doc = PDDocument.load(file)) {
>       doc.removePage(0);
>       doc.save(file);
>       doc.close();
> }
> This would remove page 2:
> doc.removePage(1);
> seems not to be new: 
> https://stackoverflow.com/questions/37865415/pdfbox-does-not-remove-first-page
> If there are any restrictions to removing pages, the javadoc should note this.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to