These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Using Javascript to Delete Pages in Reader

jmnw
Registered: Jul 29 2010
Posts: 5
Answered

Hello,

I'm trying to use the following javascript to delete the first page of a PDF prior to saving it. According to the API, this should be allowed in Reader, but requires Forms Rights.

this.deletePages({nStart: 0, nEnd: 0}) ;

I'm trying to delete the first page only of a multi-page document. I do realize that I should be able to do this with just:

this.deletePages();

And I've tried that as well.

I have tried running this from both a document level function and from a trusted function installed at the application level on a PDF that is

1) Both certified and given extended rights using Adobe Acrobat.
2) Just certified, w/o rights
3) Just given extended rights, not certified
4) Just a PDF, no rights or certification applied

In all cases I get the error:

NotAllowedError: Security settings prevent access to this property or method.
Doc.deletePages

I just want to make sure I'm not missing something here. I'm fairly convinced it can't be done, but since the API seems to say that it CAN, it's driving me crazy.
I did notice a note about after version 6.0, this function deletes SPAWNED pages, does that mean only spawned pages?

Thanks for any help you can provide,
Jane

J. Millet

My Product Information:
Reader 9.3, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Have you carefully read the Acrobat JS API Reference?

Below the 'deletePages' description:

"[color=#FF0000]Note:[/color] You cannot delete all pages in a document; there must be at least one page remaining.

(Acrobat 6.0): Beginning with version 6.0, this method deletes spawned pages from within Adobe Reader for documents with forms usage rights enabled."

It appears that with Reader version 6 and above can only delete pages that have been added from spawaning the page from a template.

George Kaiser

jmnw
Registered: Jul 29 2010
Posts: 5
gkaiseril,

Thanks for your response. I did read that note and had asked about it above. I wondered if that meant ONLY spawned pages, but I'm guessing yes. I just wanted to check with the forum and make sure I wasn't missing something.

Thanks,
Jane

J. Millet