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

Trouble hiding and showing pages

New Here ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

I have a five-page pdf document and on page one I have one group of two radio buttons.  If selecting Choice1 radio button I want page 3 to hide and if Choice2 radio button is selected I want pages 2, 4, and 5 to hide.  I'm using the following script and no pages will hide with either radio button choice.  I have tried saving as a test document and removing all fields so I only have the two radio buttons with the following script and text on all the other pages and it still won't hide any pages.

 

var radio = this.getField("Group1.Choice1"); // Replace with your actual radio button field name // Array to define the pages you want to hide or show var pagesToHide = [1, 2, 3]; // Adjusted for shifted numbering var pagesToShow = [0, 1, 3]; // Adjusted for shifted numbering if (radio && radio.value === "Choice1") { console.println("Choice1 selected - Hiding pages 2, 3, and 4."); for (var i = 0; i < pagesToHide.length; i++) { this.setPageHidden(pagesToHide[i], true); } for (var j = 0; j < pagesToShow.length; j++) { this.setPageHidden(pagesToShow[j], false); } } else if (radio && radio.value === "Choice2") { console.println("Choice2 selected - Hiding page 1 and showing all other pages."); this.setPageHidden(1, true); // Hide the first page for (var k = 0; k < this.numPages; k++) { this.setPageHidden(k, false); } } console.println("Radio button script executed successfully."); // Run this script before all other document scripts this.calculateNow();  

Views

207

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 ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



<"moved from using the community">

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 ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

Trouble hiding and showing pages typically refers to difficulties encountered when trying to control the visibility of web pages or content within a web application. This can arise due to issues with the underlying HTML, CSS, or JavaScript code, often caused by errors in coding or conflicts between different elements on the page. Troubleshooting and fixing these problems may involve checking your code for errors, ensuring proper use of CSS and JavaScript, and debugging to identify and resolve issues that affect page visibility.

 

 

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 ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

You can't use CSS or HTML in PDF files. 

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 ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

LATEST

setPageHidden is not a JavaScript method.

 

You should be aware that displaying/hiding template pages does not work in Acrobat Reader.
If your document is to work with Acrobat Reader, you need to spawn the pages while keeping the templates hidden, and delete the spawned pages when they are no longer needed.

Acrobat Reader can only delete spawned pages, not static pages.

 

See: https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsdevguide/JS_Dev_Templates.html

 

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