Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

"Bad parameter." When Calling PDDocDeletePages()

Guest
Feb 28, 2017 Feb 28, 2017

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.

TOPICS
Acrobat SDK and JavaScript
877
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 28, 2017 Feb 28, 2017

You can't delete all pages. A PDF document must have at least one page.

Translate
Community Expert ,
Feb 28, 2017 Feb 28, 2017

You can't delete all pages. A PDF document must have at least one page.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 28, 2017 Feb 28, 2017
LATEST

Ah, that makes perfect sense. This was indeed the problem. Thank you very much for the quick response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines