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

Unhiding Templates and Dropping them in at specific page locations.

New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi All,

 

I am new to the forum and have only Javascript knowledge that I have accurded by my own learning. I am wondering if it is possible to unhide a template page within an Acrobat document and have it appear at a specific page number in the document.

 

I have been able to hide and unhide a template page using java but it always reappears at the bottom of the document and thus doesn't then fit in with the document flow. Although users will be using Acrobat Pro DC they have no Idea how to use it and from their prospective use it as Reader which is the desired route as to many hands will start messing etc.

 

The form I am creating is almost done and will auto create  the document based on drop downs and field populations from the first page, the selection area won't then print on the final document. I have tried using various approaches such as allowing privileged functions for adding in PDF's and deleting PDFs and it all goes a bit wonky when the deletepages command is used as it goes by page number (which is always changing) rather than the file name of the PDF.

 

An example of the template script I am currently using on a checkbox is below.

if(event.target.value!="Off")
{this.getTemplate("Testimonials" ).hidden=false;}
else
{this.getTemplate("Testimonials" ).hidden=true;}

 

If it is a case of just using nPage or a move command after unhiding or something like that I just don't know where to add it.

 

Thanks for any help.

 

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to , JavaScript , PDF forms

Views

1.2K

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi,

 

If you use the template object, it has a method called spawn which enables you to specify the page. as below.

BarlaeDC_0-1617715642186.png

 

 

 

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
New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi, Thanks for super fast response.

 

Will the spawn function allow for it to be deleted when unchecked without causing other pages to be deleted if page numbers change etc?

 

I will take a look at the refference guide under spawn.

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Yes, you can delete spawned pages without it affecting other pages. As for the page numbers that's something you'll have to do yourself, using a script.

 

To answer your question: When you unhide a Template page it automatically appears as the last page of the file. You can't control it. However, you can of course move it to another location afterwards. Note that both unhiding a Template page and moving a page around are not possible outside of Acrobat, though.

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
New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi Try 67,

 

Thanks for your reply, I am a bit lost, when you say  "Yes, you can delete spawned pages without it affecting other pages" how do I do this?

 

You mention something about using script to alter page numbers? Could I ask for an example of this so I can try and understand the code.

 

Many Thanks.

 

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

- Read the documentation of the spawn method of the Template object and the deletePages method of the Document object.

 

- It depends on what kind of page numbers you're referring to, actually. Do you mean the ones that appear in the Pages panel, or ones that are on the actual page itself?

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
New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi Try67,

 

The Page Panel, there are no page numbers on the pages.

 

Thanks

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

In that case it's automatic. You don't need to do anything about it, unless you want to apply page labels which are not the same as the physical page numbers.

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

In Acrobat Reader you can delete spawned pages.

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
New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Hi Again,

 

I have tried running the below code which does move the unhidden the page and move it to the correct location however I then get the below error.

 

if(event.target.value!="Off")
{this.getTemplate("Testimonials" ).hidden=false;}
else
{this.getTemplate("Testimonials" ).hidden=true;}
{this.movePage(this.numPages-1,3);}

 

Error:

RaiseError: Expected an array object.
Doc.movePage:5:AcroForm:Check Box12:Annot1:MouseUp:Action1
===> Expected an array object.

 

Can anyone point out what is wrong with my code which I am sure is obvious to the trained eye? I have read the API guide however as I am not a Javascript expert it is somewhat hard too understand at times.

 

Many Thanks.

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

You're a bit too liberal with those curly brackets... Also, I think you have it the wrong way around. Don't you want to move the page after making it visible? Try this:

 

if(event.target.value!="Off") {
	this.getTemplate("Testimonials" ).hidden=false;
	this.movePage(this.numPages-1,3);
} else {
	this.getTemplate("Testimonials" ).hidden=true;	
}

 

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
New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

Thanks, I have tried that and when Checked the error still occurs and states the below even though it does unhide and move the page.

 

"RaiseError: Expected an array object.
Doc.movePage:3:AcroForm:Check Box12:Annot1:MouseUp:Action1
===> Expected an array object."

 

When unchecked however the error doesn't occur and the page hides just fine.

 

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 ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

I'm guessing there's a problem with that page. Try moving it manually and I bet you'll get a similar error message.

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
New Here ,
Apr 06, 2021 Apr 06, 2021

Copy link to clipboard

Copied

LATEST

Hi,

 

Lol, I was just trying that myseld and got error Document 15 when I moved any page so I deleted all of the tags and its is now working.

 

Thanks for your help.

 

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