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

Add page content with JS and retain tags

Community Beginner ,
Feb 02, 2024 Feb 02, 2024

Copy link to clipboard

Copied

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.  

TOPICS
JavaScript , PDF , Standards and accessibility

Views

123

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 ,
Feb 02, 2024 Feb 02, 2024

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
Feb 05, 2024 Feb 05, 2024

Copy link to clipboard

Copied

LATEST

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.  

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