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

How to List Placed Tiffs into a BY PAGE???

$
0
0
Dear Scripting team,

Is there a way to list the name of graphics (links) on each page and make a list like:

file1.tif Page 1
file2.tif page 3
file4.tif page 5
file5.tif page 8

I can list the graphic names with this:

************************************************************

Set myInDesign = CreateObject ("InDesign.Application.CS3")

for each element in myindesign.ActiveDocument.links

msgbox(element.name)

next

************************************************************

BUT I can not get the page where the graphic is contained as my list above or say something like... myindesign.ActiveDocument.pages.item(1).links because it give me an error... i mean.. ican't specify the page where I wanto to get the links and also can't know the page number where the element (link) is contained...

ANY IDEAS?? Thank you!! Thank you!!!

glue code

$
0
0

Any one, please share the latest version of glue code.jsx.

Get data directly from Excel

$
0
0

Hi all,

 

Quite often I have to write scripts that use data originated from an Excel worksheet. I (and most scripters) believed that the easiest approach was to use a CSV-file exported from Excel. However, this takes an extra step for the user so I decided to write a function that opens an Excel book in background, reads the data from its first spreadsheet and returns array.

 

The function has three arguments:

  1. excelFilePath— The platform-specific full path name for the xlsx-file — fsName. If you pass it as a string, make sure to double the backslashes in the path like in the line below:
     var excelFilePath = "D:\\My Test Folder\\SampleBook.xlsx";
  2. splitChar— [Optional] the character to use for splitting the columns in the spreadsheed: e.g. semicolon (;) or tab (\t)
    If it isn't set, semicolon will be used by default.
  3. sheetNumber— [Optional] the worksheet number: either String or  Number. If it isn't set, the first worksheet will be used by default 

 

The data in Excel

The same data transfered to InDesign as Array

The function (current version):

Main();

function Main() {
    // The platform-specific full path name for the xlsx-file -- fsName    // If you pass it as a string, make sure to double the backslashes in the path like in the line below    var excelFilePath = "D:\\My Test Folder\\SampleBook.xlsx";        // [Optional] the character to use for splitting the columns in the spreadsheed: e.g. semicolon (;) or tab (\t)    // If it isn't set, semicolon will be used by default    var splitChar = ";";        // [Optional] the worksheet number: either string or number. If it isn't set, the first worksheet will be used by default    sheetNumber = "1";    var data = GetDataFromExcelPC(excelFilePath, splitChar, sheetNumber); // returns array
}

function GetDataFromExcelPC(excelFilePath, splitChar, sheetNumber) {
    if (typeof splitChar === "undefined") var splitChar = ";";    if (typeof sheetNumber === "undefined") var sheetNumber = "1";    var vbs = 'Public s, excelFilePath\r';    vbs += 'Function ReadFromExcel()\r';    vbs += 'Set objExcel = CreateObject("Excel.Application")\r';    vbs += 'Set objBook = objExcel.Workbooks.Open("' + excelFilePath + '")\r';    vbs += 'Set objSheet =  objExcel.ActiveWorkbook.WorkSheets(' + sheetNumber + ')\r';    vbs += 'objExcel.Visible = False\r';    vbs += 'matrix = objSheet.UsedRange\r';    vbs += 'maxDim0 = UBound(matrix, 1)\r';    vbs += 'maxDim1 = UBound(matrix, 2)\r';    vbs += 'For i = 1 To maxDim0\r';    vbs += 'For j = 1 To maxDim1\r';    vbs += 'If j = maxDim1 Then\r';    vbs += 's = s & matrix(i, j)\r';    vbs += 'Else\r';    vbs += 's = s & matrix(i, j) & "' + splitChar + '"\r';    vbs += 'End If\r';    vbs += 'Next\r';    vbs += 's = s & vbCr\r';    vbs += 'Next\r';    vbs += 'objBook.close\r';    vbs += 'Set objBook = Nothing\r';    vbs += 'Set objExcel = Nothing\r';    vbs += 'End Function\r';    vbs += 'Function SetArgValue()\r';    vbs += 'Set objInDesign = CreateObject("InDesign.Application")\r';    vbs += 'objInDesign.ScriptArgs.SetValue "excelData", s\r';    vbs += 'End Function\r';    vbs += 'ReadFromExcel()\r';    vbs += 'SetArgValue()\r';        app.doScript(vbs, ScriptLanguage.VISUAL_BASIC, undefined, UndoModes.FAST_ENTIRE_SCRIPT);        var str = app.scriptArgs.getValue("excelData");    app.scriptArgs.clear();        var tempArrLine, line,    data = [],    tempArrData = str.split("\r");        for (var i = 0; i < tempArrData.length; i++) {        line = tempArrData[i];        if (line == "") continue;        tempArrLine = line.split(splitChar);        data.push(tempArrLine);    }        return data;
}

 

I wrote and tested it in InDesign CC 2017 and Excel 2016 (Version 16) on Windows 10. I wonder if/how it works in other versions of Excel. Also, I'd like to get some feedback: bug reports, suggestions and new ideas.

Here's the permanent link on my site.

 

— Kas

Data merge with alternate layouts

$
0
0

I'm wondering if there's a way to have merged document pages stay in the same layout section as the source file. Right now I've been manually selecting the pages and moving them to their appropriate column. Is there another way to do this so that each record is listed in the same layout as its source?Screen Shot 2019-01-31 at 11.58.51 AM.png

ExportAllStories script failing with Hebrew characters

$
0
0

The ExportAllStories.jsx works fine except when Hebrew text (Unicode) is involved: only part of a story is exported, and the Hebrew text is gibberishised. This applies both to when Text Only is exported and when the text is exported as RTF.

InDesign.png

exportedRTF.png

Has anyone an idea how this problem could be resolved?

 

InDesign CC 13.1

macOS High Sierra 10.13.6

Creating an SSL connection in ExtendScript

$
0
0

Is there any way to create a connection to an HTTPS server using pure ExtendScript code?  ExtendScript provides a simple Socket object for HTTP connections, but I don't see any examples showing how to create secure connections.

can you use Socket to get data from HTTPS URLs?

Articles Panel in Indesign

$
0
0

Team,

 

anyone can help me how to find and report or highlight page items frames which is not add in article panels using script.

 

regards,

red


Use GREP to find \r or \n

$
0
0

Hi all,

          Consider a paragraph with multi lines, in between there is two lines seems empty. Now i have to break the paragraph based on the empty lines or carriage returns using GREP. Thanks for any help.

 

Regards,

Sasi

Page order of objects query

$
0
0

Hi

 

I am looking to put together a document that has a repeating set of icons next to the folio. It will be a sequence of 28 different objects, which will have the first on p1 and then go through until page 28, then the sequence repeats from p29 to p56 and so on throughout the book. This is not a major problem to set up (if a bit fiddly). However, if, at a later date the page order gets changed, then my sequence order will be disrupted. Do I have to then move them all again manually, or is there a way to make the order of these objects independent of the page, so if, for example, page 27 moves to page 9, then it doesn’t take the 27th icon in the sequence with it.

 

Hope this makes sense

 

Many thanks

 

Keith

where to change the PDF preset in this snippet

$
0
0

I'm trying to add a new feature to my script...

 

this is part of a larger script that will make two pdf. the user can select from their presets or customize the pdf

I then basically rerun the same snippet to give the user an opportunity to create another pdf (Low resolution proof & high res final art).

I want to have the dialog box open with the most common option preselected.

currently it comes up with the most recently used preset preselected.

 

this is what i have tried...

 

=======================================================================================

 

// your preset name

var pdfPreset = app.pdfExportPresets.itemByName("smallest size_spreads");

if (!pdfPreset.isValid) { 

  alert("Your preset doesn’t exist!");

  exit();

}

 

 

while(app.documents.length>0){ 

    var d=app.activeDocument; 

    }; 

else{ 

    alert("Please open a document to execute export to pdf. Script will be aborted."); 

    exit(); 

    } 

if(d.saved == false){ 

    alert("Save your document first before executing export to pdf. Script will be aborted."); 

    exit(); 

    }; 

 

var pdfPath = Folder.selectDialog("Folder to save LOW RES pdf:"); 

var pdfName = d.name.substring(0, d.name.indexOf("."))+"_lr.pdf";

 

 

var userDefFileName = prompt("File name:",pdfName,undefined); 

 

if(userDefFileName == null){ 

    exit(); 

    }; 

 

var pdfFullName = pdfPath+"/"+userDefFileName; 

 

if(File(pdfFullName).exists){ 

    c=confirm("The PDF-file \""+userDefFileName+"\" is already existing. Do you want to overwrite it?",true,undefined); 

    if (c==0){exit()};   

    }; 

//Error-handling if PDF file override is on and PDF is already opened in an PDF reader app: 

try{ 

d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,pdfPreset); 

}catch(e){ 

    alert("Error:\r"+e.message+"\r\r(Line "+ e.line+" in script code.)"); 

    exit(); 

    };   

How do I place an image in a text frame using javascript in Indesign?

Read XL File

$
0
0

Hi,

 

     We can read TXT and CSV file using InDesign Javascript.  Can we read XL file using javascript?

RTF Extraction

$
0
0

CC3.JPG

 

While I am going to extract RTF it gives error some times like adobe indesign tagged text import, Hope this one comes because of not defined paragraph style option in list, Find the screenshot and tell me how to fix this in script.

Reading lines on a csv file

$
0
0

Need some help if anyone has any answers please

 

Below is a line I use for reading a cell in an Excel document:

var colHd = "Number", rowHd = "R"+Num, cellCont=excelVal(csvFile,colHd,rowHd);

 

My Excel document is set up as below:

Screen Shot 2019-02-08 at 16.34.49.png

 

The only use I have for the "Rows" column is so I can read the cell contents under "Number", so I have the var "Num" counting up so it will look for "R1, R2, etc."

Can I replace the "R"+Num in my code with something else that will just simply read the line number instead of requiring the "Rows" column?

 

Many Thanks for any help, Bren


Convert Text to Footnote

$
0
0

Hi,

i used Jarek Jump_Over script "Convert Text to Footnote" and it really worked good for me. however, when i have two paragraphs in a note and i convert it to footnotes using the script, the script does not put the second paragraph together with the first in the new converted footnote, rather it leaves it behind, it would be grately appreciated if there is a way to change something in the script that includes all paragraphs in a note.

 

Thank you.

 

see pictures in link

unnamed.png - Google Drive

unnamed (1).png - Google Drive

Path change

$
0
0

is there a way to make a script to change just a part of the path to all the links.

lets say all the docks links are in //server_1/ and i have //server_2/ with the same folder tree as server 1 so by just change the 1 to 2 the files would be there..can that be done at once with java script?

How to add PDF security to existing code?

$
0
0

Hi

I have the below code which was written for me a little while ago by Manan Joshi, and works flawlessly, I would like to add some security to

the PDF at export from IndesignCC 2019 (MAC), I have found some code that I think will do what I need, not to sure if more should be added

as I am not very familiar with extend script,  I am unsure where to add it in the script, could some one please help me out?

 

 

     function isOurFolder(arg) 

    { 

         if(arg.name.match(/^Q.*?/)) 

              return true 

         else 

              return false 

    } 

    var myFolder = Folder.desktop.getFiles(isOurFolder) 

    var myDoc = app.activeDocument 

    var docName = myDoc.name.replace(/.indd$/i,"") 

    var _dest = myFolder[0].fsName 

    try 

    { 

         var unusedSwatches = myDoc.unusedSwatches 

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

              unusedSwatches[i].remove() 

    } 

    catch(e){} 

    var screenSettings = app.pdfExportPresets.itemByName("USE THIS TO DISTILL-1") 

    app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES 

    app.pdfExportPreferences.viewPDF = true 

    app.activeDocument.exportFile(ExportFormat.PDF_TYPE, _dest + "/" + docName + ".pdf", false, screenSettings) 

    myDoc.close(SaveOptions.YES)

 

 

 

 

Security to add to the above::

 

useSecurity = true;

 

viewPDF = true;

 

disallowPrinting = false;

 

disallowCopying = true;

 

disallowChanging = true;

 

changeSecurityPassword = "XXXXXX"

how to define paragraph style

$
0
0

Hi experts,

 

How to define my paragraph name match 2 items:

 

    myParagraphStyle = myDoc.paragraphStyles.item("50 Table_txt") || myDoc.paragraphStyles.item("51 N_Table_txt");

 

what's wrong with syntax?

 

thanks

John

Are square buttons still possible in ScriptUI?

$
0
0

Corners are rounded by default and unusable at a small dimension in ID 14. Is there a way to get square buttons in the properties somewhere (which i havent seen yet) or is a workaround the only way to solve this? I was considering using panels with event handlers as an option.

Viewing all 8771 articles
Browse latest View live


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