Copy link to clipboard
Copied
over 40-odd pages in a document.
I can create multiple copies, but only to a maximum of approx 25 on one page.
I can duplicate the boxes over multiple pages, but then they are duplicates not individual fields so if I tick one box it'll tick them on all the other pages.
I want to keep the root name the same for all the checkboxes as I want to write a script at the end to summarise them all - but I can't do this if I copy and paste the checkbox.
Is there a better way of doing this, or do I just have to copy & paste my checkboxes and select fields at the end for the summary?
Thank you
Copy link to clipboard
Copied
Yes, there is. You can convert the page to a Template object and then spawn copied from it, with unique (but predictable named) field names on each copy. This requires using a script.
If you're interested, I've developed a (paid-for) tool that allows you to do it quickly and easily, without having to write any code yourself, and I'll be happy to help you set up the calculations after running the script, so you don't have to manually enter all the field names.
You can find it here: https://www.try67.com/tool/acrobat-duplicate-pages-of-a-pdf-file-including-form-fields
Copy link to clipboard
Copied
Thank you! I think that's the script I meant to buy from you but got the wrong one. I will check it out, thank you. I don't think you can do Templates unless you have a very high tech version of Acrobat (from my googling).
Copy link to clipboard
Copied
Well, you need Acrobat Pro to be able to do it via the application's UI, but if you use a script it's possible to do it in both Acrobat Pro or Acrobat Standard, but not in the free Acrobat Reader... However, in Reader you also can't add form fields, so I don't think you have that.
Copy link to clipboard
Copied
I have Pro but can't see an option to convert to a template anywhere inc. tools.
Copy link to clipboard
Copied
It's under Tools - Organize Pages - Page Templates. But you can only create them there, not spawn them.
Copy link to clipboard
Copied
Thanks, and it looks like to spawn the templates I need a button to add to each page. Then when I click on the button I run the script. Unfortunately I can't afford your option at the moment!
Copy link to clipboard
Copied
Hmm I've got it to spawn pages (great) but not fields which is what I was aiming for. Do I have to create the fields on an absolutely blank page?
Copy link to clipboard
Copied
- You don't need a button to add each page. You can run the code from the JS Console.
- I thought you added the fields already... If not, you need to add them (via Tools - Prepare Form) to the page you defined as a Template, and then spawn copies from it. The fields won't be added or changed automatically after the spawning.
Copy link to clipboard
Copied
Yes, the page I selected as a template already has fields on it, which are copied over; but it's also copied over/spawned all the text behind the fields, formatting, colour, etc. which doesn't work as each page is unique.
Copy link to clipboard
Copied
Also if you do it in the console, how does it know when you want to spawn the template?
Copy link to clipboard
Copied
> Also if you do it in the console, how does it know when you want to spawn the template?
When you execute that code, that's when it spawns the Template...
Copy link to clipboard
Copied
Yes, the Templates includes the entire page's contents, not just the fields.
If you only want to duplicate those it will be more difficult. Basically, I would use the built-in Duplicate Fields Across Pages command then another script to "rename" them (I use quotes because you can't do that directly, you have to remove them and create new field with the right names), OR you could use a script to create the fields from scratch in the right positions and the right names.
Copy link to clipboard
Copied
Another option is to replace the spawned pages with a blank page, I guess... That will keep the fields in tact but remove the underlying page's content.
Copy link to clipboard
Copied
It'd still be a blank page though and the text is already in place... still this is all very useful information for the future, so thank you.
Copy link to clipboard
Copied
I think that's the simplest way for now; duplicating fields & then renaming.
Copy link to clipboard
Copied
Can't you create all the checkboxes on page one using Create multiple copies, then cut and paste them to the other pages? Are the checkboxes in the same location on every page? If so you can run a script in the console to create the fields on every page.
Copy link to clipboard
Copied
More or less. They may require some jiggling but not much.
Copy link to clipboard
Copied
On page 1, create the first check box (named "Check Box" in this example); Create multiple copies 25 down and 1 across. Now you have Check Box.0 through Check Box.24. Move the check boxes into place and run the following script in the console to create 25 uniquely named check boxes on pages 1 through 40 of the document in the same location as those on page 1:
var rects=[];
for(var i=0;i<25;i++)
{rects.push(this.getField("Check Box."+i).rect)}
var fldNum=25;
for(var i=1;i<this.numPages;i++)
{
for(var j=0;j<25;j++)
{
this.addField("Check Box."+fldNum,"checkbox",i,rects[j]);
fldNum++;
}
}
Copy link to clipboard
Copied
Thanks so much for this!
I need approx 5 per page, for the next 40 or so pages. So I have created 5 copies down. I then put in the script but as it starts on page 5 and I have 5 fields, I've amended the script as below but nothing is happening which suggests that I have done it wrong!
I'm putting it in the console which comes up when I press CTRL+J, which I figure is where it should go...
var rects=[]; for(var i=0;i<4;i++) {rects.push(this.getField("LOC."+i).rect)} var fldNum=4; for(var i=5;i<this.numPages;i++) { for(var j=0;j<4;j++) { this.addField("LOC."+fldNum,"checkbox",i,rects[j]); fldNum++; } }
Copy link to clipboard
Copied
ETA I've added it to "document javascript strings", do I need to press anything to get it to run?
Copy link to clipboard
Copied
I don't know what that means. Are you familiar with the JavaScript Console?
Copy link to clipboard
Copied
The script looks good. "Nothing is happening" - It should either create the fields or throw an error. Are you selecting entire code in the console before running it?
Copy link to clipboard
Copied
I have set it up as a button and then I click on that button to run the code.
I get this in the debugger:
Exception in line 1282 of function AFSimple_Calculate, script byteCodeTool
Exception in line 1 of function top_level, script Field:Calculate
TypeError: f is null
1282:byteCodeTool
TypeError: f is null
1282:byteCodeTool
TypeError: f is null
1282:byteCodeTool
TypeError: f is null
1282:byteCodeTool
TypeError: f is null
1282:byteCodeTool
Copy link to clipboard
Copied
It looks like you have a lot of errors in your form. Those errors have nothing to do with the script I provided. Clear the console and run the script there.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more