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

Problems with javascript console in Acrobat Pro

$
0
0

Hi,

 

I have this script which is below which I need to split a 300 page document which I need to split into 50 documents and name them with a csv file provided. I have the excel spreadsheet with column headed "filename" with 50 file names.

 

When I select the data file to import after being asked to enter text at start of filename etc I see the message 'No filenames found - using "file-XX.pdf". Press Escape after continuing to cancel.'

 

and then the error -

 

RaiseError: The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

Doc.extractPages:83:Console undefined:Exec

===> The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

file-0

 

I have checked the number of rows in the csv with the one which i created the merge in Indesign and it is the same. I have also tried using google docs spreadsheet but acrobat doesnt recognise the URL.

 

Thank you.

 

script I am using -

 

var CSV = function (data, delimiter) {

    var _data = CSVToArray(data, delimiter);

    var _head = _data.shift();

    return {

        length: function () {return _data.length;},

        adjustedLength: function () {return _data.length - 1;},

        getRow: function (row) {return _data[row];},

        getRowAndColumn: function (row, col) {

            if (typeof col !== "string") {

                return _data[row][col];

            } else {

                col = col.toLowerCase();

                for (var i in _head) {

                    if (_head[i].toLowerCase() === col) {

                        return _data[row][i];

                    }

                }

            }

        }

    };

};

 

function CSVToArray( strData, strDelimiter ){

    strDelimiter = (strDelimiter || ",");

    var objPattern = new RegExp(

        (

            // Delimiters.

            "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +

            // Quoted fields.

            "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +

            // Standard fields.

            "([^\"\\" + strDelimiter + "\\r\\n]*))"

        ),

        "gi"

        );

 

    var arrData = [[]];

    var arrMatches = null;

    while (arrMatches = objPattern.exec( strData )){

        var strMatchedDelimiter = arrMatches[ 1 ];

        if (

            strMatchedDelimiter.length &&

            (strMatchedDelimiter != strDelimiter)

            ){

            arrData.push( [] );

        }

        if (arrMatches[ 2 ]){

            var strMatchedValue = arrMatches[ 2 ].replace(

                new RegExp( "\"\"", "g" ),

                "\""

                );

        } else {

            var strMatchedValue = arrMatches[ 3 ];

        }

        arrData[ arrData.length - 1 ].push( strMatchedValue );

    }

    return( arrData );

}

 

function isInt(n) {

    return typeof n === "number" && n % 1 == 0;

}

 

var prepend = app.response("Enter any text to go at the START of each filename:");

var append = app.response("Enter any text to go at the END of each filename:");

var pathStr = app.response("If the PDFs should be saved in a sub folder, enter the relative path here:", "", "pdf/");

 

this.importDataObject("CSV Data");

var dataObject = this.getDataObjectContents("CSV Data");

var csvData = new CSV(util.stringFromStream(dataObject, 'utf-8'), ',');

var pagesPerRecord = this.numPages / csvData.length();

if (isInt(pagesPerRecord)) {

    for (var i = 0; i < this.numPages; i ++) {

        var pageStart = i*pagesPerRecord;

        var pageEnd = (i+1)*pagesPerRecord - 1;

        var recordIndex = (i + pagesPerRecord) / pagesPerRecord;

        var filename = csvData.getRowAndColumn(i, "filename");

        if (!filename) {

            app.alert('No filenames found - using "file-XX.pdf". Press Escape after continuing to cancel.');

            filename = "file-" + i;

        }

        var settings = {nStart: pageStart, nEnd: pageEnd, cPath: pathStr+prepend+filename+append+'.pdf'};

        this.extractPages(settings);

    }

} else {

    var message = "The number of pages per row is not an integer (" + pagesPerRecord;

    message += ", " + this.numPages + " pages, " + csvData.length() + " rows).";

}

 

(which I found from another forum, but noone has answered me and I am desperate)

 

Thank you in advance.



[AS/CC]Resizing a box and its contained image

$
0
0

Is there a method ro resize by percentage a box and the image inside?

 

My code for this is the following:

(first line for the box, second for the image)

 

  resize selection in inner coordinates from top left anchor by multiplying current dimensions by values {0.75, 0.75} with resize individually and considering ruler units  resize image 1 of selection in parent coordinates from top left anchor by multiplying current dimensions by values {0.75, 0.75} with resize individually and considering ruler units

 

But unfortunately, if the image is skewed, the result is not what we can expect: the image is resized, but misplaced.

 

Any suggestion?

[AS] How to test the presence of at least one table?

$
0
0

Hello everyone,

 

 

I would like to test for the presence of at least one table in a document before starting a process (on edge strokes). 

 

I found this, but I do not know if this is really effective:

                              setCountOfTables1tocountoftablesofeverystory

                              setCountOfTables2toeverytableofeverystory

 

The first gives me a list of the number of table in each story; the second gives me the objects reference of every table.

 

Is there another way?

 

TIA.

 

Oli.

How to detect H&J violations from a script

$
0
0

Is there a way to detect all lines that violate the H&J settings? ID highlights the lines in yellow, and I'd like to get a list of those lines so I can monitor in a script how changing frame width solves the problem lines.

 

I realize I could manually step through all the lines, checking the word and letter spacing against the settings, and figure it out manually -- but since ID already is doing that I'd rather not reinvent the wheel.

 

Thanks

Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times

$
0
0

I have these 6 page brochures and there are 50 marketing codes which need to be on first and 6th pages (different codes for each document exported). Rather than manually changing the marketing codes on the 2 pages 50 times (which takes too long) there has to be a easy way to do it. Anyone came across this?

Automated link creation?

$
0
0

We produce a monthly catalogue that contains approximately 500 part numbers that appear in the form of 'XXXX XXXX'.

 

Once the catalogue has been sent to print we use a third party online eBook creator that auto detects all instances of 'XXXX XXXX' and then inserts static text (http://abc.com.au/search?q=) before the part number to create a hyperlinked URL, eg.

 

http://abc.com.au/search?q=05512365

 

My question is, is InDesign capable of doing the same thing?

 

Apologies if I haven't explained myself very well - am more than happy to provide more info if it helps.

 

Thanks in advance.

InDesign CC - Extract Pages

$
0
0

Not a script guy, but think it's probably the only solution for splitting up an INDD file.

 

I'm running CC and need to break up a few documents into single page InDesign files (not PDF). I've read most of the articles on scripting but don't see anything that will work with CC (already tried a couple). Any suggestions?

Is there a way to migrate data from one user account to another simply?

$
0
0

Recently one of our employees has left the company. This user had pertinent images saved to their profile and we are needing to migrate those images to a new profile (Kiosk) so users can access the needed files. In InDesign I'm told it pulls file paths in order to pull up different images and documents. Is there a way to transfer these files without breaking InDesign? Or is there a simple way to recreate the file paths in InDesign so that we may move the user's information to a new account and recreate the file paths as soon as possible.

 

I was referred here from - http://forums.adobe.com/thread/1397569


Find and replace

$
0
0

Hi,

 

 

  XML poured document in InDesign, when moving the anchor it creates character like ":". 

 

I need to replace that character but I could not replace that. Even not able find that character in Indesign application manually.

 

 

 

char.png

 

find.png

 

 

 

 

If anyone knows, pls help me.

 

 

Thanks in advance,

Sudha K

InDesign CC Javascript

$
0
0

Our company is importing a lot of PDFs into InDesign documents for further processing down the line.  I need to be able to scan the text that was imported with the PDF to identify locations for documentation and other possible requirements down the road.

 

I looked at the number of text frames one InDesign document had that was the container for a PDF with lots of text (i.e. the PDF was PLACEd in the InDesign document) and Javascript said that the InDesign document had no text frames.

 

Is there a way to access the text in an InDesign document that was imported as part of a PDF document?  If all you have is an example, that would be sterling.

 

TIA,

 

R,

John

Applescripts no longer work

$
0
0

Hi all,

I had to update some old applescripts, but apparantly none of them work anymore on my machine (OSX Mavericks).

It seems to be related with calling InDesign (tried with CS5, 55 and 6), but I'm not sure.

Sample:

set myJavaScript to "alert (\"lalala\");"

 

tell application "Adobe InDesign CS6"

          do script myJavaScript language javascript

end tell

 

Result:

Sytax error:

Expected end of line but found “script”.

 

This used to work fine and actually still works on other machines (also OSX Mavericks)

 

Hoping anyone has experienced something like this and knows a solution...

 

Thanks!

find hyperlink convert to button

$
0
0

Hello,

 

Do somebody know a script that find hyperlinks and convert them to a button.

I work with CS5 on mac.

 

Kind regards,

Patrick

Save Indd Filename as Filename of placed PDF

$
0
0

Hi all, I'm not much of a programmer so this may seem like an incredibly easy problem for most of you, but it's baffling me. I'm running Indesign 5.5, and I have a javascript I've hacked together that will step a PDF times onto a page at specific spacing. What I'd like the script to do next is to insert the filename of that placed PDF into a textbox somewhere on the page, and then prompt you to save the indesign file, with the filename defaulting to the name of the placed pdf.

 

Ie. If the filename of the PDF placed on that page is "cct-smith-1.pdf", the text "cct-smith-1" would appear in a textbox on that page, and then the indesign file would prompt you to save with a default filename of "cct-smith-1.indd". Does that make sense?

 

Thanks!

replace paragraph with their respective icons

$
0
0

Is there a way to change different paragraph heads with their respective images (which they all differ for each of these paragraphs) at the same time.

Is there a plug-in or script that can automatically do this change?

njoftime.jpg

How to assign number one to numbered list? [CS6-jsx]

$
0
0

Can't change first para number in numbered list.

var myText = app.selection[0].paragraphs;
mstyle = app.activeDocument.paragraphStyles.item("body_numbered");for (i=0; i < myText.length; i++) {
with (myText[i]){
applyParagraphStyle (mstyle, false);}}  myText[0].spaceBefore = 2;  myText[0].numberingStartAt = 1; // does not change the first number of the list  myText[-1].spaceAfter = 2; 

Placing footnotes at the bottom in half width of a text frame while keeping text flowing aside?

$
0
0

Hi, Is there a way, a script, any opportunity of placing the footnotes at the bottom of the text frame in half width of it, and keeping the main text flowing near the footnote's frame while doing this -except manual work- ? (please check the attached image)

Layout.jpg

I have tried Sidenotes script (Thanks to Mr. Peter Kahrel - http://www.kahrel.plus.com/indesign/sidenotes.html -) unfortunately couldn't make "sidenotes_add.jsx" work (only 2nd parameter works for me). I was thinking of seperating the footnotes in a single text frame with an object style that anchors it to the bottom side of the main text frame. Was thinking of having two object styles and choosing from them respectively according to the side it should be.

 

Any kind of help is appreciated.

Regards

Kagan

Destroying ScriptUI Palette Windows

$
0
0

In ExtendScript, I've run up against a very strange scenario with which I need some help from a ScriptUI guru. I've got a huge InDesign script that, during the course of its execution, displays a progress bar in a palette window:

var w = new Window("palette", "Progress");

I would like this palette to be closed when the script is finished, so I added a w.close() at the end of the script.

 

However, this only occurs if the focus is still in InDesign. Some of our people like to work on other tasks while the InDesign script is running on another screen in the background, which is fine, but when they return to InDesign, that progress bar palette is still on the screen, showing 100% completion. This palette window can be moved around, but it cannot be closed, even if the little red 'x' in the corner is clicked. This eventually leads to multiple palettes staying on the screen throughout the day, as this script is called dozens of times in a normal workday.

 

Reading Peter Kahrel's excellent guide to ScriptUI, I learned that all palettes remain in memory, even after being closed with .close(). I want them completely erased from memory and purged, so they don't stay on the screen if the user switches to another application while the script is running. Any ideas on how to accomplish this?

 

By the way, I wanted to include some sample code so you could see for yourself, but it doesn't seem to work when it's just some small code called from with the ESTK; only in my 4,647-line production script. Thus, I cannot paste any example code.

Count Spell Check

$
0
0

Is it possible to count how many mispelled word by using javascript?

or Highlight mispelled word?

If can how to write the script?

Busy Cursor or Progress Bar

$
0
0

I have looked all around forums and links and am learning all sorts of things except for the one thing I need. I work for a publishing company and we produce a number of directories. I have modified the change/find script form adobe to pull these articles in from a tab-delimited text file. Everything works.

 

Where I run into issues is trying to generate a progress bar or busy cursor. I have the progress bar from Peter Kahrel's Script UI for Dummies but can't seem to figure out how to determine the total number of lines in the file.

 

Then I decided that the easiest thing would be to create a busy cursor and found this thread http://forums.adobe.com/thread/1109409. Problem solved... almost, I get an error stating "illegal use of reserved word import." This may be a Mac issue as the thread is a PC discussion.

 

Could you help me figure out what I am missing? Solutions for Mac and PC are wonderful as I use CC on Mac at work and CS6 on PC at home.

 

My code is below as I said the dirInput() function is working, with 5000+ entries it takes a little while to run so just need a progress bar or busy cursor. Thank you in advance. Jason

 

 

import mx.managers.CursorManager;

CursorManager.setBusyCursor();

 

 

 

 

 

 

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

var txtFrame = app.selection[0].parentStory;

CursorManager.setBusyCursor();

 

 

dirInput();

CursorManager.removeBusyCursor();

 

 

function dirInput(){

    var dirFile = File.openDialog("Choose the directory file you wish to import.");

    var txtLine, Lname, Fname, Phone, StreetNum, StreetName, HisEmploy, HerEmploy = null;

    Lcount = 0;

   

    if(dirFile != null){

        dirFile = File(dirFile);

        var myResult = dirFile.open("r",undefined,undefined);

       

        if (myResult == true){

 

 

             //Loop through the find/change operations

            do{

                dirLine = dirFile.readln();

                findTabArray = dirLine.split("\t")

                 //find options by tab

                //>>> <tab 0> Last Name       <tab 1>        First Name       <tab 2>        Phone       <tab 3>        Street Number       <tab 4>        Street Name       <tab 5>        His Employment       <tab 6>        Her Employment

                Lname = findTabArray[0]; //get the LastName - [0] tab              

                Fname = findTabArray[1];  //get the First Name - [1] tab              

                Phone = findTabArray[2];  //get  the Phone Number - [2] tabs               

                StreetNum = findTabArray[3]; //get the Street Number- [3] tabs               

                StreetName = findTabArray[4]; //get  the Streetname - [4] tabs               

                HisEmploy = findTabArray[5];  //get His Employment - [5] tabs                              

                HerEmploy = findTabArray[6]; //get Her Employment - [6] tabs

               

                //build and format the text line-by-line

                txtLine = Lname + ", " + Fname;

                txtLine = txtLine += "\t"; //add tab character

                txtLine = txtLine + Phone;

                txtLine = txtLine += "\n"; //add soft return

                txtLine = txtLine + StreetNum + " " + StreetName;

                txtLine = txtLine += "\n"; //add soft return

                txtLine = txtLine + HisEmploy;

                txtLine = txtLine += "\n"; //add soft return                         

                txtLine = txtLine + HerEmploy;        

                txtLine = txtLine += "\r"; //add paragraph return

 

 

                txtFrame.insertionPoints.item(-1).contents = txtLine; //>>> Inserts the entry at the end of the text already in the text frame.

                }while(dirFile.eof == false); //>>> completion of the do…while loop – in this case the loop runs until it reaches the end of the file (.eof); once eof is reached close the directory file.

                dirFile.close();

            }

        }

    }

 

 

function progressbar(line) {

    var w = new Window ("dialog", "Export XML", undefined, {closeButton: false});

    w.add ("progressbar", undefined, 1, line);

    var w = new Window ('palette');

    w.pbar = w.add ("progressbar", undefined, 1, line);

    w.pbar.preferredSize.width = 300;

    w.show();

    for (var i = 0; i < line; i++){

    w.pbar.value = i/300;

    $.sleep(20);

        }

    }

javaScript to load default Preferences

$
0
0

Hello

 

I ideally would like when indeisgn resets its preferences they are loaded in my default set instead of Adobe default set of preferences.

I have seen Preferences manager which looks like Javascript but of course its a jsxbin file and therefore i can not see the code.

Also i was hoping to just use a simple javascript

Does anyone know how to backup/restore load Indesign Prefernces via javaSCript?

 

Thanks

Viewing all 8771 articles
Browse latest View live


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