"Bad parameter." When Calling PDDocDeletePages()
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.
