Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Creating a TOC

Avatar

Level 2
How does one create a table of contents? Our forms are several pages long and have different sections. Is there a way to create a TOC in the Masterpage?



Much appreciated.

Sgb
9 Replies

Avatar

Level 2
Navigation can be tricky especially if your form is dynamic. If it's static you might look at using bookmarks but if you have to change anything in the form you'll loose the bookmarks.



There are also a few ideas on navigating by identifying the physical location of a form item you want to navigate to in the following post:

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=14377

Avatar

Level 10
Hi sgb,



We have sucess today implementing an Acrobat solution into LiveCycle.



www,pdfscripting.com and Ted Padova's Acrobat 9 PDF book introduced us to pop-up menus. The LC Designer help file does not give much info on the popUpMenu script. There are examples at www.pdfpictures.com.



If you create a button in the master page (or on page 1) and put similar script in the click event:



var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3);



if (choice == "Page 1") {

xfa.host.currentPage = 0;

}



if (choice == "Topic 1") {

xfa.host.currentPage = xfa.host.numPages -7;

}



if (choice == "Topic 2") {

xfa.host.currentPage = xfa.host.numPages -6;

}



if (choice == "Topic 3") {

xfa.host.currentPage = xfa.host.numPages -5;

}



When the user click on the button a pop-menu button appears with the heading you have set in the first line of script. We were luck on this form that the dynamic content (adding additional pages) was at the start of the form, so we were able to count backwards from the total number of pages to get out targets right.



Good luck,



Niall

Avatar

Former Community Member

Niall, hi

I was trying to follow your advice and coppied this code after the click event and see what happened - simply nothing works, is it possible for you to correct this script. I have no idea about syntax in JAVAscript.

<event activity="click"/>
         <event = var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3)&gt;

                if (choice == "Page 1") {
                xfa.host.currentPage = 0;
                }

                if (choice == "Topic 1") {
                xfa.host.currentPage = xfa.host.numPages -7;
                }

                if (choice == "Topic 2") {
                xfa.host.currentPage = xfa.host.numPages -6;
                }

                if (choice == "Topic 3") {
                xfa.host.currentPage = xfa.host.numPages -5;
                }>

My doc is about 40 pages and it would be nice to be able to switch between sections quick.

Thank you

Avatar

Level 10

Hi,

It looks like you have inserted the script in the "XML Source" tab. Would not advise that! The XML Source tab is fine for minor amendments / tinkering, but is not the best place to insert script.

When you have LC open in Design view, there is a window at the top called "Script Editor" (available under the Windows menu).

If this is a single line, it is worth dragging the bottom bar down so that you see a few lines of script at a time.

Create a button on the page and then in Script Editor select the click event. You can then insert your text, as below:

08-07-2009 20-06-08.png

The script would be as before, but without the tags (LC inserts these automatically).

var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3");

     if (choice == "Page 1")

     {
          xfa.host.currentPage = 0;
     }

     if (choice == "Topic 1")

     {
          xfa.host.currentPage = xfa.host.numPages -7;
     }

     if (choice == "Topic 2")

     {
          xfa.host.currentPage = xfa.host.numPages -6;
     }

     if (choice == "Topic 3")

     {
          xfa.host.currentPage = xfa.host.numPages -5;

     }

In the example above I am counting backwards from the total number of pages. If you document is static (number of pages does not increase) you can just script using "xfa.host.currentPage". Just remember that the page numbers are based on a zero numbering system.

Hopefully you should end up with somethin like this:

08-07-2009 20-20-32.png

Good luck,

Niall

Avatar

Former Community Member

Hooray!!! It works!

Great +1 to you Niall. Do you know if it is possible not to count pages but some how link to object on the required page. Because at the moment my document is static and all text fields restricted to the size of the visible area therefore if I'll make it dinamic page numbers will be changing depending on the end user and how much infor they will put into text field.

How would I refer to the  text subform?

Thanks a lot!!!

Avatar

Level 10

Glad you got it working!!

Because your form is static (number of pages does not increase) actually helps you out here.You do not need a flowing form to get this to owrk.

I would advise sticking with "xfa.host.currentPage = xfa.host.numPages"

For example if you wanted an index to go to the last page, the if statement would look like this:

if (choice == "Go to last page")

     {
          xfa.host.currentPage = xfa.host.numPages; // this is nice clean script that can be copied from one form to another

     }

For page 39; xfa.host.currentPage = xfa.host.numPages - 1;

For page 20; xfa.host.currentPage = xfa.host.numPages - 20;

etc...

Test this out, as I think it is the easiest way forward.

If you want to reference a specific object on each page, it can be done but it will make that object active / in focus which may lessen the user experience.  The script would look something like this...

if (choice == "Go to last page")

     {
          xfa.host.setFocus(xfa.form.form1.page40.userInput_textfield); // this will achieve the same thing, but has to be uniquely referenced to objects on each page, ugh

     }

Good luck,

Niall

ps I have just tested this. Normally our form is saved as "Dynamic XML form"; but when I saved is as "Static PDF form" the script continued to work. So no problems with static forms.

Avatar

Level 2

Does someone has an example of working pdf using the code below:

<event = var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3)&gt;

                if (choice == "Page 1") {
                xfa.host.currentPage = 0;
                }

                if (choice == "Topic 1") {
                xfa.host.currentPage = xfa.host.numPages -7;
                }

                if (choice == "Topic 2") {
                xfa.host.currentPage = xfa.host.numPages -6;
                }

                if (choice == "Topic 3") {
                xfa.host.currentPage = xfa.host.numPages -5;
                }>

Avatar

Level 2

Niall,

Do u have working PDF for the example below:

If you create a button in the master page (or on page 1) and put similar script in the click event:

var choice = app.popUpMenu("Page 1", "Topic 1", "Topic 2", "Topic 3);

if (choice == "Page 1") {
xfa.host.currentPage = 0;
}

if (choice == "Topic 1") {
xfa.host.currentPage = xfa.host.numPages -7;
}

if (choice == "Topic 2") {
xfa.host.currentPage = xfa.host.numPages -6;
}

if (choice == "Topic 3") {
xfa.host.currentPage = xfa.host.numPages -5;
}

When the user click on the button a pop-menu button appears with the heading you have set in the first line of script. We were luck on this form that the dynamic content (adding additional pages) was at the start of the form, so we were able to count backwards from the total number of pages to get out targets right.

Thanks.

Avatar

Level 10

Hi,

Here are some examples:

The first one is for a XFA form with a static number of pages (eg easier to keep track of sections): https://acrobat.com/#d=f0knWwFdm45r80NeuqtUvw

This second example is a dynamic XFA form as the user can add pages. https://acrobat.com/#d=0Vwv8jvHYfBuQuGjmjCGrA

In both cases check out the script in the click event of the index button. The buttons is on the Master Page, but does not appear in LC Designer as the way we were working image buttons at the time.

I hope these help,

Niall