hi,
there are several types of pictures.

1. bitmap images that are stored as resources
2. inline bitmap images that are stored within page's content stream
3. images that consist of curves/vectors - these vectors are defined 
within page's content stream

your example code removes only images defined in #1
if you want to remove images #2 and #3 it is much harder. you need to 
parse content stream, remove them, and create new content stream.


Best regards
Juraj Lonc




From:   Zhnupy Gonzalez <[email protected]>
To:     [email protected], 
Date:   08. 11. 2012 14:50
Subject:        remove all images from pdf



Hello everyone,
While looking for a way to remove all images from pdf file, I found this:
http://stackoverflow.com/questions/6831194/how-can-i-remove-all-images-drawings-from-a-pdf-file-and-leave-text-only-in-java


which wasn't enough, so I ended replacing the page's resource object with 
a
new (empty) one:
for (Object pageObj : catalog.getAllPages()) {
    PDPage page = (PDPage) pageObj;
    page.setResources(new PDResources());
}

which for my purposes is fine (there are some warnings when opening the
file with acrobat reader but it doesn't interfere with my goal).

BUT, there are still some images on the document and I don't know how to
tear them out. I don't even  know how to "navigate" to those images,  my
guess is I need to somehow traverse through page.getCOSDictionary()  and
delete appropiate entries but I haven't manage to do that and also not 
sure
if that works.

any help?
regards

Reply via email to