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

Tilman Hausherr commented on PDFBOX-5211:
-----------------------------------------

{code}
try (PDDocument doc = PDDocument.load(new File("original.pdf")))
{
        for (PDPage page : doc.getPages())
        {
//              page.getCOSObject().removeItem(COSName.PIECE_INFO); // when 
2.0.24 is released
                page.getCOSObject().removeItem(COSName.getPDFName("PieceInfo"));
        }
        doc.save(new File("original_saved.pdf"));
}
{code}
According to the specification /PieceInfo may also be elsewhere, but here it 
wasn't. This code saves a file with a similar size than yours.


>  How can I clear unused data?
> -----------------------------
>
>                 Key: PDFBOX-5211
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5211
>             Project: PDFBox
>          Issue Type: Wish
>         Environment: mac os
>            Reporter: yoonho
>            Priority: Major
>         Attachments: 스크린샷 2021-06-10 오후 8.08.39.png
>
>
> How can I delete unused elements (for Photoshop, for InDesign, etc) within a 
> PDF file?
> After applying Adobe DC's optimization options (I posted in the screenshot), 
> I found that a pdf file of 380mb was reduced to around 48mb. This feature is 
> very useful to me. How can I implement it with pdfbox?
> I tried several ways, but couldn't find a way. I need advice.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to