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

Delete pages in Adobe Acrobat READER

Community Beginner ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

I recently created a PDF file that contains a button for deleting a page:

this.deletePages(this.pageNum, this.pageNum)

This all worked perfectly in my Adobe Acrobat environment but it didn't work for anyone who was using Adobe Reader. I soon found out through the forums here (thanks try67) that the deletePages function only works in Adobe Acrobat OR for spawned pages. 

So my thought process is now, that I simply create a PDF with all fillable fields and then create a template for each page in the PDF:

for (var i = 1; i <= this.numPages; i++)
    this.createTemplate({cName: i, nPage: i});

 Afterwards, I spawn all my templates:

var a = this.templates;
for (i = 0; i < a.length; i++)
    a[i].spawn(this.numPages, false, false);

 

Now I'd have x amount of original pages and x amount of spawned/duplicated pages. I then delete the original pages in Acrobat Pro and save the document with only the spawned pages. Like this, the spawned pages should be deletable in Adobe Reader, but it looks like they are not.

 

So, my questions are:

- Is this the correct procedure or is there maybe an easier one? If it is the correct procedure, what am I doing wrong?

- Is there a way to install Adobe Acrobat Reader in parallel to Acrobat Pro? Because it is super annoying to have to get 2 devices and install one software on the first device and the other software on the second device and then send the documents back and forth between the devices only to test the functionality in Adobe Acrobat Reader. This can't be the only solution, right? I mean, I'm a paying customer for Adobe Acrobat and yet I have no chance of testing my document for the end user.

TOPICS
JavaScript , PDF , PDF forms

Views

3.4K

Translate

Translate

Report

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 , Nov 03, 2023 Nov 03, 2023

So you deleted the original page templates?  That's a no-no.  Page templates must be hidden. That's how they work. You delete them and the spawned pages are no longer spawned, but regular pages. 

 

But why are the pages spawned upfront?  This is normally a forward only process.  A button is added to the form to allow the user spawn a new page when one is needed. 

 

Votes

Translate

Translate
Community Expert ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

Acrobat Reader can delete spawned pages when the pages where spawned in Acrobat Reader. 

Votes

Translate

Translate

Report

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
Community Beginner ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

Thanks Bernd, I didn't know what. Is there any way that I can figure out which page is an original one an which page is a spawned one? I assume Acrobat creates some internal tag/flag in the source code of a spawned page. Can I somehow see that. I'd be intersted in seeing the flag, even if that means that I have to dig beyond the GUI of Adobe Acrobat.

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

No, there isn't such a flag. The only way you can identify a spawned page is if it has form fields that were renamed automatically from those on the original Template page, as their names will have a specific pattern that can be identified.

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

All you have to do is hide the template on the "Templates" dialog and you're good.  Hide it before spawning. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Community Beginner ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

LATEST

The template hiding did the trick. @Bernd Alheit I tested it with spawning the pages from within Adobe Acrobat Pro and it still worked. So, everything is fine now. Thanks to everybody here who took their time to look into this!

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

So you deleted the original page templates?  That's a no-no.  Page templates must be hidden. That's how they work. You delete them and the spawned pages are no longer spawned, but regular pages. 

 

But why are the pages spawned upfront?  This is normally a forward only process.  A button is added to the form to allow the user spawn a new page when one is needed. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Community Beginner ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

Re "why are the pages spawned upfront?". I just have a document in which the user should see all the pages and possibilities upfront and then they can delete a page if not needed.

I'm currently doing a bit more testing, but it looks like this did the trick! In case anyone else ever needs to do this procedure, I also had an error in mine code in the question. When creating the templates, the code should be modified to this, since the numPages and nPage are 0-based:

for (var i = 0; i < this.numPages; i++) {
	name = i.toString();
	while (name.length < 3) name = "0" + name;
	// cName = template name | nPage = 0-based index of page within document
	this.createTemplate({cName: name, nPage: i});
}

 I also added a line which adds leading zeros to the template name, just in case you have more than 9 pages, as the templates aren't sorted by the order they are created but rather by their string value. And then the sorting would look like 0, 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9 which creates a wrong order when spawning the pages later.

Votes

Translate

Translate

Report

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