Copy link to clipboard
Copied
Hello Community!
New user here. I'm working on creating a fillable form with a button that inserts new pages from a template. The page appears as below. I need to make the template such that some fields are linked and some are unique to each page. The info above each photo, once entered by the user, should be the same on every page. The button which goes to get the icon to become my image, however, needs to be unique. I also want the page numbers and photo # labels to be accurate. Thanks in advanced for any help!
-JM
Copy link to clipboard
Copied
Hi,
Can you confirm the version of the software and operating system you are using?
Can you also share how you created the file.
In Acrobat, there are 2 ways to get content to appear in more than one field:
- name the field with exactly the same spelling
- use a script to read and copy the content from an original field (using script)
Copy link to clipboard
Copied
Ha rookie mistake. It's Acrobat Pro DC Version 2019.021.20061 running on Windows 10.
The image is from the original file my supervisor presented me with that I was attempting to build on, but I'm planning on starting over because of the problems I've had so far. I'm not sure if I'm answering the question of how I created it or not. In my tooling aroud, I took the original page and made it a hidden template. The button has a JavaScript that spawns a new page from said template.
Copy link to clipboard
Copied
When spawning a page all fields are renamed or not renamed, we can't mix. And JavaScript can't rename a field.
You can:
- spawn a new page without renaming fields, and create the "image" and the "label" fields with new names on the fly using JavaScript.
- spawn 2 times: one time (new page) with renamed fields, and one time (above the new page) without renaming fields. But this requires to spawn two 1/2 templates.
Copy link to clipboard
Copied
Okay, so let's talk about the first option. Would I need to have my template contain only the fields I want to be identical? Then have a script run to make the others?
Before I knew about permissions and secuirty, my planned approach was to use newPage() and have all the fields be created by JS. When I learned I had to use a template to insert the new pages, it made sense to me to make the template look like what I needed.
How do I choose if fields get renamed?
Copy link to clipboard
Copied
Okay, I should have looked into it. I see how to set bRename when I spawn the page.
Copy link to clipboard
Copied
Would I need to have my template contain only the fields I want to be identical? Then have a script run to make the others?
Yes and no. Spawn the most numerous fields and use JavaScript to create the least numerous fields. Since it's easier to spawn a field than to create it with JavaScript.
How do I choose if fields get renamed?
See the bRename parameter: https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/Te...
Copy link to clipboard
Copied
Spawn the most numerous fields and use JavaScript to create the least numerous fields.
Okay, that makes sense. Here I need advice, and for that, need to elaborate on my plan. The final product I'm going for will allow the user to add the blank pages to the end or between any pages they wish, delete photos and all accompanying labels/info, and move/rearragne photos already inserted. What I pictured was a few buttons that would be on each page such as: Add Page, Insert Page Before ___, Move Photo to ___, Delete, etc. Since some buttons will act on the images which will have unique names, I assume they will also be uniquely named. Is that correct? (I wish I knew the terminology I'm obviously missing here. Something about forms vs. widgets??) It sounds to me like I should spawn the renamed fields and create the common stuff in JS. Does this sound right?
Copy link to clipboard
Copied
I should spawn the renamed fields and create the common stuff in JS. Does this sound right?
Yes
Copy link to clipboard
Copied
Since some buttons will act on the images which will have unique names, I assume they will also be uniquely named.
Spawned fields are logically renamed:
P1.xxxx
P2.xxxx
P3.xxxx
etc.
So the button script can detect which page it is on, and therefore add the prefix corresponding to the targeted field's name.
Copy link to clipboard
Copied
- spawn 2 times: one time (new page) with renamed fields, and one time (above the new page) without renaming fields. But this requires to spawn two 1/2 templates.
So I finally understood this and implemented it. It's great for what I'm doing so far. I forsee a potential problem with pages being deleted though. If I spawn a few pages then later delete one, the next new page will auto-name the fields using the same P# of the last page. This causes them to have #0, #1 suffixes and links them. I'm afraid I know the answer, but is there a simple way around this that doesn't involve creating each field individually with JS?
Copy link to clipboard
Copied
If I spawn a few pages then later delete one, the next new page will auto-name the fields using the same P# of the last page.
To avoid this issue I delete all previously spawned pages, and re-spawn all the pages that are needed in a correct order.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now