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

Pls correct my script for script label creation

$
0
0

Hi,

 

I want to add the script label name in Masterpages only which was in 'Text thread' options. Is this possible by script?

This is my code

 

 

var myTextFrame=app.selection[0];
myTextFrame.label="textpage";
var myNextFrame=myTextFrame.nextTextFrame;
while(myNextFrame !=null)
{    myNextFrame.label="textpage";    myNextFrame=myNextFrame.nextTextFrame;   
}


Instead of first line I want to create this script label "textpage" for master page 'text thread' text frame only

Instead of first line I want to create this script label "textpage" for master page 'text thread' text frame only. How to change my script pls help me?

 

FYI:

1.png

by

hasvi


Customizing imported excel table with a script

$
0
0

Hi Guys,

 

I am new to the InDesign scripting and I am trying to develop a script for one of the documents I am working on.
I want to customize an imported excel table or spreadsheet with a script that changes the table automatically with the required styling and alignment as required.

Can someone please help me solve this problem?
It will help save a lot and lot of time.

Please help.

 

Thanks.

 

Nitesh

Script has issues with merged cells in tables

$
0
0

Brand new to javascript so apologies in advance for the sloppy methodology. I'm going through a huge document trying to streamline the styles, and ran into a wall when it comes to the tables. In order to clear the stroke/fill formatting from specific tables (only defined by their internal paragraph styles) and apply my own, I need to override the current settings with a cell style. This is made more difficult by the fact that there's no standard number of rows or columns for the tables. I managed to cobble together something close to what I need, as given here:

 

if ((table.rows.length>0) && (table.rows[1].cells[0].texts[0].appliedParagraphStyle.name === "CATALOGID"))  {       for (i=0; i<table.rows.length; i++)       {            if (table.rows[i].cells[0].texts[0].appliedParagraphStyle.name === "Categories")            {                 for (v=0; v<table.columns.length; v++)                 {                          table.rows[i].cells[v].appliedCellStyle = "Header";                 table.rows[i].cells[v].clearCellStyleOverrides(true);                 }            }            else if (table.rows[i].cells[0].texts[0].appliedParagraphStyle.name === "CATALOGID")                 {                 table.rows[i].cells[0].appliedCellStyle = "Catalog ID";                 table.rows[i].cells[0].clearCellStyleOverrides(true);                 for (j=1; j<table.rows[i].cells.length; j++)                      {                             table.rows[i].cells[j].appliedCellStyle = "Table Body";                      table.rows[i].cells[j].clearCellStyleOverrides(true);                      }                 }            else {}         }  }
else{}

 

It works fine up until it hits a merged cell, at which point it quits and won't go any further in the document. I'm guessing it's because of some issue in counting cell/column numbers consistently. I've tried a few workarounds by checking the rowSpan property but they just end up breaking the script worse. If someone could point me in the right direction for getting this thing working, even if it just ignores merged cells/any tables with merged cells, that'd be great.

KT list with Page number

$
0
0

Hi,

I want generate report of KT Character Style with Page numbers. But it showing some error, please anyone help me for this.

Picture 5.png

 

Thanks in advance,

Brave heart

Table text frame width adjustment by script

$
0
0

Hi,


I have to capture my table cells within ‘Text Frame Width’ option with ‘Distribute Column Evenly’ , when it’s going to beyond the ‘Text Frame Width’. Is this possible by script?


by

hasvi

Cannot get the paragraphs contents in findGrep result

$
0
0

I want to get which paragraph was applied "01H" this style, since I use findgrep cannot get any result of contents

anyone have any idea to help me?

 

var myEnd =app.selection[0].paragraphs[0];

var myStart = app.selection[0].parent.paragraphs[0];

app.findGrepPreferences = NothingEnum.NOTHING ;

app.changeGrepPreferences = NothingEnum.NOTHING ;

app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Eng").paragraphStyles.item("01H");

app.findGrepPreferences.findWhat = "^.+$\r";

myRange = app.selection[0].paragraphs.itemByRange(myStart, myEnd);

var myFindGrep = myRange.findGrep()

alert (myFindGrep.contents)

 

Thx a lot

Para style name creation by script

$
0
0

Hi,


I have to create the empty “Paragraph Styles” name as per our neediness. For instance I am going to declare my para style news in New Array (“BX”, “BK”, “HL”, “LD” ). Now the empty paragraph style have to create within declared name. Is this possible by script?


by

hasvi

Error Number & Error String

$
0
0

Hi


I have clarified some doubts. Please see the screen shot below.


Untitled.png


What is mean by Error No: 30477, Error No: 45, Error No: 21., etc.,

 

Please explain "Error Number"" and "Error String" topic.




Regards

ASHRAM


Is there a version of the script "batch_convert.jsxbin" to Ind. CS6?

$
0
0

Is therea version of thescript "batch_convert.jsxbin" toInd.CS6?

 

Thanks...!!!

Find URL Using GREP

$
0
0

Hi All,

 

Request:

I need to find URL end with '.com', '.org', '.uk' etc by using GREP.

 

i.e.,

 

abcde@duval.com

zeoue@rediff.uk

rajjjesz.sir555@gmail.corp.fr

(zzzz@yahoo.com)


Please help for the above request ASAP.


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

But, I got the solution for the content start with 'http' or 'www'

 

Using Forum Grep Code is: (?i)(http|www)\S+[\l\u|\d]

 

 

Regards

Siraj



Script for shrinking overset text?

$
0
0

I use data merge to create labels for guests attending functions. Usually this is around 500-1000 labels at one time. I usually set my text frame on the template page for a large point and then shrink it horizontally (I do this to minimize the number of pages I have to manually edit for overset text). I still get some names where they are long hyphenated names that create overset text.

 

Is there a script available where it will recognize there is overset text and then shrink the text down either by decreasing the point size or adjusting the horizontal spread of the text (maybe making it 100% to 80%)?

Indesign Applescript Placed Object Layer Visibilty Override

$
0
0

Hi, trying to programmatically control layer visibility of placed objects (either AI or other ID files) in a multi-page Indesign document.  Have looked all over the dictionary but can't seem to figure a way to reference the layers.

 

Would someone have an example of how to do this in Applescript?  (Please, not javascript, will convert one day but for now am staying with AS.)

 

Thanks!

hyperlink to button CS6

$
0
0

Hello is use this script in Indesign CS5 and it works. Now i have CS6 and it's not working anymore.

It makes the yellow bar but the hyperlink is empty.

 

Does somebody know to fix this?

 

Kind regards,

Patrick

 

 

/* Copyright 2014, Kasyan Servetsky

February 3, 2014

Written by Kasyan Servetsky

http://www.kasyan.ho.com.ua

e-mail: askoldich@yahoo.com */ 

//====================================================================================== 

var scriptName = "Convert hyperlinks to buttons - 2.0", 

doc; 

 

Main(); 

 

//===================================== FUNCTIONS  ====================================== 

function Main() { 

    var hyperlink, source, sourceText, destination, page, arr, outlinedText, gb, button, behavior, sourcePageItem, 

    barodeCount = 0, 

    hypCount = 0; 

    if (app.documents.length == 0) ErrorExit("Please open a document and try again.", true); 

    var startTime = new Date(); 

     

    doc = app.activeDocument; 

    var layer = MakeLayer("Buttons"); 

    var swatch = MakeColor("RGB Yellow", ColorSpace.RGB, ColorModel.process, [255, 255, 0]); 

    var hyperlinks = doc.hyperlinks; 

     

    var progressWin = new Window ("window", scriptName); 

    progressBar = progressWin.add ("progressbar", undefined, 0, undefined); 

    progressBar.preferredSize.width = 450; 

    progressTxt = progressWin.add("statictext", undefined,  "Starting processing hyperlinks"); 

    progressTxt.preferredSize.width = 400; 

    progressTxt.preferredSize.height = 30; 

    progressTxt.alignment = "left"; 

    progressBar.maxvalue = hyperlinks.length; 

    progressWin.show(); 

     

    for (var i = hyperlinks.length-1; i >= 0; i--) { 

        hyperlink = hyperlinks[i]; 

        source = hyperlink.source; 

        destination = hyperlink.destination; 

         

        if (source.constructor.name == "HyperlinkTextSource") { 

            sourceText = source.sourceText; 

            page = sourceText.parentTextFrames[0].parentPage; 

            arr = sourceText.createOutlines(false); 

            outlinedText = arr[0]; 

            gb = outlinedText.geometricBounds; 

            outlinedText.remove();             

        } 

        else if (source.constructor.name == "HyperlinkPageItemSource") { 

            sourcePageItem = source.sourcePageItem; 

            gb = sourcePageItem.geometricBounds; 

            page = sourcePageItem.parentPage; 

        } 

         

        barodeCount++; 

        progressBar.value = barodeCount; 

        progressTxt.text = "Processing hyperlink " + hyperlink.name + " (Page - " + page.name + ")"; 

         

        if (source.constructor.name == "HyperlinkTextSource" || source.constructor.name == "HyperlinkPageItemSource") { 

            button = page.buttons.add(layer, {geometricBounds: gb, name: hyperlink.name}); 

            button.fillColor = swatch; 

            button.fillTint = 50; 

            button.groups[0].transparencySettings.blendingSettings.blendMode = BlendMode.MULTIPLY;     

            behavior = button.gotoURLBehaviors.add(); 

            behavior.url = destination.destinationURL; 

             

            hyperlink.remove(); 

            source.remove(); 

             

            hypCount++; 

        } 

    } 

     

    var endTime = new Date(); 

    var duration = GetDuration(startTime, endTime); 

    progressWin.close(); 

 

    alert("Finished. " + hypCount + " hyperlinks were convertted to buttons.\n(time elapsed: " + duration + ")", scriptName); 

 

//---------------------------------------------------------------------------------------- ---------------------------------------------------------------- 

function GetDuration(startTime, endTime) { 

    var str; 

    var duration = (endTime - startTime)/1000; 

    duration = Math.round(duration); 

    if (duration >= 60) { 

        var minutes = Math.floor(duration/60); 

        var seconds = duration - (minutes * 60); 

        str = minutes + ((minutes != 1) ? " minutes, " :  " minute, ") + seconds + ((seconds != 1) ? " seconds" : " second"); 

        if (minutes >= 60) { 

            var hours = Math.floor(minutes/60); 

            minutes = minutes - (hours * 60); 

            str = hours + ((hours != 1) ? " hours, " : " hour, ") + minutes + ((minutes != 1) ? " minutes, " :  " minute, ") + seconds + ((seconds != 1) ? " seconds" : " second"); 

        } 

    } 

    else { 

        str = duration + ((duration != 1) ? " seconds" : " second"); 

    } 

 

    return str; 

//---------------------------------------------------------------------------------------- ---------------------------------------------------------------- 

function MakeLayer(name, layerColor) { 

    var layer = doc.layers.item(name); 

    if (!layer.isValid) { 

        layer = doc.layers.add({name: name}); 

        if (layerColor != undefined) layer.layerColor = layerColor; 

    } 

    return layer; 

//---------------------------------------------------------------------------------------- ---------------------------------------------------------------- 

function MakeColor(colorName, colorSpace, colorModel, colorValue) { 

    var doc = app.activeDocument; 

    var color = doc.colors.item(colorName); 

    if (!color.isValid) { 

        color = doc.colors.add({name: colorName, space: colorSpace, model: colorModel, colorValue: colorValue}); 

    } 

    return color; 

//---------------------------------------------------------------------------------------- ---------------------------------------------------------------- 

function ErrorExit(error, icon) { 

    alert(error, scriptName, icon); 

    exit(); 

//---------------------------------------------------------------------------------------- ----------------------------------------------------------------

deleting unused paragraph styles and swatches ID CS2

$
0
0
Hi, I posted this on Macscripter's great AS forum, but unfortunately haven't had a solution, The problem is that the script deletes all unused paragraph styles as it should, but it also deletes styles upon which others are based, therefore trashing the document. If I have a body text style, then make a new style based on it, if body text isn't used, it gets deleted and the new style gets set to the default (losing formatting, etc). Oddly, when I delete unused styles from the paragraph styles palette ID seems to be able to 'factor in' this 'based on' issue. Anyway, here's my script:

tell application "Finder"
set file_list to selection

repeat with process_item in file_list
set the_alias to alias ((file_list as string) & (process_item))
tell application "Adobe InDesign CS2"
activate
open the_alias
set theDoc to active document
tell theDoc
set myParagraphStyles to every paragraph style of theDoc
set theCount to count of myParagraphStyles
repeat with n from (count myParagraphStyles) to 2 by -1
set myCurrentStyle to item n of myParagraphStyles
my RemoveUnusedStyle(myCurrentStyle)
end repeat
end tell
end tell
end repeat
end tell
on RemoveUnusedStyle(myStyle)
tell application "Adobe InDesign CS2"
set find preferences to nothing
set change preferences to nothing
set theDoc to active document
search theDoc with find attributes {applied paragraph style:myStyle}
tell active document
set myFoundStyles to search theDoc with find attributes {find text:""}
if (count myFoundStyles) = 0 then
try
delete myStyle
end try
end if
end tell
end tell
end RemoveUnusedStyle

tell application "Adobe InDesign CS2"
try
repeat
tell front document
set theUnusedSwatches to unused swatches
repeat with UnusedSwatch from 1 to count of theUnusedSwatches
if name of (item UnusedSwatch of theUnusedSwatches) is not "" then
try
delete (item UnusedSwatch of theUnusedSwatches)
end try
end if
end repeat
end tell
close front document saving (yes)
end repeat
end try
end tell

Hope you can geve me a pointer.

Cheers,

Kev.

ExportPDF single pages with heading text (content) in file name

$
0
0

Hi all,

 

 

I found PEU5 for export as single pages it works fantastic!, now how can i call the heading content as file name in exporting Pdf

 

any help please...


Copy content from table cell of one document in InDesign to text frame of a different document in InDesign

$
0
0

var newdoc;                                      //Creates a new document that will have a text frame

newdoc = app.documents.add(false);

with (newdoc.documentPreferences) {

    pageHeight = "825pt";

    pageWidth = "637pt";

    pageOrientation = PageOrientation.PORTRAIT;

    pagesPerDocument = 1;

    //setting bleed properties for the document

    documentBleedUniformSize = true;

    documentBleedTopOffset = "9pt";

    //setting slug properties for the document

    documentSlugUniformSize = true;

    slugTopOffset = "0pt";

}

 

var doc = app.activeDocument,          // Opens current or active document which has a table

    _tables = doc.stories.everyItem().textStyleRanges.everyItem().getElements(),     

    i, j, k, l, a, _rows, _cells, rowlen, tempVar, page;

 

page = newdoc.pages.items[0];

 

var TextFrame = page.textFrames.add();           //Creates TextFrame

TextFrame.geometricBounds = myGetBounds(doc, page);

 

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

    for (j = 0; j < _tables[i].tables.length; j++) {

        _rows = _tables[i].tables[j].rows;

        for (k = 0; k < _rows.length; k++) {

            _cells = _rows[k].cells;

            for (l = 0; l < _cells.length; l++) {

               

                tempVar = _cells[0].contents;          //Copy contents from table cell to a temporary variable

                TextFrame.contents = tempVar;        //write it into text frame.

 

 

            }

        }

    }

}

 

The bold text is where error "undefined is not an object" is shown. Please help with the code. I am new to Indesign scripting.

I need to add hairline around document bleed

$
0
0

I need a script that add an hairline around document, over the red bleed line.

Anyone can help me?

evaluateXPathExpression

$
0
0

Hi All,

 

var myDoc = app.activeDocument;

var myRoot = myDoc.xmlElements[0];

var myElms = myRoot.evaluateXPathExpression("//*[@aid:pstyle]");

alert(myElms.length);

 

 

 

length returns 0.

how can i find all "aid:pstyle" tags

 

 

Thanks in Advance

Mahesh

Applying [None] character style

$
0
0

I have a script that finds text with a certain character style, cuts that text from the main story and anchors it in a frame that sits in the margin.

 

Everything works fine except that I'd like to have the option of removing the character style. However, when I apply the [None] character style InD shows [None] in the character style lists but the formatting for the character style that was just removed remains on the text.

 

Is there a way to have it work as if the [None] was manually selected from the character style list? i.e.: where the character style formatting is removed as well?

 

Thanks,

Ken

How to write a script for export underline text to PDF?

$
0
0

I am Harvey, work in financial printing field.

 

When I do some alteration in the financial document, I have to underline it aim to show what I have amend, those underline was called “markup“. And then print (hard copy) and gen (PDF) the amendment, which mean I have to print and gen the underline text (or called markup text) after  alteration.

 

sample pic:

 

back markup.jpg

 

 

If:

 

Client request a new version of markup which mean I have change the last markup color (last amendments’ underline color) into “back” and then make new markup to “red” like this:

 

red markup.jpg

       

 

What I want:

 

is that possible to write a script for print and gen the markup text only in the all open document

 

and I want two versions

 

1) gen all the markup text no matter what the underline color

 

2) gen the red color of markup text

 

thanks!

Viewing all 8771 articles
Browse latest View live


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