Chapter Excerpt #1 from "Adobe Acrobat 5 Master Class"
Authors explain the use of 'page transitions' in PDF files

15 July 2002

Master Class

DOWNLOAD: You can also download a Chapter 10 excerpt [PDF: 969kb] that contains illustrated versions of this excerpt and a related one we've also published.

Chapter 10.3: Embedding Page Transitions

The major limitation associated with using page transitions is that they are controlled by the preferences on each user's machine. Fortunately, there are several ways to embed the instructions for page transitions within the document. This makes it possible to create sophisticated page transitions that play anywhere, without relying on the user's preference settings.

Acrobat PDFMarks

Back in the days of Acrobat 3, the Acrobat contained a folder of transition files. You imported an EPS file into the page layout. When the document was distilled, the transition was embedded as part of the page. These transitions overruled the preference settings and allowed different transitions for each page. If you have access to an Acrobat 3 CD, you can still use those files.

Embedding Page Transitions From the Javascript Console

NOTE: The JavaScript from this section is included on the Acrobat Master Class CD. You can also copy and paste it from our text file [TXT: 3kb] into the JavaScript Console.

These days there are easier ways to embed page transitions. The JavaScript Console lets you type in commands (calls) that control page transitions. Using the JavaScript console, you can set different transitions for the various pages. You can also set the length of time each transition runs. More importantly, these transitions work in the normal and full-screen modes. This method of embedding transitions also works when the document is viewed in Reader 4.

Is this easy? We asked the most code-phobic member of our team (Sandee) to try it. Here are the steps she took to add the Box In transition for the first two pages of a document. Don't try to understand the code, right now; we'll explain it all after you've followed the steps and seen it work.

  1. Open the JavaScript Console
    Choose Tools>JavaScript>Console. The JavaScript Console dialog box appears. Don't worry about any text that may be in the console area. The main concern should be the new text you enter.

    Acrobat 5 JavaScript Console

  2. Type the JavaScript
    Click inside the white area of the console, and make sure you're on a new line. Enter the following code as one line, exactly as written. (Watch for the spaces after the colons and commas.)

    this.setPageTransitions({nStart: 0,aTrans: [-1, "BoxIn", 1], nEnd: 1});
    

    Press the 'Enter' key on the numeric key pad to send the code from the console into the document. If you've entered the text correctly, you will see the word "undefined" appear in the console text area. If you're on a keyboard that doesn't have a numeric keypad, hold the 'Alt' key (Win) or 'Control' key (Mac) when you press 'Enter' (or 'Return') to execute the script.

  3. Save and Test
    Save the file, close the document, and then reopen it. Use any of the navigation controls to move between pages. The first two pages will appear with the Box In transition. The other pages will appear with whatever transition has been set in the Full Screen Preferences. If you want to modify your embedded page transition, you must enter the new call in the console and then press the Enter key to send it to the document.

Understanding The JavaScript Page Transitions Code

Here's a breakdown of the JavaScript code in the previous exercise:

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
This phrase says the script is to set the page transitions.

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
nStart specifies the page of the document for the transition. Acrobat starts numbering pages with 0.

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
aTrans sets the definition array for the transition.

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
The information in the square brackets is an array, and sets the definition of the transition. The first number controls how long (in seconds) the page is displayed. The value of - turns off automatic page advancing.

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
This is the name of the transition as it appears in the preferences. Type the name of all transitions without any spaces.

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
This number sets the duration of the transition. The 1 here stands for one second.

this.setPageTransitions({nStart: 0, aTrans: [-1, "BoxIn", 1], nEnd: 1});
The nEnd number stands for the last page you want the transition applied to. If you want only one page to have the transition, you can delete this part of the code.

Applying a Transition to All Pages

If you want to apply a transition to all the pages in a document, use this code (Here, we changed the transition to Dissolve):

this.setPageTransitions({aTrans: [-1, "Dissolve", 1]});

Deleting the Embedded Code

What if you want to get back to a normal document without embedded transitions? You'll have to send a command to delete the embedded transitions. (Clearing the JavaScript Console won't work.) Here's the code to delete the transitions from the first two pages:

this.setPageTransitions({nStart: 0, nEnd: 1});


MORE INFO

To Top


PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.