Print Page | Close Window

How to delete unused images from PDF?

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=418
Printed Date: 01 Apr 20 at 6:23AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to delete unused images from PDF?
Posted By: james.si
Subject: How to delete unused images from PDF?
Date Posted: 19 May 06 at 1:18PM
Is there a possibility to delete unused pictures (pictures that are not drawn) from PDF? Please help.



Replies:
Posted By: chicks
Date Posted: 19 May 06 at 2:41PM
Don't know for sure, but here are some things you might try:

FindImages() / ReplaceImage(). Might be able to replace a big unused image with a tiny one to save space.

DeleteLayer(). Might be able to delete a layer with images, assuming they are on a layer by themselves.

CheckObjects(). Documentation just says it checks all objects to see if they're valid. Doesn't say whether it removes invalid objects, but may be worth a try.

I'm still amazed at the number of functions in this library, and haven't used them all by any means.


Posted By: swb1
Date Posted: 19 May 06 at 3:10PM

Iíve tried a number of things to remove image streams from the PDF and I have not found the means within QuickPDF. I have traced the code and it looks to me as though replace image only replaces the reference to the stream not the stream object itself.  It does not look like it would be an enormous challenge to write a function capable of doing this however there may be ramifications of which I am unaware.

 

sb



Posted By: chicks
Date Posted: 19 May 06 at 3:19PM
Good to know.

Meanwhile, here's a tool than definitely can remove images:

http://www.windjack.com/products/pdfcanopener.html

Unfortunately, it also requires Acrobat, so is pretty much out of my price range...


Posted By: james.si
Date Posted: 20 May 06 at 2:41AM
reply to chicks: I allready tryed all those things, before I was writing to this forum. I am working on PDF compresion. I replace bmp pictures in PDF with JPG but I can't remove replaced pictures.


Posted By: DELBEKE
Date Posted: 20 May 06 at 3:05AM
Have you try an extractpages function after the replacement to create a new Pdf file ?


Posted By: chicks
Date Posted: 20 May 06 at 3:37PM
I bought NitroPDF on sale at Fry's for $49 last week. Just tried removing an image from a sample PDF, works great! File size went from 132K to 58K.

Boxed version of NitroPDF was out of date, but updated for free with download version released just two days ago. Appears to work well so far...


Posted By: chicks
Date Posted: 23 May 06 at 2:01PM
It's also possible to do this manually, if you're not shy about editing PDF files directly. You'll need the free pdftk tool.

Here's an example:

http://www.savefile.com/files.php?fid=1846963

1. Uncompress the original PDF using pdftk:
    pdftk png_example.pdf output step1.pdf uncompress

2. Edit step1.pdf (using commandline edit.exe):
    Find the object of interest, in this case 5 0 obj.
    Remove all references to this object by deleting the
    lines associated with it, including:
      /XOBJ7BC610 5 0 R
      /XOBJ7BC610 Do
      Everything between the line starting with 5 0 obj
      and endobj
    Save the edited file to step2.pdf.

3. The xref table in step2.pdf is now corrupt, so we need to fix it. We'll also recompress the PDF:

    pdftk step2.pdf output step3.pdf compress

The final file, step3.pdf, is now a valid, compressed PDF, without the unwanted image (we left the text description below the spot where the image was). We can now use QuickPDF to add a new image in its place.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk