Skip to main content
Participating Frequently
February 2, 2024
Question

Add page content with JS and retain tags

  • February 2, 2024
  • 1 reply
  • 350 views

I'm trying to accomplish a few things.  Is this possible?  

 

Current state:  Multiple page PDF with tables and form fields in some cells.  Table structure is the same across all tables (same number of columns, varying number of rows).  All content has been structured appropriately in teh Tags pane.  

 

What is desired

  • Based on a result in a form field (e.g., Failed) from potentially multiple rows in multiple tables, I need a new page to be inserted, a table structure created (using the same row of table headers that is on all the tables) and add the complete row of information for any row that had a result of "Failed". 
  • It is likely that only so many rows could fit on a page, let's say 7.  So, I need it to add as many pages with the table structure and header row as necessary to add all data rows that have a result of "Failed". 
  • Based on numbers I provide in a hidden field for each data row, I want the data rows on these new page(s) to appear in decsending order.  E.g. a row has a result of "Failed" and an associated score of "7".  Another data row has a result of "Failed" and a score of "6". 
  • The new pages and content must become tagged in the Tags pane.  Thus, I can't use layers because they are not accessible in the Tags pane. 

 

I created "Templates" and made them invisible for a couple pages hoping that may be a way to maintain tags.  If using "Templates" is a good approach (not a better/easier way to accomplish the above bullets), is there a way to indicate in the JS how to insert the data row content into the existing template table structure?  

 

Thanks!  Stretching the limits of PDFs, but is the only resource available to all recipents.  

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
February 2, 2024

Page templates are the correct way to implement the addition of new pages. And it is in no way stretching the capabilities of PDF. 

 

If all additional pages have the same format, then you only need one page template. It must be made invisible for the working document. Then "spawned" when needed.  

Here's the Acrobat JavaScript reference entry for spawning.  

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#spawn

 

You need to get the page spawning working first before we can help you with filling the fields with data. 

You'll find plenty of posts on this forum explaining how to do this. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
CT1119Author
Participating Frequently
February 5, 2024

Thanks for your response.  The other day, after I posted, I did successfully get a template to be spawned upon an action.  Unfortunately, it seems tags do not carry/get created.  I'll read the resource you provided and see if there's another way to spawn that does retain tags.