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 2018/09/21 17:20:00 UTC
[jira] [Closed] (PDFBOX-4310) Remove all images from a page
[ https://issues.apache.org/jira/browse/PDFBOX-4310?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tilman Hausherr closed PDFBOX-4310.
-----------------------------------
Resolution: Not A Problem
I forget to mention that the RemoveAllTexts example from the source code download shows how to access and modify the content stream.
Closing because this is a how-to question, these should be asked in the user mailing list or on stackoverflow.
> Remove all images from a page
> -----------------------------
>
> Key: PDFBOX-4310
> URL: https://issues.apache.org/jira/browse/PDFBOX-4310
> Project: PDFBox
> Issue Type: Wish
> Affects Versions: 2.0.11
> Reporter: Alexandre
> Priority: Minor
> Labels: how-to
> Attachments: 8325f992-15ff-4cdb-afed-0d8068c67ddc.pdf
>
>
> Hello Apache contributors,
> I am looking forward to remove all images from a pdf page (= create a new page without images from the original)
> For the moment, I am trying the following and it is not working. What's missing?
> {code:java}
> PDPage page = document.getPage(p);
> PDResources resources = page.getResources();
> resources.getXObjectNames().forEach((cosName) -> {
> PDXObject image;
> try {
> image = resources.getXObject(cosName);
> if (resources.isImageXObject(cosName)) {
> resources.getCOSObject().removeItem(cosName);
> page.setResources(resources);
> page.getCOSObject().removeItem(cosName);
> }
> }
> catch (IOException e) { }
> });
> {code}
> Best, A.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org