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

set the class of a paragraph style to export in HTML

$
0
0

How, in AppleScript, set the class of a paragraph style to export in HTML?

I try with "style export tag map", but doesn't works!

Thank's


Prompt before running script action?

$
0
0

I have a script which deletes unused character styles.

When they script is run, I want a dialog to pop up and ask the user if they wish to proceed... If yes, the rest of the script will run. If no, the script will stop.

I can't seem to find other instances of this. Any help would be appreciated. Thank you.

 

function removeUnusedCharStyle(myChStyle) {

app.findTextPreferences = NothingEnum.nothing;

app.changeTextPreferences = NothingEnum.nothing;

app.findTextPreferences.appliedCharacterStyle = myChStyle;

var myFoundStyles = myDoc.findText();

if (myFoundStyles == 0) {

myChStyle.remove();

}

app.findTextPreferences = NothingEnum.nothing;

app.changeTextPreferences = NothingEnum.nothing;

}

moving images and text to layers

$
0
0

I've managed to cobble together a script that moves all images and text to layers. I intend to create an if else statement that checks if layers exist, but my question is: is there any way to exclude the master pages from this?

Thanks,

~David

 

-----

pictureLayer = app.activeDocument.layers.item ("images");

textLayer= app.activeDocument.layers.item ("text layer");

app.activeDocument.rectangles.everyItem().itemLayer = pictureLayer;

app.activeDocument.textFrames.everyItem().itemLayer = textLayer;

Indesign Preferences

$
0
0

Hi,

 

I have used the below code to set Preview Options of InDesign Preferences (InDesign Preferences -> File Handling -> Saving InDesign Files).

 

app.generalPreferences.includePreview = true;   // Always Save Preview Images with Doc

app.generalPreferences.previewSize = PreviewSizeOptions.medium;    // Preview Size

app.generalPreferences.openRecentLength  = 10;       // Number of Recent Items to Display

app.generalPreferences.previewPages = PreviewPagesOptions.FIRST_2_PAGES;    // Prview pages

 

 

Its working fine for me in InDesign CS6 but Its throwing error in InDesign CS5.  When I searching in CS5 Reference, it does not have the property for "app.generalPreferences.previewPages".  But InDesign Preference having this property.  I want to run the script in both version(CS5 and CS6).  How can I make to run in both version?

 

Thanks,

Sudha K

yet another ask for help with javascript

$
0
0

Hello i have created the code below as i have a layout with 5 pages , i wanted to export each page as a new doc (keeping the existing page setup)

however what has happened is that it has created a new doc(layout) for each page

so the output if 5 new docs with the same 5 pages on as the orignal doc.

How can i adjust this so that each 5 new docs have just one page on thats different on each document

i tried chnaging  curDoc.save(saveFile); to  eachpage.save(saveFile);

but this did not work

thanks

 

var curDoc = app.activeDocument;

var myPages =  curDoc.pages; 

       for (i=0; i<myPages.length; i++){

           var eachpage = myPages[i];

var Name = curDoc.name.replace(/\.[^\.]+$/, '');

var saveFile= File("~/Desktop/guides/Test" + Name + ".indd")

 

   //app.activeDocument.save(saveFile);

   curDoc.save(saveFile);

 

   }

A script to delete all table rows containing a specific text

$
0
0

Hello,

 

I've tried some old scripts but can't get around to the right solution.

 

I need a script that will delete all rows in a table that contain a specific single-word text, something like "xxx".
Anyone's got an idea?

 

Thanks

Problem Linking HyperLink 3 Images on Same Cell Text Line. Need hero.

$
0
0

Hello Friends,

 

I need a hero, please. VB.NET, CS6. I am trying to add hyperlinks to 3 images. Here's the code (it's VB.NET but the logic should be easy to understand)

 

        If imageFileName IsNot Nothing Then

            Dim rect As ID.Rectangle = curTextItem.Rectangles.Add() : With rect

                .Name = imageFileName

                .GeometricBounds = geoBounds

                .Place(imageFileName)

                .ClearObjectStyleOverrides()    'needed to eliminate drop shadow

                .StrokeWeight = 0               'needed to eliminate stroke

                .Fit(idFitOptions.idProportionally)

                .Fit(idFitOptions.idFrameToContent)

                .Select()

            End With

            If imageLink IsNot Nothing Then

                Dim myHyperlinkURL = aDoc.HyperlinkURLDestinations.Add(imageLink)

                Dim myHyperlinkSource = aDoc.HyperlinkPageItemSources.Add(rect)            

                Dim myHyperlink = aDoc.Hyperlinks.Add(myHyperlinkSource, myHyperlinkURL)

                myHyperlink.Visible = False

            End If

        End If


FYI:  curTextItem is a cell.Text object.

 

When I add them without the hyperlinks, everything works fine (comment out red lines). However, when I try to add the first hyperlinkSource it errors with:

 

A first chance exception of type 'System.InvalidCastException' occurred in InDesign Scripting.exe

Additional information: Unable to cast COM object of type 'System.__ComObject' to interface type 'InDesign.PageItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D7D2C130-D321-11D1-AAA2-00C04FA349C7}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

I've tried just about every imaginable object reference to replace "rect" (except the "right" one) to make this work. If I choose to use "HyperlinkTextSources" instead of "HyperlinkPageItemSources" I can successfully link the first source by using  "aDoc.HyperlinkTextSources.Add(curTextItem.Texts.LastItem) but when it gets to the second source it errors with:

 

"The object you have chosen is already in use by another hyperlink."

 

I've been at this for about a day. If I were a smarter guy I might have given up a while ago, but I am stubborn. I know that I am missing something simple. You'll probably hear me smack my head from wherever you are when I get the answer. Please help.

 

Thank you kindly,

 

-TT

Overide all master page's text frame only

$
0
0

I have a document have 6 pages with 3 master page, A-master, B-master, C-master, A-master have 3 text frame, B-master is base on A-Master, and C-Master is base on B-Master

P1-2 (Apply A-Master), P3-4 (Apply B-Master), P5-6(Apply C-Master)

 

What I want to do is overrider the master page text Frame only, if my script is work, P1-6 will overrider the master text Frame, but it only overrider P1-2 text Frame, Please help to fix it! Many Thx

 

var myDocument = app.activeDocument; 
var TotalPages = (myDocument.pages.count()); 
for(var CurrentPage=0; CurrentPage < TotalPages; CurrentPage++) { 
     OverrideMasterItems(); 

function OverrideMasterItems() { 

var allItems = myDocument.pages[CurrentPage].appliedMaster.pages.item(1).textFrames.everyItem().getEleme nts(); 

  for(var i=0;i<allItems.length;i++){ 

try{

 

    allItems[i].override(myDocument.pages[CurrentPage])} 
catch(e){} 

  } 

  var allItems0 = myDocument.pages[CurrentPage].appliedMaster.pages.item(0).textFrames.everyItem().getEleme nts(); 

  for(var i=0;i<allItems0.length;i++){ 

try{

 

    allItems0[i].override(myDocument.pages[CurrentPage])} 
catch(e){} 

  } 

 

 

 

}


Indesign Javascript

$
0
0

I want to learn javascript please any sample

JavaScript script: How to add a DSP Interactive WebView to a page?

$
0
0

Hi forums experts,

 

I'm working on a project where we want to automate the insertion in a indesign (*.indd) of a DSP WebView using a JavaScript (*.jsx) script.

 

I did an extensive research of the JavaScript API but i could NOT find any reference of the "DSP", "WebView".

 

Is this possible?

 

Is there a hidden API located somewhere?

 

What is an alternative? IDML?

 

Any help would be extremely appreciated.

 

Regards

correct my MeasurementUnits by script

$
0
0

My Indesign file preference properties in inches ('myDocument.viewPreferences.horizontalMeasurementUnits=MeasurementUnits.INCHES;') But I am using point size measurement units for above space adjustment script as like below:

 

 

if(arrExtraStyles.length!=0)

                      {

                          adjustExtraSpace(4);

                          }

 

Here I have mentioned 4 points here. I try to assign default this is in point size value as like below but it doesn't work.

 

ProcessTracking=[4];

ProcessTracking.pointSize = 4;

ProcessTracking="0p4";

 

If my indesign files measurement units in inches, my above process 'adjustExtraSpace' value taking in inches, that means 4 inches, but I have mentioned here 4 points only. how to control it?

 

by

hasvi

Resizing column width of multiple selected stories with tables

$
0
0

I've found this wonderful script that fits the width of all tables to the width of their text frames

It's brilliant because we have multiple layers, each layer containing tables in their own language. So the script helps a lot.

There's only one thing I'd like to change:

In this case, the script runs through the entire document. I'd like to change that to only the frame we select (to maximize control and avoid mistakes).

 

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

 

var myDocument=app.activeDocument;

 

for (s=0; s<myDocument.stories.length; s++) {

 

        for (t=0; t<myDocument.stories[s].tables.length; t++) {

  

            var myTable = myDocument.stories.item(s).tables.item(t);

            var myTableParent = myTable.parent;

            var parentWidth = myTableParent.geometricBounds[3] - myTable.parent.geometricBounds[1];

            var factor = parentWidth/myTable.width;

            for (col=0; col<myTable.columns.length; col++) {

                myTable.columns[col].width *= factor;

                }

        }

}

Find content after last tab using GREP

$
0
0

Hi All,

 

Is it possible to find the contents after last tab using GREP?????

 

Please refer the screenshot below:

 

In screenshot, I highlight the requested text.

 

Screen Shot 2014-05-27 at 5.11.29 PM.png

 

Thanks in advance

Siraj

Making a script for Excel files import

$
0
0

HI!

I'm new in scripting. I tryied to make a script, that import every row as table.

But have a problems right from the start...))))

 

I wrote code for Excel file import preferences and for import and place dialog (see below), but I dont understand, how I link a code with import preferences to imported file... How can I do that?

 

-----------

 

function setExcelPrefs () {

   with(app.excelImportPreferences) {

       aligmentStyle = AlignmentStyleOptions.spreadsheet;

       decimalPlaces = 4;

       preserveGraphics = false;

       rangeName = "A1:D1";

       sheetIndex = 1;

       showHiddenCells = false;

   }

}

 

var myDocument = app.documents.item(0);

 

var textFrame = myDocument.pages.item(0).textFrames.add();

myTextFrame.geometricBounds=["6p","6p","24p","50p"];

var myExcelFile = File.openDialog("Choose an Excel file");

myTextFrame.place(myExcelFile);

Please help me to correct my script!

$
0
0

Please help me to correct my script

 

I use this script which copy from the adobe forum:

 

app.findGrepPreferences.findWhat = "\\r";

app.changeGrepPreferences.changeTo = "\\r\\r";

app.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

 

to change my return one to two, but it will always change all my document,

How can I tell the script I only want to change the slection?


need script for apply paragraph style

$
0
0

Hi,

 

I want to apply the "next paragraph style" to previous paragraph".

For instrance:

 

line 1: H1 style

line 2: H2 style

line 3: H3 style.

 

 

Now I want to apply 'line 3' style to 'line 2'. Is this possible by script?

 

by

hasvi

Remove extra enter mark by script

$
0
0

Hi,

 

I need to remove extra enter mark in my Indesign file, at the same time it should not be affect the above and below styles.

by

hasvi

SetTextProperties

$
0
0

Does anyone know where to find the tutorial and complete "SetTextProperties tutorial script"?

In the InDesign scripting guides javascript I stuck on the text: "The SetTextProperties tutorial script shows how to set every property of a text object. This fragment illustrates how to change the appearance of text by setting various properties."

Searching the internet does not solve my problem.

Positioning an object placed from library using JS

$
0
0

I'm placing an object from a library and I'd like to move it to specified coordinates but this third line does not do the job. The error is: "assetProf.resolve is not a function"

What am I missing here?

 

var lib = app.libraries[0];

var assetProf = lib.assets.itemByName( "test" ).placeAsset( app.activeDocument );

assetProf.resolve( [[100, 100], AnchorPoint.TOP_RIGHT_ANCHOR], CoordinateSpaces.parentCoordinates, true);

Please help me to correct the script

$
0
0

I try to write a script by my slef, but not work

 

app.findGrepPreferencest = firstLineIndent:8, leftIndent:8;

app.changeGrepPreferences = firstLineIndent:8, leftIndent:16;

app.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

 

Can someone please help me to correct the script, please.

Viewing all 8771 articles
Browse latest View live


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