InDesign-Acrobat automated pdf quiz maker

quiz_demo_files
This script was an experiment inspired by a discussion on an InDesign LinkedIn group. I am posting a zip file that contains:
1. An InDesign file (in IDML) explaining the requirements for using the quiz maker along with some quiz questions.
2. A script-generated pdf file based on the InDesign file with the completed quiz.
3. An ExtendScript file used to create the pdf from the example InDesign file.
4. An Acrobat 10 Action file used to finish the creation of the quiz functionality in the pdf file.
5. A “.js” file containing the Acrobat JavaScript used in the Action, which is adapted from Marijan Tompa’s script for converting buttons created in InDesign into other form fields in pdf.

Creating a quiz is a two-step process:

1. Running a script in InDesign which makes some temporary changes to the active document and then prompts the user to export an interactive pdf.
2. Running an Acrobat Action on the pdf created in step 1.

The script was briefly tested in InDesign 5.0 and 5.5 on the Mac. The Acrobat Action requires Acrobat 10.

Many thanks to Marijan Tompa. His method of handling the creation of radio button groups with Acrobat JavaScript from his popular tomaxxiFORMS script at http://indesignsecrets.com/the-holy-grail-has-been-found-create-forms-fields-in-indesign.php was essential to my experiment.

The script is made available on an “AS IS” basis with no warranty of any kind, either express or implied.

Posted in Acrobat JavaScript, ExtendScript, InDesign, pdf | Tagged , , | Leave a comment

Object styles structure InDesign output to html and epub: demo script

applyObjectStyleByParaStyle.jsx
Object styles applied to page items determine the class name of containing divs in html and epub output from InDesign. Object styles need not apply any formatting at all, even though this is their primary use in InDesign. They may instead be used to identify certain content by name both in InDesign and in html output generated by InDesign. This utility of object styles goes beyond assigning a distinct class name to a single text frame’s content upon html export. It is possible to cause uniquely named, hierarchically nested divs to be created in the html output. These divs bear class names based on applied object styles like so:


Applying object styles programmatically using ExtendScript can be very useful in some circumstances. The script, applyObjectStyleByParaStyle.jsx, serves as a simple demonstration. This script acts on the active InDesign document. It prompts the user to select a target paragraph style and an object style in the active document. The script applies the selected object style to every text frame in the document that has its first paragraph styled with the target paragraph style.

Posted in epub, ExtendScript, html export | Tagged , | 1 Comment

Replace a group of page items with a linked eps file

replaceSelectedGroupWithEPS

InDesign allows you to export elements on a page out to files in various formats, including eps format. In the case of eps, however, you are limited to exporting an entire page. The script, “replaceSelectedGroupWithEPS.jsx,” uses a workaround to enable you to export a group of items on a page without exporting the entire page. The script then imports the eps created to replace the original page content.

This script will prove useful if you create diagrams or figures using multiple page items within InDesign and you want to tag these items as a single element for pdf output or if you wish to reuse the content elsewhere.

How to use replaceSelectedGroupWithEPS.jsx

Select either a single group of page items or a single page item located on a single page. Run the script. Enter a name for the eps file to be created when prompted.

Results

The selected element will be replaced in the layout by a linked eps file created by the script. The eps file will reside in a subfolder called “Links” within the folder containing the current InDesign document. This subfolder is created by the script if it does not already exist. The originally selected group or page item is not deleted; it is moved to an invisible layer called “hide.” The script creates this layer if it does not yet exist. If the targeted group is anchored, the eps image will be similarly anchored.

Limitations

Exporting page elements containing text wraps or text set to align to the baseline grid may cause text to move from its original position in the eps file created. A group targeted by the script must reside entirely on a single page. The script supports custom anchored elements and inline elements, but it does not support above line elements. The script uses the default eps export options. Change the default eps export settings before running the script if necessary. The script works in InDesign CS 5.5 or higher.

Posted in Uncategorized | Leave a comment

Script to sort an InDesign story by its headings

sortStoryByHeadings.jsxbin

This script sorts multiple sections of an InDesign story into alphabetical order according to the heading of each section. It works for InDesign 5.0 and 5.5. The script has 3 sorting options. You can sort a story by:

  • Entire text of heading paragraphs
  • Word after index marker within headings
  • Word or phrase identified by character style within headings

The key to getting the correct result is making sure that the heading for every section is a single paragraph and has the same paragraph style applied. The paragraph style used for section headings must be used exclusively for that purpose within the story. Each section in the story will likely have a different number of paragraphs. That’s fine. The script determines what makes up a section according to the consistently applied heading paragraph style.

Target a story for sorting by placing an active cursor anywhere in that story. A sorted copy of the story will be placed in a new text frame on the first page of the active document.

Please note that this script is not for use in cases where the text to be sorted contains cross-references. Any cross-references present in the text will become invalid as a result of the sorting operation performed. Hyperlinks in the sorted text are preserved.

If you need to sort a story with many sections spanning across many pages sortStoryByHeadings might be just what you need.

See a demo of the script on YouTube.

The script is made available on an “AS IS” basis with no warranty of any kind, either express or implied.

Posted in ExtendScript, InDesign | 2 Comments

InDesign Pie and Ring Graph Styles: High-end visual design meets automated mass production

It is possible to automate the creation of numerous, highly customized data graphs within the InDesign page layout program much more quickly than could be done using commercially available graphing software.

Using Mariusz Sobolewski’s Pie Graph Tool script posted to the Adobe InDesign Exchange in 2005 as a starting point, I created scripts that generate pie graphs and ring graphs with numeric labels and legends. The scripts include the ability to explode selected slices of these graphs and implement a basic graph style functionality in InDesign. Here are screen captures of two examples of graphs created in InDesign using ExtendScript.

I also created a basic user interface using ScriptUI to help demonstrate the graph style concept. This interface could be used by a production artist to define new graph styles to be applied programmatically by a script in an InDesign template document.

The graph style designates a single paragraph style group and a single object style group in an InDesign document for use by the pie graph scripts. The graph style also identifies which of the paragraph styles in the designated group are to be used for the graph’s numeric labels and for its legend text. In addition, the graph style maps specific object styles within the designated group to specific slices of the pie graph. Here is what the interface for the pie graph script looks like in its default state, before the user applies any overrides:

The required initial conditions for running the pie graph script are:

The user has two objects selected:

  1. A circle of the size desired for the pie graph
  2. A single text frame with a 2-column InDesign table containing legend text and data.

The dialog above was displayed based on the selection shown below (plus the settings of a predefined default graph style).

Graph scripts  such as these can be customized in myriad ways. For example, data can be read from an xml file or an Excel workbook–instead of a table in the layout–without displaying a user interface. I took the latter approach in generating about 1,000 graphs similar the the one pictured below for a series of variable data reports created in InDesign.

Here’s a video demonstration of the scripts at work.

Play YouTube video

Posted in ExtendScript, InDesign | 5 Comments

Scripts for tagging and for gathering and applying alternative text and document metadata

AltTextDocInfo.zip

The zip file attached contains 3 InDesign CS5 scripts, 1 Acrobat 9 batch sequence, and a user guide.

The first script ‘tagDocumentPlus.jsx’ is similar to ‘tagDocument.jsx’ posted previously. It tags all untagged, placed graphics in the active InDesign document as either Artifacts or as Figures with an Alt attribute. It also maps all paragraph styles to xml tags. tagDocumentPlus.jsx can be used by itself or in conjunction with ‘makeAltTextForm.jsx’, ‘_finishAltTextDocInfoProcessing.sequ’, and ‘importAltTextDocInfoFromFDF.jsx’.

These latter items make it possible to generate an interactive pdf form from an InDesign document that can be used by a subject matter expert or editor to enter alternative text for images and document metadata elements (title, author, description, and keywords) using Adobe Reader. The data from this form can then be mapped back into the original InDesign document automatically.

The user guide is included here as a Slideshare presentation.

These scripts are intended for use with InDesign CS5 and Acrobat 9 on the Macintosh platform.

Posted in InDesign, pdf, Section 508 accessibility | 10 Comments

An efficient workflow for authoring and applying alternative text for images

InDesign documents are the best place to apply alternative text to images. Alternative text specified as the value of an Alt attribute of a Figure tag that is applied to a graphic in InDesign is preserved in every pdf file created from that InDesign document.

Writing and applying concise, informative alternative text presents challenges. Who does the writing? Who matches up the text snippets with the images in InDesign? Does the work group agree on who owns this responsibility?

In many instances, InDesign users could write alternative text themselves. The user can type the Alt text right into that little InDesign attribute dialog box. In other cases, an editor or a subject matter expert will need to write the alternative text. For example, a complex data graph portraying subtle trends involving highly technical or arcane phenomena will call for a specialist to step in.

How can the InDesign expert and the subject matter expert work together efficiently to create and apply alternative text? By “efficiently,” I mean without copying and pasting snippet after snippet of text from a Word document into the correct place in an InDesign document.

A tool to facilitate the authoring and applying of alternative text that does not require the subject matter expert or the editor to use InDesign is needed. Ideally, such a tool would:

  • Allow multiple individuals to write, review, and revise alternative text for images in an InDesign document.
  • Allow the writer to view the image for which alternative text is to be written in the context in which it appears in the publication layout and also allow the writer to compose the alt text in that same context.
  • Avoid the need to retype text.
  • Avoid awkward copying and pasting of text from one application to another.
  • Handle key elements of document information, such as title, author, description, and keywords at the same time.
  • Automate the matching up of alternative text and document information to all of the correct images and metadata fields in the InDesign document.
Posted in InDesign, pdf, Section 508 accessibility | Leave a comment

InDesign script enhances 508 accessibility of pdfs

tagDocument.jsx

If you use Adobe InDesign and you need to create pdf documents that comply with section 508 guidelines for accessibility for people with disabilities, there are best practices, such as:

  • mapping paragraph styles to xml tags
  • tagging placed graphics as figures or as artifacts
  • creating “Alt” attributes for the figures to hold alternative text.

These routine measures can be carried out through the user interface of InDesign, using the Tags palette and Structure Panel, prior to pdf export.

Or, a simple script can automate these tasks instead.

A designer can readily determine which placed graphics will need alternative text and which will not. Indicating this determination using a file naming convention enables a script to handle the appropriate tagging of graphics.

If a graphic is pure visual decoration, it should be tagged as an artifact and thus needs no alternative text. If a graphic conveys meaning, it should be tagged as a figure and assigned alternative text that provides an appropriate description.

The script, “tagDocument.jsx,” acts on the active InDesign CS5 document. It relies on two simple conventions to identify which graphics should be tagged as artifacts and which should be tagged as figures having an “Alt” attribute for adding alternative text later on:

  1. Any untagged graphic on a master page is tagged as an artifact.
  2. Any untagged graphic on a normal publication page having a file name that contains either of two 4-character sequences, “art_” or “_art” (case insensitive) is also tagged as an artifact.

All other untagged graphics are tagged as figures and assigned an Alt attribute.

In addition, every paragraph style in the document is mapped to the “P” tag by default. Paragraph styles named according to the html convention for headings of varying levels (H1, H2, H3, H4, H5, H6 ) are mapped to xml tags with the same names. Paragraph styles with names that contain one of these 2-character sequences are similarly tagged.

Note that the script removes any existing styles-to-tags mappings and replaces them with the mappings described above. However, previously tagged, placed graphics are not affected by the script, with one exception: an Alt attribute is added if the assigned tag does not already have one.

Posted in InDesign, pdf, Section 508 accessibility | 35 Comments