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

Spawning Templates for use in Acrobat Reader DC

Explorer ,
Aug 03, 2021 Aug 03, 2021

Copy link to clipboard

Copied

Hi Everyone,

I am trying to modify a form that I have created to allow an additional page to be added based on the clicking of a check box.  The form has been developed using Acrobat DC Pro, but all of the users will only have access to Acrobat Reader DC.

I believe that I need to use the "spawn" method with a pre-defined hidden template in JScript but all of the research I have done indicates that this method doesn't work for Reader DC?  I also need to be able to hide/remove the page and clear all associated data if the checkbox is cleared.  I think I am comfortable with the code to do most of the datat validation and clearing, but it is the adding a page to the form that has me stumped.

Any guidance, help or links to appropriate web pages would be very much appreciated.  I have attached a copy of the JScript and the PDF Form for reference.

James

TOPICS
How to , PDF forms

Views

2.7K

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 2 Correct answers

Community Expert , Aug 03, 2021 Aug 03, 2021

You can spawn template pages in Acrobat Reader DC.

Votes

Translate

Translate
Community Expert , Aug 04, 2021 Aug 04, 2021

And you can delete the spawned pages in Reader (but only them!) using deletePages.

Votes

Translate

Translate
Community Expert ,
Aug 03, 2021 Aug 03, 2021

Copy link to clipboard

Copied

You can spawn template pages in Acrobat Reader DC.

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 ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

And you can delete the spawned pages in Reader (but only them!) using deletePages.

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
Explorer ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

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
Explorer ,
Aug 04, 2021 Aug 04, 2021

Copy link to clipboard

Copied

Thanks for the confirmation.  I'll do some experimental code now they I know I can make it work.

 

I'll post my results soon.

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
Explorer ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

Hi Everyone that assisted so far.

 

I have successfully been able to add and remove a spawned template, and the associated code I needed to make it work is almost working.

 

The problem I now have is that I need to clear the contents of a table that I am using under certain conditions.  To creat the various lines and fileds within the table I used the replication function in Acrobat Pro so each line has the feild name followed by an automatically generated sequential number.  i.e. Description.0, Description.1, Description.2, etc.  This was done for each feild in each coloumn.

 

In order to Clear to contents of each field in the table , I want to get the field using the "this.getField("fieldname")" and then set it to zero.  I have also wondered if the setFieldValue function might also acheive the same outcome?

 

My intent was to use a while function and just loop through the fields, as they are sequentially numbered.  The problem is I can't seem to concatinate the fieldname and the loop counter value together to form a valid fieldname for use with the get or set functions.  I have tried the + and the & and the && operators in various combinations inside and outsied the quotes and parenthesis with NO luck so far.  I believe this should be possible but I am now stumped.

This is a small part of one version of the example code I have tried:-

 

var z = 0,

while (z < 24) {

    var MQ = this.getField("MaterialQty." + z //where MaterialQty.0 thru MaterialQty.23 are table fields

    MQ.value = 0

    z++

}

 

Noting that it is the green text when concatenated should form a valid field name to use withteh getField function.

 i.e this.getField("MaterialQty.0")

 

Any assistance with this would be greatly appreciated as there are approx. 150 fields I need to zeroise under certain conditions and this in probably the last item to fix before the form is usable in it current iteration.

 

Thanks in advance

James

 

 

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 ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

What happens when you use the script? Any error in the Javascript console?

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
Explorer ,
Aug 25, 2021 Aug 25, 2021

Copy link to clipboard

Copied

Hi Mate,
I get an message "TypeError: MQ is Null" followed by the line number within the action that caused the error.

 

I think I am on the correct track for what I am trying to acheive.  It is just an issue of joining the two parts of the variable together to create a block of text that is then recognised as a legitimate field name.

 

I have been doing a bit of research and I was wondieriong if I don't need to use a different function to join the two parts of the variable.  Any suggestions.

 

James

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
Explorer ,
Aug 25, 2021 Aug 25, 2021

Copy link to clipboard

Copied

LATEST

Hi everyone,

 

It would apearthe I missed a very important part of try to concatenate teh field. I forgat to add the "." between the feild names and the counter index.

Final code that worked is 

while (z < 24)

{

var MQ = this.getField("MaterialQty" + "." + z)

MQ.value = ""

z++

}

 

Sorting this out will actually allow me to fix a couple of amature programming mistakes I have made elsewhere in my form.

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