You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by moe mezzawi <ma...@gmail.com> on 2019/12/28 15:00:00 UTC
Delete an Image
Dear All,
How can we delete an image from a pdf?
Thanks.
Re: Delete an Image
Posted by Tilman Hausherr <TH...@t-online.de>.
Get the RemoveAllText.java example from the source code download, then
modify it so that it catches the "Do" operator. For example "/Im4 Do".
Here "Im4" is the name of the image. Rewrite the content stream without
these two tokens. If you want to delete the image from the resources
(because it is secret), then you have to access the resources somewhat
like this:
page.getResources().getCOSObject().getDictionaryItem(COSName.XObjects).RemoveItem(COSName.getPDFName("Im4"));
This is a simple example; in might be more tricky in practice, e.g. if
the image is not at the top hierarchy, or if it isn't an image at all.
Tilman
Am 28.12.2019 um 16:00 schrieb moe mezzawi:
> Dear All,
>
> How can we delete an image from a pdf?
>
> Thanks.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org