extract specific pages from PDF Document  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Lambchop
User
Posts: 34
Joined: Mon May 02, 2022 5:58 pm

extract specific pages from PDF Document

Post by Lambchop »

I am sure this is posted somewhere but I just cannot seem to find it in this forum. Can someone post the link to the code that lets me call a specific page extraction? I am trying to implement (currently unsuccessfully):
1) count the number of pages within the PDF
2) extract a specific page for single page display
3) allow specific page edits for the single page displayed
Case scenario: user references a 10 page PDF. they choose page #3 and make some changes, then click on page #7 to look at it and then close the PDF with saved changes.
Challenging part: I do not want the full PDF displayed, just stored within a xpdf object that can be referenced.
How can I do this?
Many thanks!
-Eric
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: extract specific pages from PDF Document  SOLVED

Post by Ivan - Tracker Software »

I guess you already have a PDF document opened. Let's say it will be

Code: Select all

IPXV_Document* pVDoc;
1) count the number of pages within the PDF
to get the number of pages in the document you can use the following code:

Code: Select all

CComPtr<IPXV_Document> pRDoc;
pVDoc->get_CoreDoc(&pRDoc);
CComPtr<IPXC_Pages> pages;
pRDoc->get_Pages(&pages);
UINT_T numPages = 0;
pages->get_Count(&numPages);
it is much simpler in C# or C++ with non-raw-only import:

Code: Select all

auto numPages = pVDoc->CoreDoc->Pages->Count;
2) extract a specific page for single page display
To extract pages into a new document, you have to use Extract Pages operation. There is a small sample of how to use it.
3) allow specific page edits for the single page displayed
It depends on how you display the PDF. If you use IPXV_Control (actually, in this case, there is a simple way to get the number of pages -- just use a corresponding property of the IPXV_Control), you can set layout mode "Single Page" and control (for example via EnableEventListening) switch pages.

HTH
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Post Reply