Print Page | Close Window

Please Help How to Extract Pages from File

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=2466
Printed Date: 07 Jun 25 at 6:40AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Please Help How to Extract Pages from File
Posted By: alinux08
Subject: Please Help How to Extract Pages from File
Date Posted: 02 Dec 12 at 4:33AM
Here are my code take from the sample:
 
           string fileName = @"..\..\Test Files\sample1.pdf";
         
            string OutputFile3 = @"..\..\Test Files\sample1_extracted3.pdf";
            string OutputFile4 = @"..\..\Test Files\sample1_extracted4.pdf";
            // Check to see if the library has been successfully unlocked
            if (qp.Unlocked() == 1)
            {               
                int docID = qp.LoadFromFile(fileName, "");
                int extractPageSuccess = qp.ExtractPages(1, 2);
                if (extractPageSuccess == 0)
                {
                    MessageBox.Show("Page(s) could not be extracted.");
                }
                else
                {                  
                    qp.SaveToFile(OutputFile3);                 
                }

                extractPageSuccess = qp.ExtractFilePages(fileName, "", OutputFile4, "1-1");
                //or extractPageSuccess = qp.ExtractPages(1, 1);
             
                if (extractPageSuccess == 0)
                {
                    MessageBox.Show("Page(s) could not be extracted.");
                }
                else
                {
                    qp.SaveToFile(OutputFile4);   
              }             
                qp.RemoveDocument(docID);
            }

My problem is that the second call of ExtractFile will always save the same pages from the first call.
Is this a bug or by design? I was trying to extract some different pages by each call to ExtractFile, just can not get the job done. Or I have to close file, reopen it to extract a different range of pages?

Thanks

Mark



Replies:
Posted By: Wheeley
Date Posted: 04 Dec 12 at 8:49AM
That is because you are overwriting the pages from ExtractFilePages with the pages from Extractpages. Remove the second call to SaveToFile, run your code, and then do a compare. Then ask your self this, "Why am I saving a second time?"

Wheeley


Posted By: alinux08
Date Posted: 06 Dec 12 at 2:22AM
Thanks. The idea is splitting the file into several small files, so what I did is calling the ExtractPage with different page ranges, and saving them after each call. Actually, after each call, the file is reloaded, it does gives me the right pages to save.



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