[JS][CS5] Enhancing Section 508 accessibility of pdfs from InDesign script

I was using a script to automate mapping styles to tags and tagging graphics as artifacts or as figures with Alt attributes for section 508 accessibility reasons, but in order to encourage use by designers, I wanted to add code to unlock all locked items in the document and then relock those items before the end of the script. Otherwise, the script would hang up when it encountered a locked item. I have an approach that seems to work, but is there a more elegant way of handling the locking and unlocking, especially for anchored and inline graphics?
Also, if anyone finds this code useful, I'd appreciate any feedback based on your use of it.
Preps an InDesign document for pdf output that is closer to section 508 compliancy.
This script acts on the active InDesign document. It removes any unused tags from the tags palette. 
It unlocks everything that is locked.
It creates all necessary tags in the tags palette if they do not already exist.
It tags all untagged, placed graphics as either Artifacts or as Figures as follows:
Any graphic on a master page is tagged as an artifact.
Any graphic with 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.
Graphics appearing on publication pages (not master pages) that were tagged prior to running the script will have an Alt attribute added to the pre-existing tag if it does not already have one.
The script relocks everything that the script previously unlocked.
It removes any existing styles-to-tags mappings.
It creates new styles-to-tags mappings for all paragraph styles based on the following paragraph style naming convention:
Every paragraph style is mapped to the P tag, unless the style name contains a prefix, suffix, or infix matching the format H2_ or _H1 (underscore character optional) 
where the numeric digit indicates the level in the document hierarchy for the headings to which the style is applied.
Paragraph styles with names containing H1, H2, H3, H4, H5, or H6 are mapped to tags with those names.
The script then maps paragraph styles to tags based on the newly created mappings.
THIS SCRIPT IS MADE AVAILABLE ON AN "AS IS" BASIS,  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#target "InDesign-7.0" //for InDesign CS5
var markup_tag_names = new Array( "H1","H2","H3","H4","H5","H6","Figure","P","Story","Article","Table","Cell","Artifact");
var re_artifact = new RegExp("(ART_)|(_ART)", "i" );
var re_heading = new RegExp("(H[1-6]_?)|(_?H[1-6])", "i" );
var arraysAnchoredInlineGraphicsLockStatuses = new Array();
var d = app.documents[0];
d.deleteUnusedTags();
var arrLayersLockStatuses = d.layers.everyItem().locked;
var arrPageItemsLockStatuses = d.pageItems.everyItem().locked;
for (var k  = 0; k < d.stories.count(); k++ ) {
    arraysAnchoredInlineGraphicsLockStatuses.push( d.stories[k].pageItems.everyItem().locked );
d.layers.everyItem().locked = false;
d.pageItems.everyItem().locked = false;
d.stories.everyItem().pageItems.everyItem().locked = false;
for ( var i = 0; i < markup_tag_names.length; i++ ) {
     zTag = d.xmlTags.itemByName( markup_tag_names[i] );
     if ( zTag.isValid ) continue;
     else d.xmlTags.add( markup_tag_names[i] );
var p_tag = d.xmlTags.itemByName('P');
var figure_tag = d.xmlTags.itemByName( 'Figure' );
var artifact_tag = d.xmlTags.itemByName( 'Artifact' );
var root = d.xmlElements[0];
for ( var i = 0; i < d.allGraphics.length; i++ ) {
     g = d.allGraphics[i];
     pg = g.parentPage;
     if ( pg == null ) continue;
     isOnMaster = pg.parent.constructor.name == 'MasterSpread';
     if ( g.itemLink.isValid != true ) continue;
    fname = g.itemLink.filePath;
    fname = fname.substring( fname.lastIndexOf(':') + 1 ); //Mac-specific folder separator ':'
     if ( g.associatedXMLElement == null ) {
        if ( isOnMaster )  {
            root.xmlElements.add( artifact_tag, g );
        else  if (  re_artifact.exec( fname ) != null ) {
            root.xmlElements.add( artifact_tag, g );
        else {
            xmle = root.xmlElements.add( figure_tag, g );
            xmle.xmlAttributes.add('Alt', '' );
     else if ( ! ( g.associatedXMLElement.xmlAttributes.itemByName('Alt').isValid ) && !(isOnMaster ) ) g.associatedXMLElement.xmlAttributes.add('Alt', '' );
for (var k  = 0; k < d.stories.count(); k++ ) {
    if ( d.stories[k].pageItems.count() > 0 ) {
        for ( var z = 0; z < d.stories[k].pageItems.count(); z++ ) {
            d.stories[k].pageItems[z].locked = arraysAnchoredInlineGraphicsLockStatuses[k][z];
for ( var i = 0; i < d.pageItems.count(); i++ ) {
    d.pageItems[i].locked = arrPageItemsLockStatuses[i];
for ( var i = 0; i < d.layers.count(); i++ ) {
    d.layers[i].locked = arrLayersLockStatuses[i];
d.xmlExportMaps.everyItem().remove();
for ( var i = 0; i < d.allParagraphStyles.length; i++ ) {
     var psty = d.allParagraphStyles[i];
     var rslt = re_heading.exec( psty.name);
     if ( rslt != null ) {
          rslt = rslt[0].replace("_", "");
          rslt = rslt.toUpperCase();
          d.xmlExportMaps.add( psty, d.xmlTags.itemByName(rslt) );
     else { d.xmlExportMaps.add( psty, p_tag ); }
d.mapStylesToXMLTags();

Are you running this in a persistent engine?
Have you tried wrapping the myDisplayDialog() call in a try/catch block to see if it is throwing an error?
I can provide all the relevant scripts if necessary, but they're pretty convoluted. The most important one is the user input function. Here it is:
It's quite common that the convolutions are related to the problem. A good exercise is narrowing it down to a small reproducible test case without the convolutions, and often as not you may find the problem in the process. If not, well, at least you'll provide something to test with.

Similar Messages

  • Exporting a pdf from InDesign-need to access Overprint

    I am exporting an InDesign CS5.5 Document with mixed ink and Illustrator eps with pantone overprints.
    When I export it into PDF the native mixed ink in InDesign represent accurately.
    However the Illustrator eps preview as solid gray @ 70%. This is the overprint layer onto of Pantone 293.
    When I turn on Print preview in pdf it is accurate.
    My question is:
    In the export to pdf palette under the output header, there is a check box 'simulate overprint'.
    I've tried several different variations, but cannot get that check box to turn on.
    Unlease I make an X-1a file the overprint for the Illustrator eps does not preview without turning on the output preview palette in Acrobat.
    And lets face it, to the client, that is rocket science.
    How can I access the 'Simulate Overrpint' option when I am exporting the document.
    Thanks,
    J-

    Or, better than that, export the PDF from InDesign as PDF/X-4!
    By default, Acrobat and Reader use overprint preview when displaying PDF/X-4 files. Plus you have the benefit of full color management and not having transparency ruined by premature flattening.
    One other note. Other than for the fairly common practice of overprinting black text over colors to avoid halo effects due to registration, one should be exceptionally careful in using overprint. Trapping, the other good, justifiable use for overprint is really best performed by the RIP. Most modern RIPs provide for automatic trapping. Overprint should absolutely not be used as a “poor man's transparency,” especially in conjuction with spot colors. With the advent of real transparency in the Adobe imaging model and hence in Illustrator, InDesign, and PDF, there is no good reason to use overprint hacks anymore to simulate transparency.
              - Dov

  • Why does black turn grey when creating a pdf from InDesign CS5??

    Why do blacks turn to grey when I create/export a pdf from InDesign CS5?

    Unfortunately, things like this are rarely glitchy little programming errors but deep, by-design, problems with using colour management. Usually you are getting exactly what you asked for, just not what you want, and the more colour management options there are, the more likely this is.
    There are many possible causes, but one of the easiest to do is and hardest to spot is applying a CMYK profile in InDesign export, and a different one through Photoshop settings. This is actually demanding that colours be converted for the worst! Since your print workflow will be different, a work-around of rich black is likely to make things worse.
    So the first thing to check is whether the colours you indended made it to the PDF, indeed. Output Preview is the first tool to use (as well as inspecting plates, you can hover over points to check the colour mix).
    Also, go to your PDF export under the "Output" tab which includes colour and PDF/X. Either send a screen shot, or read off all of the the settings there.

  • Failure to fully export pdf from InDesign CS2 (application unexpectedly quits)

    I found a TechNote detailing such an issue when you save or export a PDF after the Adobe application has been left idle for several days. However, when I tried both suggested solutions, I was unable to fix the problem. Some say it may be that I have a corrupt file, but the file saves normally and shows no signs of error.
    When I try to export a file as a PDF file from InDesign CS2, I don't get an error message when I save the file. I only receive an error message when I try to open the resulting PDF file which has not been fully processed.
    The error message I see is as follows:
    * Exporting a PDF file from InDesign CS2: The file appears to save without error, but when I open the file with Acrobat I see the error "Acrobat could not open '[file name]' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). To create an Adobe PDF document, go to the source application. Then print the document to Adobe PDF."
    Thus, I tried solution 1: upgrading my Mac to Mac OS X v10.5. That didn't work.
    Then I tried solution 2: save the file, and then restart the application. That also did not work.
    The TechNote goes into further detail, explaining:
    "When you save or export PDF files from Photoshop CS2, Acrobat 7, Illustrator CS2, or InDesign CS2, the application must reference the TemporaryItems file located in /tmp/501. Prior to Mac OS X.v10.4, Mac OS X regularly deleted files in the /tmp folder that had not been used or modified within a certain period (approximately two or three days). If an Adobe application is running but unused for several days, Mac OS X prior to version v10.4, would delete the TemporaryItems file. When you save or export a file as PDF, the Adobe application attempts to reference the no-longer existing TemporaryItems file which results in errors or faulty PDF creation.
    When you restarting the Adobe application and then save or export a PDF, the application rebuilds the TemporaryItems file."
    Does anyone have any other suggestions for a solution to my query?

    Similar to you, I've just posted the following in the InDesign section:
    Problems writing pdf from InDesign CS2
    Hello everyone, I've just gone and bought myself a new 2.4ghz iMac and done all of the updates for Tiger so I'm now running 10.4.11. InDesign CS2 is version 4.0.5.
    I have a simple A4 document with 3 placed images which is an updated version of many done previously. I've never had any trouble writing pdf's from them before until tonight on my new Mac. It seems to get about half way through and InDesign quits.
    If I print to a pdf file then it's okay, but a bit long winded when you get used to exporting from InDesign.
    Any ideas?
    Thanks
    Trev

  • I need to create a PDF from InDesign that people can edit in Reader or Acrobat

    I need to create a PDF from InDesign that people can edit (for example, change a name from "John" to "Johnny") from either Adobe Reader or Adobe Acrobat. I have already looked at forms, but they do not keep your font colors, faces, and sizes and just make everything that is selected as a text form Black, 12pt, Times New Roman.
    Can anyone here help me?

    Vincent,
    If you use Acrobat pro, generate your .pdf file and then save it as (french version):
    ... so that anyone using Acrobat Reader (or Pro, of course) can modify the .pdf file (with limitations), add comments, ...
    If you want to try to "protect" your .pdf file, you can try with this (in the "Préférences" menu (french version)):

  • How to print a Pdf from Java script

    Hi,
    I need to print a pdf from java script. In java script i have url of pdf. Is there any way to print pdf from java script?
    I am able to print word doc by ActiveX. is there any activeX or something else which do the same thing for pdf?
    Any help heartily esteemed to me.
    Thanks
    Kamlesh Sharma

    you are cross postin .. your thread has been answered in the jsp jstl forums

  • PDF/A-1b compliant PDF from InDesign exported PDF

    Hi folks.  I need to produce a pdf/a-1b compliant pdf from an InDesign document and it is giving me fits.  Because InDesign offers no native option to export pdf/a-1b compliant files, I have been exporting my document with the available presets (I've tried all of them), then running the pdf/a-1b conversion in Acrobat.  However, this conversion fails every time, usually on font subset and colour issues depending on how I set up the initial export from InDesign.  The only way I have managed to get a file to pass the conversion is to export from InDesign, save that pdf as images, rebuild the original pdf from the image files, then run the pdf/a-1b preflight from Acrobat.  Trouble is that this results in a serious loss of resolution that I can't have for my purposes.  Anyone have any ideas on how I can produce a pdf from InDesign that will pass the pdf/a-1b preflight in Acrobat?

    You have to do it in Acrobat Pro after PDF export.

  • Too long export to PDF from Indesign CS6

    When I exporting PDF from InDesign CS6 takes too long. For example, a few minutes (5minutes). In InDesign CS3, which I used earlier, the file is exported immediately (few seconds). It is a problem in setting or higher hardware requirements?
    I use laptop 2GB dual processor, 8GB RAM, Windows Vista 32 bit. You have a similar experience?

    It is strange that CS6 supports Windows XP and Windows7 and Vista does not support. I use 8GB RAM because I bought a laptop so. There for me any solution, how to enable CS6 InDesign with the 32 bit system Windows Vista?

  • Having trouble exporting to pdf from InDesign CS6

    When I attempt to export to pdf from InDesign CS6, the application crashes. Apparently there is some phantom plug-in issue.
    I need to get this resolved asap.
    Thank you,
    Marissa

    Have a look at this generic document to help you troubleshoot: http://helpx.adobe.com/indesign/kb/troubleshoot-printing-pdf-export-indesign.html
    Could you also provide details about what you've tried, and what errors you encountered? Is this problem limited to a particular document, or all documents?

  • I'm attempting to create a pdf from InDesign and the Illustrator image does not appear properly.

    I'm attempting to create a pdf from InDesign and the Illustrator logo does not appear properly. The logo has a light blue color background with a black to white gradiant over it with a multiply designation set at 100%.  I flattened the logo in illustrator before importing into InDesign. When the pdf is created, the blue background of the logo drops out and the only thing showing is the graduated screen of black. PLEASE HELP!!!!!!

    Thanks for your reply Peter,
    I'm on Mac OSX (10.5.8) using Acrobat 7 Professional and Acrobat 
    Reader 9 to view the pdf. I created it by exporting. Attached is a 
    screen capture of the letterhead. Since I posted, I sent a test pdf to 
    my partner's computer eventhough it didn't look right on my system and 
    she said it looked fine to her. I've restarted my computer and tried 
    again and still get the same results.
    Thanks for your help,
    Pat Boullion
    Boullion Graphics
    281 444-5749
    Fax: 281 444-6507
    CONFIDENTIALITY NOTICE
    The information in this email may be confidential and/or privileged. 
    This email is intended to be reviewed by only the individual or 
    organization named above.
    If you are not the intended recipient or an authorized representative 
    of the intended recipient, you are hereby notified that any review, 
    dissemination or copying of this email and its attachments, if any, or 
    the information contained herein is prohibited. If you have received 
    this email in error, please immediately notify the sender by return 
    email and delete this email from your system.

  • Making a interactive PDF from indesign, but it's too big. Tried to reduce file size in Acrobat, but

    Making a interactive PDF from indesign, but it's too big. Tried to reduce file size in Acrobat, but it does not reduce file size.

    Use the Optimize PDF command in Acrobat, it gives you more control. I think it's under the Advanced menu in Acrobat 9 Pro and File > Save As > Optimized PDF in Acrobat X Pro.
    You might try playing around with different settings. You can also click the Audit Space button at the upper right to see if its from images or other things causing the file size problem.
    Unfortunately, InDesign doesn't write interactivity in a very optimized way. You get better results with buttons, for example, creating them in Acrobat Pro and using the Duplicate command to duplicate them across multiple pages.

  • Export the pdf from indesign some error Pop Up window (Failed to Export the PDF file). How slove the

    Export the pdf from indesign some error Pop Up window (Failed to Export the PDF file). How slove the problem
    Please some one help on this

    You need to try exporting the first half of the book.
    If that exports ok then export the other half of the book.
    Whatever half it fails on - keep dividing the book in half to find the culprit page or pages.
    For example if your book is 128 pages long:
    1. Export pages 1 - 63
    2. If these Fail to Export then
    3. try exporting1-32
    4. If these Fail to Export
    5. then try exporting1-16
    If it doesn't fail (step 2)
    Then export pages 64-128
    and 64-90 etc.
    until you find the pages causing the issues.

  • Can't Choose Page Range when Exporting PDF from InDesign

    Hi!  Ever since I upgraded to CS6 via your subscription, I can't choose a page-range when exporting to PDF from InDesign (8.0.1).  Here's a video demonstration of the problem so you can see the bug in action:  http://screencast.com/t/kYR1ACtNi
    Are you aware of this bug?  If it's not a bug, how do I fix it?

    Alternate layouts are used for things like horizontal and vertical orientations of the same layout for use on tablets. I suspect there's some coverage in the Help files -- being a print guy I don't mess with them.
    It may be that you only have one layout and ID just shows you that one inthe dropdown. I can't recall that I ever used the dropdown to try to select the range -- I always just type what I need in the field.

  • Font issue in exported PDF from indesign

    Font issue in exported PDF from indesign:
    In Indesign file we have kept a sentence in “Univers LT Std” (San serif font) with all caps style that was orginally in lower case. Refer below
    When we selected the sentence in exported PDF some of the characters are not selected. Refer below.
    If we enable “create tagged PDF“ in export PDF setting, then the problem is solved. Refer below.
    Can you please check why this problem happened? In another project also we have faced this same problem but different font “Frutiger LT Std” with all caps style. Here also same San serif font. Please check and advise to solve this issue permanently.

    Without tags a PDF is a silly amount of letters, images and lines, with tags all itams a kept in their semantic context. So work with tags as it is the only way to get correct selections and export to other file types like Word DOCX.
    Without tags InDesign reads from left to right from top to bottom and the font geometry might influence the correct order of letters.
    Why should anyone work without tags today? If you open a tagged PDF in Acrobat DC it is much faster than without tags.

  • Anyone know how to export a PDF from InDesign so it is "click to go to next page" instead of "scroll to go to next page"?

    Anyone know how to export a PDF from InDesign so it is "click to go to next page" instead of "scroll to go to next page"?

    I don't use the latest InDesign, but in the past ID's options for exporting to PDF did not allow setting how a PDF should be viewed once exported.  However, these settings can be adjusted in Acrobat through Preferences: check out Page Layout and Zoom under Page Display.
    David

Maybe you are looking for

  • Sharing music across different accounts on the same PC

    Hi, I've got an iPod Classic with 12G of music, all from CD's. It is on iTunes on my account on my PC. I had a 8G iTouch for Xmas. I have opened another account on my PC and downloded iTunes. How can I transfer selected music from my original account

  • Error message when trying to connect to Itunes

    When I go to I-Tunes Store on my account I keep getting message.."I-Tunes Store is temorarily unavailble...please try again later...this has been going on for several days...what can I do to get into the I-Tunes Store from my account? This was an ear

  • Having problems trying to install ipod

    I keep running the install disk and it asks to connect the ipod to see if it needs to be formatted. I do this and it says that it is rebooting the ipod...then it says to press the format button again. It will do this a couple times then say that it i

  • Multiple button groups

    Hey everyone I am writing a program that contains 2 button groups(of radio buttons) and I am try to set a different value of Height for every height, and either the gender of male or female. But i can't get the getActionCommand to work with it. I don

  • Please help uploading new site

    How do i overwrite an old site? My old website got wiped out when i installed the new iweb..now i made a new one but it would not overwrite the old one..Please help!!