Quantcast
Channel: Adobe Community : All Content - InDesign Scripting
Viewing all 8771 articles
Browse latest View live

JavaScript error - Object is invalid

$
0
0

Problem (while using Indesign CS6 on Mac OS X):

  • After updating to El Capitan and installing the, now necessary, legacy Java SE 6
    • there's a JavaScript error;
    • Indesign files won't open;
    • Indesign won't "Quit" without force quitting.
  • The following error message appears:

JavaScript Error!

 

Error Number: 54

Error String: Uncaught JavaScript exception:

ReferenceError: Object is invalid

 

Engine: ConvertURLToHyperlinks

File: /Applications/Adobe InDesign CS6/Scripts/converturltohyperlink/startup scripts/ConvertURLtoHyperlinkMenuItemLoader.jsx

Line: 100

Source: Folder.current = cacheCurrent ;

 

I assume that if I knew even the basics of JavaScript for Indesign, I'd be able to solve this, but I don't, so any information would be great, thanks.


Remove "empty" linked text frames at the end of documents

$
0
0

Hi all,

 

I want to write a script to clean up the "empty" text frames and pages at the end of the document,

these text frames and pages are there because I have formatted the table and text correctly after I placing a word doc, and content shrink dramatically.

I know technically these "empty" text frames are not empty because they are linked to the part with tables and text in previous text frames, so I cannot use the delete empty frames script...

Cant access Indesign with Excel VBA

$
0
0

I cant set indesign as an object. here is my code:

 

Sub newbook()

Dim InDapp As New InDesign.Application

Set InDapp = CreateObject("InDesign.Application")

End Sub

 

I have tried adding a version number to the create object(.CC.2015, CC2015) and i have tried renaming the reference resource as recommended by Trevor. I have look all over the internet and look in the guide.

If anyone can help me getting start here i would really apprieciate it.

Thanks.

Dane

How can i Remove Returns from a Certain Paragraph Style?

$
0
0

I have a paragraph style (SafetyDATA) set and i all i need is to remove all the return from it.  How can i do this? 

 

Thank you .. for any help

Accessibility Script

$
0
0

Hello,

 

I'm wondering if it would be possible to make a script which changes an objects export option to "artefact".

 

If there is also a script which shows all image alt text that would also be perfect.

 

Any help would be great!

 

Thanks

[Help] Looking for a script that can batch change font size & type Cs 6

$
0
0

I know this question might've been answer through the forums, but i'm having a hard time looking for the answer. Im working with a document with 200+ pages and would like to find a script that can do a batch change font size & type! This would help me so much with time and instead of going through each document! Thanks! I appreciate it! S6

Pages added by scripting create new spread, why?

$
0
0

Hello,

       I'm working on a method that will add a page, add some content to that page, then repeat.  Sometimes, depending on how I arrange my code, the new pages are added within the current spread, sometimes adding a new page automatically creates a new spread.  How do I control this?

 

From my testing thus far, having

var mySpread = MyDocument.spreads.add();

before

myPage = mySpread.pages.add();

But if I don't add a new spread before adding a page it seems to create the new page within the current spread.

 

It seems like there should be some way to control what spread pages are added to, and whether or not adding a page automatically creates a new spread?  Thanks for any help.

 

 

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

$
0
0

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();

Indesign Scripting - Increase frame sizes by 1 mm

$
0
0

Hi there,

I am still new to indesign scripting and have struggled to come up with an answer.

 

I have a page of empty rectangle frames, all different sizes.

 

Is there a way i could select all the frames, run an "increase size" script through a keyboard shortcut, and all the boxes will increase by 2mm X+Y from the centre of the frame.

 

Example - Frame W: 63mm Frame H: 87.3mm

 

<Run Script - Width=Width+2mm, Height=Height+2mm>

<Result>

Frame W: 65mm Frame H: 89.3mm (from centre)

<Next Frame>

<Repeat>

 

I'd really appreciate any help i can get on this issue

 

Thankyou !

Avoid "reading" images

$
0
0

I have a script that inserts images throughout a document and applies an object style to them. I've found that once the script is done, it takes time to visit any page in the document that has these images. I see a little blue bar appear at the bottom of the ID window that says "Reading [image name]". It will read each image on the spread before it takes me there. Once the images on a particular spread have been read, I can revisit that spread with no lag. Also, if I don't visit any pages but save the document and reopen it (or save a copy and open it) I can visit any page normally, with no lag. Obviously ID needs to do some sort of one-time scan of the images I've placed, but I'd much prefer to handle this as part of the script and not inconvenience users with it. Since it happens automatically on save, I wonder if there's some way to mimic it in a script without saving the document? From what I can tell, this only happens when an object style is applied to images.

 

I've tried recomposing the story after placing each image, but it has no effect on this issue. Any thoughts on an approach that might work here?

Link moves to done folder after placing into InDesign

$
0
0

 

Hello all,

 

I have working daily on a Magazine it's contains so many images (more than 50); to place images into artwork I am using Mini Bridge, while placing images some of the images are repeating in some pages. To avoid this problem I have created done folder when image place into InDesign script can move that image into done folder and re-link from done folder, if I deleted from InDesign it's moves to normal images folder... Is it possible? Please help me to avid the repeating images in magazine.

 

I am using InDesing CS6 in windows7

 

Thanks in advance

Document SaveAs leads to missing assignment

$
0
0

The Problem - Document SaveAs leads to assignment file missing status

Assume that your InDesign document has an assignment (ICMA file).

If you SaveAs your document to a new location, then the new document will have the assignment file missing.

The assignment file location refers to old location and the file name changes to originalname-X.icma (where X is 1, 2, 3, etc.)

 

Fixing Manually:

Assignments panel in InDesign provide you a way wherein you can specify new location for assignment.

The Change Assignment Location options does the trick.

 

Scripting Solution?

To my knowledge, there is no way in the scripting DOM to address this issue.

What other good options are available in the Scripting DOM to address this.

It is desired to move the assignment file to new location retaining same name of the file.

Untag only Parent element

$
0
0

I need to the parent element and prevent the child element. Is this possible via script?

Multipageimporter2.5-cs5.jsx wont work after indesign 8.1 update?

$
0
0

Need help

this script wont work after 8.1 update. anyone can repair this very good script?

throw error 11268

How to quickly change cell stroke weight

$
0
0

Hi there,

 

I'm actually working on souscription forms based on tabs. At the moment, the strokes are 1pt weight around each label and content to be added cells. I'm looking for a quick way to set them at 0.5pt.

 

I've tried the script presented at this address : Script to find/change stroke in tables , but when I launch it returns an error 30614 (incorrect object)

 

tell application "Adobe InDesign CC 2015"   set currWeight to 1   set newWeight to 0.5   set mytablelist to every cell of every table of every text frame of active document   repeat with x from 1 to (count items of mytablelist)   set myCell to item x of mytablelist   if the bottom edge stroke weight of myCell is currWeight then   set bottom edge stroke weight of myCell to newWeight   end if   if the diagonal line stroke weight of myCell is currWeight then   set diagonal line stroke weight of myCell to newWeight   end if   if the left edge stroke weight of myCell is currWeight then   set left edge stroke weight of myCell to newWeight   end if   if the right edge stroke weight of myCell is currWeight then   set right edge stroke weight of myCell to newWeight   end if   if the top edge stroke weight of myCell is currWeight then   set top edge stroke weight of myCell to newWeight   end if   end repeat end tell

 

I have the same answer (error 30614).

 

I don't have any idea of what happened.

 

Is there someone nice enough to help resolve this problem?

 

Kind regards,

 

 

Guillaume


Create an UI for a script! …

$
0
0

Hi all,

 

I think I had to split this topic part!

[ see:  How to quickly change cell stroke weight  ]

 

Here's 2 variants of a tool thought by Uwe Laubender, Skemicle and your servant!

 

This 1rst script allows the op to change to 0.5 pt the cell stroke weights in all the tables in a document if they are not equal to zero.

 

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;     
app.doScript         (         main,         ScriptLanguage.JAVASCRIPT,         [],         UndoModes.ENTIRE_SCRIPT,         "Change Tables Stroke Weights!"         );      
function main()     
{         var newWeight = 0.5;         if(app.documents.length == 0){return};     if(app.documents[0].stories.length == 0){return};     if(app.documents[0].stories.everyItem().tables.length == 0){return};            var doc = app.documents[0];         var allStories = doc.stories.everyItem();         var allCells = allStories.tables.everyItem().cells.everyItem().getElements();              for(var n=0;n<allCells.length;n++)             {                 if(allCells[n].topEdgeStrokeWeight != 0){                  if(allCells[n].topEdgeStrokeWeight != newWeight){                        allCells[n].topEdgeStrokeWeight = newWeight                   }               }         };          for(var n=0;n<allCells.length;n++)             {                 if(allCells[n].bottomEdgeStrokeWeight != 0){                  if(allCells[n].bottomEdgeStrokeWeight != newWeight){                        allCells[n].bottomEdgeStrokeWeight = newWeight                   }               }         };          for(var n=0;n<allCells.length;n++)             {                 if(allCells[n].leftEdgeStrokeWeight != 0){                  if(allCells[n].leftEdgeStrokeWeight != newWeight){                        allCells[n].leftEdgeStrokeWeight = newWeight                   }               }         };          for(var n=0;n<allCells.length;n++)             {                 if(allCells[n].rightEdgeStrokeWeight != 0){                  if(allCells[n].rightEdgeStrokeWeight != newWeight){                        allCells[n].rightEdgeStrokeWeight = newWeight                   }               }         };            
};    

 

 

This second script allows the op to choose what cell stroke weights in all the tables in a document he wants to change (to 0.5 pt):

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;     
app.doScript         (                 main,         ScriptLanguage.JAVASCRIPT,         [],         UndoModes.ENTIRE_SCRIPT,         "Change Stroke Weight"                 );          
function main()     
{            
var weight = Number(prompt("What is your starting weight?", 1,"Current Stroke Weight"));   
var newWeight = 0.5;          
if(app.documents.length == 0){return};     
if(app.documents[0].stories.length == 0){return};     
if(app.documents[0].stories.everyItem().tables.length == 0){return};            
var doc = app.documents[0];     
var allStories = doc.stories.everyItem();     
var allCells = allStories.tables.everyItem().cells.everyItem().getElements();                  
for(var n=0;n<allCells.length;n++)     
{         if(allCells[n].bottomEdgeStrokeWeight != weight){continue};         allCells[n].bottomEdgeStrokeWeight = newWeight;     
};                
for(var n=0;n<allCells.length;n++)     
{         if(allCells[n].leftEdgeStrokeWeight != weight){continue};         allCells[n].leftEdgeStrokeWeight = newWeight;     
};            
for(var n=0;n<allCells.length;n++)     
{         if(allCells[n].rightEdgeStrokeWeight != weight){continue};         allCells[n].rightEdgeStrokeWeight = newWeight;     
};            
for(var n=0;n<allCells.length;n++)     
{         if(allCells[n].topEdgeStrokeWeight != weight){continue};         allCells[n].topEdgeStrokeWeight = newWeight;     
};      
};    

 

I think it would be cooler to have this UI and this game:

 

• type * if the op wants to treat all the strokes (except 0);

• type a number if he wants to treat a specific stroke weight.

 

 

Capture d’écran 2016-08-17 à 16.49.54.png

 

I get this UI like this:

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;   
app.doScript       (       main,       ScriptLanguage.JAVASCRIPT,       [],       UndoModes.ENTIRE_SCRIPT,       "Change Tables Stroke Weights!"       );   


// Here's the UI


var w = new Window ('dialog {alignChildren: "right"}', 'Change Tables Stroke Weights!');
  var group1 = w.add ('group');  group1.add ('statictext {text: "Cells stroke to be replaced:"}');  var UIWeight = group1.add ("edittext", undefined, 1);   UIWeight.minimumSize.width = 50;    UIWeight.maximumSize.width = 50;  UIWeight.active = true;  var group2 = w.add ('group');  group2.add ('statictext {text: "… by:"}');  var UINewWeight = group2.add ("edittext", undefined, 0.5);   UINewWeight.minimumSize.width = 50;  UINewWeight.maximumSize.width = 50;  var buttons = w.add ('group {alignment: "center"}');  buttons.add ('button {text: "OK"}');  buttons.add ('button {text: "Cancel"}');


if (w.show() == 2) {  // Cancel pressed  exit();
}


// Now the script:


function main()   
{   

 

 

… But, at this step, I'm totally unable to continue! …

 

Thanks for all your help and your nice advices to not to sink in the dark side of The Force! 

 

MTFBWY!

Indesign to Photoshop

$
0
0

Hi All,

 

Created script for Indesign to JPEG.

 

But the below request is possible???

 

1. Create individual Photoshop(.psd) from each Indesign(.indd) page

2. Each object or text area in InDesign should be its own layer in Photoshop

3. Text areas should be editable, in tact, and not broken and disjointed

 

Please share your thoughts.

 

 

Thanks in Advance

Siraj

GREP space plus dot using extendscript

$
0
0

Hi,

 

I try to remove all spaces before a dot using a GREP formula.

 

GREP of "\s+\." works fine in the InDesign user interface but as soon as I try to make it work as a script, it no more works and the result is a replacement of all spaces by a space plus a dot !

 

My script works for different other grep changes.

It looks like :

 

app.changeGrepPreferences = NothingEnum.nothing;

    app.findGrepPreferences = NothingEnum.nothing;

  

    app.findChangeGrepOptions.includeFootnotes = true;

    app.findChangeGrepOptions.includeHiddenLayers = false;

    app.findChangeGrepOptions.includeLockedLayersForFind = false;

    app.findChangeGrepOptions.includeLockedStoriesForFind = true;

    app.findChangeGrepOptions.includeMasterPages = false;

  

        app.findGrepPreferences.findWhat = "\s+\.";

        app.changeGrepPreferences.changeTo = "\.";

        app.activeDocument.changeGrep();

 

Any idea on how to make that works ?

 

Pierre

IDML BackingStory ---- Issue

$
0
0

When I move the floats the while doing the auto-pagination. The below line created in the BackingStory.xml in the IDML file

 

<XMLElement Self="di3i4" MarkupTag="XMLTag/chapter" XMLContent="u267" />

 

 

While exporting the file as a idml file the above line corrupt the indesign file. I need to remove the line from the structure.

 

Also how avoid the duplicate XML structure form the idml file.

 

Is this possible via scripting. Please confirm.

Paragraph style, first line bold

$
0
0

Hi all,

I am trying to give a column in a table a paragraphstyle in which the first line is bold and the rest of the cell isn't, like this:

 

---------------------------------------------------------------------------------

Column 2 cell 3

Company name
Adress

Adress

 

Column 2 cell 4

Company name
Adress

Adress

---------------------------------------------------------------------------------

 

I don't know if this is even possible but it would be a great help.

 

I do apply the paragraph like this to the second column:

---------------------------------------------------------------------------------

myTable.columns[1].cells.everyItem().texts[0].applyParagraphStyle(contentText);

---------------------------------------------------------------------------------

 

The following is the contentText paragraph:

---------------------------------------------------------------------------------

var contentText = myDocument.paragraphStyles.item("contentText");

    try

        {

            var contentTextName = contentText.name;

        }

    catch (myError)

        {

            contentText = myDocument.paragraphStyles.add({name:"contentText"});

        }

 

contentText.appliedFont = "Arial";

contentText.fontStyle = "Regular";

contentText.pointSize = 10;

contentText.spaceAfter = 10;

contentText.spaceBefore = 10;

contentText.fillColor = myDocument.colors.item("Black");

---------------------------------------------------------------------------------

 

Is there a way to only let the first line be bold?

 

Thanks in advance,

 

Greetings

Viewing all 8771 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>