Print Page | Close Window

Remove pictures from exisiting PDF file

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: General Discussion
Forum Description: Discussion board for Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2791
Printed Date: 23 Nov 24 at 12:01AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Remove pictures from exisiting PDF file
Posted By: zeras
Subject: Remove pictures from exisiting PDF file
Date Posted: 28 Nov 13 at 7:26PM
We have a large pdf file with many pictures and respective text for these pictures. For one reason, we don't need pictures inside pdf file.
Therefore question, whether it's possible to delete picture within pdf file to decrease file size of pdf file.
Or any other idea?
Replace pictures by dummy or decrease resolution of pictures?



Replies:
Posted By: AndrewC
Date Posted: 01 Dec 13 at 5:34AM
You need to use the FindImages(), ImageCount(), GetImageID() and ClearImage() functions.

ClearImage() will replace the image with a 1x1 single transparent pixel.

Andrew.


Posted By: zeras
Date Posted: 02 Dec 13 at 7:15PM
Thanks, that works.
Problem is, that I don't want to delet all pictures. Can I get page number of picture first, so that I can decide to delete or not?


Posted By: AndrewC
Date Posted: 03 Dec 13 at 6:08AM
Zeras,

FindImages will find the Image Resources list for the entire PDF file.  It is a list of images.  These images can be drawn on to multiple pages and at multiple locations multiple times.  This allows PDF files to be smaller by sharing resources.  Font's can work in a similar way.  FindImages cannot report a page number because the image is just stored ready to be drawn.

So if you have Image1 in the list and it is drawn on Page 1 and Page 2 but you only want it deleted from Page1 then you will be out of luck with this approach.  

You can use a different set of QPL functions which will tell you where each image is draw and on what page.  You can also the get the ImageID and then call ClearImage.  If the image is shared though on page 1 and page 2 then the image will be cleared from both pages.

            QP.LoadFromFile("99pages.pdf", "");
            QP.SelectPage(1);

            int id = QP.GetPageImageList(0);     // Only finds images on the current page.
            int count = QP.GetImageListCount(id);

            for (int i = 1; i <= count; i++)
            {
                int type = QP.GetImageListItemIntProperty(id, i, 400);
                int width = QP.GetImageListItemIntProperty(id, i, 401);
                int height = QP.GetImageListItemIntProperty(id, i, 402);
                int bpp = QP.GetImageListItemIntProperty(id, i, 403);
                int cs = QP.GetImageListItemIntProperty(id, i, 404);

                int ImageId = QP.GetImageListItemIntProperty(id, i, 405);

                if (width == 200)
                  QP.ClearImage(ImageId);
            }


Andrew




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