Copy link to clipboard
Copied
I have a plug-in that deletes all pages from a document using the following code:
// get the active PDF document
AVDoc currentAVDoc = AVAppGetActiveDoc();
PDDoc originalDocument = AVDocGetPDDoc(currentAVDoc);
// number of pages in the document
int numPages = PDDocGetNumPages(originalDocument);
// delete all pages from the document
PDDocDeletePages(originalDocument, 0, numPages - 1, NULL, NULL);
The problem is that I'm getting an error message that simply says "Bad parameter" when my code calls the PDDocDeletePages() function. So I tried to delete each individual page one at a time by doing this:
for (int i = numPages - 1; i >= 0; i--)
{
PDDocDeletePages(originalDocument, i, i, NULL, NULL);
}
The same error message still appears, but it happens once there is only 1 page remaining. The other pages are deleted without any problem. I have even tried reversing the loop and deleting the pages in the opposite order, but the error still comes when there is only 1 page remaining.
Can you think of any reason why this would happen? I have even tried using the constant PDLastPage to delete the last remaining page, but that does not seems to be the answer.
You can't delete all pages. A PDF document must have at least one page.
Copy link to clipboard
Copied
You can't delete all pages. A PDF document must have at least one page.
Copy link to clipboard
Copied
Ah, that makes perfect sense. This was indeed the problem. Thank you very much for the quick response.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now