I'm trying to use the Adobe's IAC to save the 1st 2 pages of one document as another. I create an instance of AcroApp
like this:
ACROBAT::CAcroAppPtr acApp;
HRESULT hr = acApp.CreateInstance(__uuidof(ACROBAT::AcroApp));
If the creation is successful I open the original PDF like this:
ACROBAT::CAcroPDDocPtr pdDoc;
hr = pdDoc.CreateInstance(__uuidof(ACROBAT::AcroPDDoc));
pdDoc->Open(_bstr_t(L"source.pdf")) // so far so good it has 13 pages
If that is successful I create another PDDoc like this
hr = outDoc.CreateInstance(__uuidof(ACROBAT::AcroPDDoc)); // returns S_OK
outDoc->Create(); // returns -1 which is good
Then I try to add the 1st 2 pages of original document to this new one like this:
pdDoc->InsertPages(0, outDoc, 0, 2, 1); // this returns 0 which means something went wrong
But InsertPages
returns error and the new PDDoc
still has 0 pages.
What am I missing?
I am using Acrobat Pro 2020
and the original PDDoc
has 13 pages in it.
I'm using Visual Studio 2022
for development.