Canvas support in Indesign scripts?
Hello
short version:
I was wondering if it is possible in any way to include automatically generated content (Using canvas api for example) raster design using JavaScript?
Long version:
I noticed that the In-design supports a very old version of JavaScript, and since I'm pretty new to InDesign scripting, I thought, it's best to inquire about its capabilities / limitations before planing on what to do with it! I wrote a Javascript (not in in-design script) code which generates unique random patterns of patterns, now, I'm interested if I can integrate it into scripts in design so she would put one of these raster images in each page of a design document (IE: left and right of each face relatively pages);
also since my first guess after reviewing documentation of object a little design model has been that it is very limited to what is possible via the user interface software (and not everything/something new/more), so I was wondering (in this case), how is it possible to connect a script for an external script and send and receive the data/vars between them; like putting the two scripts in the same folder, one calls the other is giving some info (size of the document, etc.), the second script runs (outside of ID), put the images on the disk and return to the main script when's done it! :/
I have a few other sketches of solution as well in my mind, but wanted to get your opinion before doing anything ridiculous! :-)))
I really appreciate your in - put on this point.
THX, mim,
And Yes! It seems that I can run an external file of any type!
After reading and looking for some time, finally:
In the page 52nd documentation, it says:
Execute()
fileObj.execute)
Open this file using the appropriate application, as if she had been double-clicked in a file Explorer. You can use this method to run scripts, launch applications and so on
Voila! Exactly what I need (if what I think I need is actually what I need! indeed!)
I'll try to see if it works later (actually impatient!) and thx again!
mim
Tags: InDesign
Similar Questions
-
Edit an Indesign script for me?
Hi all!
I'm fairly new to Indesign scripting and I have a script here that I would have changed.
This script puts a several page pdf in an Indesign file and add pages as needed. From now this script appears in a dialog box that asks you what document I want than the PDF to be placed in, and I would like to have this dialog box eleminated and have the script automatically place the pdf file in the document I have active. This script also asked which page to start to put the pdf file on and I would if it would simply just start automatically on the first page of the Indesign document active without even asking me. Someone would be willing to make these changes for the script below and zip code on this thread? Let me know if I did something clear.
var myDocument = app.activeDocument; //Get the current page. main(); function main(){ //Display a standard Open File dialog box. var myPDFFile = File.openDialog("Choose a PDF File"); if((myPDFFile != "")&&(myPDFFile != null)){ var myDocument, myPage; if(app.documents.length != 0){ var myTemp = myChooseDocument(); myDocument = myTemp[0]; myNewDocument = myTemp[1]; } else{ myDocument = app.documents.add(); myNewDocument = false; } if(myNewDocument == false){ myPage = myChoosePage(myDocument); } else{ myPage = myDocument.pages.item(0); } myPlacePDF(myDocument, myPage, myPDFFile); } } function myChooseDocument(){ var myDocumentNames = new Array; myDocumentNames.push("New Document"); //Get the names of the documents for(var myDocumentCounter = 0;myDocumentCounter < app.documents.length; myDocumentCounter++){ myDocumentNames.push(app.documents.item(myDocumentCounter).name); } var myChooseDocumentDialog = app.dialogs.add({name:"Choose a Document", canCancel:false}); with(myChooseDocumentDialog.dialogColumns.add()){ with(dialogRows.add()){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Place PDF in:"}); } with(dialogColumns.add()){ var myChooseDocumentDropdown = dropdowns.add({stringList:myDocumentNames, selectedIndex:0}); } } } var myResult = myChooseDocumentDialog.show(); if(myResult == true){ if(myChooseDocumentDropdown.selectedIndex == 0){ myDocument = app.documents.add(); myNewDocument = true; } else{ myDocument = app.documents.item(myChooseDocumentDropdown.selectedIndex-1); myNewDocument = false; } myChooseDocumentDialog.destroy(); } else{ myDocument = ""; myNewDocument = ""; myChooseDocumentDialog.destroy(); } return [myDocument, myNewDocument]; } function myChoosePage(myDocument){ var myPageNames = new Array; //Get the names of the pages in the document for(var myCounter = 0; myCounter < myDocument.pages.length;myCounter++){ myPageNames.push(myDocument.pages.item(myCounter).name); } var myChoosePageDialog = app.dialogs.add({name:"Choose a Page", canCancel:false}); with(myChoosePageDialog.dialogColumns.add()){ with(dialogRows.add()){ with(dialogColumns.add()){ staticTexts.add({staticLabel:"Place PDF on:"}); } with(dialogColumns.add()){ var myChoosePageDropdown = dropdowns.add({stringList:myPageNames, selectedIndex:0}); } } } myChoosePageDialog.show(); var myPage = myDocument.pages.item(myChoosePageDropdown.selectedIndex); myChoosePageDialog.destroy(); return myPage; } function myPlacePDF(myDocument, myPage, myPDFFile){ var myPDFPage; app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia; var myCounter = 1; var myBreak = false; while(myBreak == false){ if(myCounter > 1){ myPage = myDocument.pages.add(LocationOptions.after, myPage); } app.pdfPlacePreferences.pageNumber = myCounter; myPDFPage = myPage.place(File(myPDFFile), [0,0])[0]; if(myCounter == 1){ var myFirstPage = myPDFPage.pdfAttributes.pageNumber; } else{ if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){ myPage.remove(); myBreak = true; } } myCounter = myCounter + 1; } } var myPDFFrame = myPlacePDF.parent;
Thank you very much in advance for your help! I greatly appreciate it!
This is a rewrite for you. I also added some code to remove empty pages in the document.
/*
PlaceMulitpagePDF condensed by Skemicle Script
*/
If (parseFloat (app.version)<>
main();
on the other
app.doScript (principal, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Place Multipage PDF");
main() {} function
var myPDFFile is File.openDialog ("choose a PDF file");.
If ((myPDFFile! = "") & (myPDFFile!) (= null)) {}
var = app.activeDocument myDocument,
myPage = myDocument.pages.item (0);
var myPDFPage;
app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
var myCounter = 1;
var myBreak = false;
while(myBreak == false) {}
If (myCounter > 1) {}
my page = myDocument.pages.add (LocationOptions.after, myPage);
}
app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place (File (myPDFFile), [0,0]) [0];
if(MyCounter == 1) {}
New var features = myPDFPage.pdfAttributes.pageNumber;
} else {}
if(myPDFPage.pdfAttributes.PageNumber == myFirstPage) {}
myPage.remove ();
myBreak = true;
}
} myCounter = myCounter + 1;
}
} var pages = app.activeDocument.pages;
for (c = 0; c<>
If (pages.pageItems.length [c] == 0) {}
pages [c]. Remove();
}
}
}
-
InDesign Scripting - increase of height of 1 mm
Hello
I'm still new to indesign scripting and have struggled to find an answer.
I have an empty rectangle frames page, all different sizes.
Is there a way I could select all images, run a script 'enlarge' via a keyboard shortcut, and all the boxes will increase by 2mm X + Y in the center of the frame.
Example - Frame w: 63mm frame h: 87.3 mm
< run Script - width = width + 2mm, height is height + 2mm >
< result >
Frame w: 65mm h frame: 89.3 mm (from the Center)
< image >
Repeat the <>
I'd appreciate any help I can get on this issue
Thank you!
-
How to pass the content of an xml element in the text frame in inDesign Script
var XMLFile = File.openDialog ("select XML Files... ») ;
var doc = app.activeDocument;
If (!) App.Documents.Length)
{alert ("ERROR: Document not opened");}
return;
}
doc.importXML (XMLFile);
var firstFigureNode = doc.xmlElements [0] .xmlElements [1] .xmlElements [0];
var lableNode = firstFigureNode.xmlElements [0];
var lableNodeText = lableNode.contents;
myFrame var = doc.textFrames.add ({geometricBounds: [-13, 13, 3, -3]});
lableNodeText.move (LocationOptions.AFTER, myFrame.texts [0]);
========================================================
My requirement is: == > > move the content of an xml element in the text by inDesign Script block, but XML InDesign file Structure should not be change & data in the XML Structure should remain as it was before...
I tried to code above, but it does not work...
Please can someone help me in solving this problem...
It does not work correctly...
It moves firstFigureNode in myFrame...
firstFigureNode.placeXML (myFrame);
===>> For Apple Script try below Code ===>>
myFrame markup using firstFigureNode
-
How to change type of police using InDesign scripting (Javascript)?
Hello
I need to change the font type of a document, InDesign using InDesign script (javascript). I found a few online references in the InDesign scripting guide and running extract next, gives me errors.
Delete existing preferences
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
app.findChangeTextOptions.caseSensitive = false;
app.changeTextPreferences.appliedFont = app.fonts.item ("DEVANAGARI MT");
App.Documents.Item (0) .changeText ();
Download the msg of InDesign server.
Error code: 1
Error description: changeText
The indesign file that is used to change the font is certainly not corrupt, cause the following script to export the file in .png works very well. Any help appreciated.
app.pngExportPreferences.exportResolution = 100.0;
App.Documents.Item (0) .exportFile (ExportFormat.PNG_FORMAT, PreviewDocument don't);
Hello
Try this 1-liner:
app.documents.item(0).stories.everyItem().appliedFont = app.fonts.item("DEVANAGARI MT");
Guess above specified police is available. Some disorders may begin with the name of the font, cause not always WYSIWYG.
To be sure how to refer to a specific font by its name - a console text and notice of runing ESTK select this option:
app.selection[0].appliedFont.name
Jarek
-
I work under Vista and this message comes when I tried to download creative cloud: "the operating system you are using is no longer supported by InDesign.» Refer to the minimum requirements for a complete list of the supported platforms. "How can I do install creative cloud and use Indesign?
Thank you
Hi Laurent,.
Please refer to the data sheet below:
System requirements | Creative cloud
Kind regards
Sheena
-
I'm new in indesign scripting, please tell me how to write a script to get the contents of an XML element and then sort all the content
Hello
Can the code below is useful for you, but I do not know how to sort.
Change the tag based on your employment application.
-
InDesign script to run on the action?
Hi, can someone help - is it possible to set up an indesign script to be triggered to perform an action, for example when you export to PDF (instead of manually running the script)? To explain, I have a script that creates a text box to display the size of the indesign document, but if the size of the page change the text box does not update unless you manually run the script again. so I was wondering if it was possible to put the script to run when the document is exported to PDF, so in theory be PDFd with the size of the pages always display up-to-date!
I approach this issue perspective, as altogether new to the am scripts.
Thanks in advance for any suggestions.
Hi Trevor - thank you very much for this - (after a bit of trial and error with changes!) managed to make it work.
Work of great stuff.
Thanks again
-
InDesign script to put the excel file
Hi all, I'm new to Indesign Scripting, and I hope someone can help me with the following code:
All I want to do is:
- Open the indesign file
- Open excel file
- ExcelFile place as a table (with active flow)
- export as PDF & save document
Thank you!
//Define file to open var myDocumentFile = new File("/d/Projecten/Indesign Server/document.indd"); //Define file to save //var mySaveFile = new File("/d/Projecten/Indesign Server/document_save.indd"); //Define file to export var exportPDF = new File("/d/Projecten/Indesign Server/document_save.pdf"); //Open xls-file to place as table var myExcelFile = new File ("/d/Projecten/Indesign Server/products.xls"); var result = ""; if(!myDocumentFile.exists) { result = "Unable to find DOCUMENT: " + myDocumentFile.path; $.writeln(result); exit(); } else if(!myExcelFile.exists) { result = "Unable to find EXCEL: " + myDocumentFile.path; $.writeln(result); exit(); } else { // Open file var myDocument = app.open(myDocumentFile); with(app.documents.item(0).pages.item(0)){ myTarget = textFrames.item("tabel"); } var myPage = myDocument.pages.item(0); //Set excel placement properties setXLimportPrefs(); // Place Excel file try { $.writeln("Place Excel file"); //HELP!! HOW TO PLACE EXCEL FILE? //myTextFrame.place(myFile); } catch (e) { $.writeln("Place Excel file " + e + " " + app.excelImportPreferences.errorCode); myDocument.close(); exit(); } if(!exportPDF.parent.exists && !exportPDF.parent.create()) { result = "Not exported. Unable to create the folder: " + exportPDF.parent.fullName; $.writeln(result); } else { app.documents.item(0).exportFile(ExportFormat.pdfType, exportPDF, app.pdfExportPresets.item("[Press Quality]")); } myDocument.exportFile(ExportFormat.PDF_TYPE,exportPDF); myDocument.close(); } function setXLimportPrefs(){ $.writeln("setXLimportPrefs()"); with(app.excelImportPreferences){ //alignmentStyle property can be: //AlignmentStyleOptions.centerAlign //AlignmentStyleOptions.leftAlign //AlignmentStyleOptions.rightAlign //AlignmentStyleOptions.spreadsheet alignmentStyle = AlignmentStyleOptions.spreadsheet; decimalPlaces = 4; preserveGraphics = true; //Enter the range you want to import as "start cell:end cell". rangeName = "A1:B16"; sheetIndex = 1; sheetName = "Appetizers"; showHiddenCells = false; //tableFormatting property can be: //TableFormattingOptions.excelFormattedTable //TableFormattingOptions.excelUnformattedTabbedText //TableFormattingOptions.excelUnformattedTable tableFormatting = TableFormattingOptions.excelFormattedTable; useTypographersQuotes = true; viewName = ""; } } result;
myTextFrame is not defined in your script.
It works for me:
myTextFrame = app.selection[0]; var myExcelFile = new File ("~/Documents/idml/some file.xlsx"); myTextFrame.place (myExcelFile);
-When I select a text block, of course.
To debug this, you can remove the try... catch statements because they're actually hiding the error now: InDesign can place the file, but the variable does not exist.
Thankfully, I fell it many times before.
-
Registering InDesign Script ID/name pair
Hello
I try to record some InDesign Script ID/name pair, but it doesn't seem to work.
These are my pairs:
TFSS, Suite TabFlow
TFob, object of the object TabFlow
TFut, event table update
TFuj, event do update of jobs
TFop, object from the TabFlow property
TFts, model for the table Propetry slug
Patiaudrey, updateJob-ID parameterIf I submit that I return to the site. There are 4 confused red symbols showing, but not a message of error or something like that. You can see in the attached priontscreen.
I want to see the pairs already registered, the site is empty.
What coud be wrong?
Thank you
Hans
My first guess would be the "-" in udateJob-ID.
So please revisit the naming conventions.
-Have a look at docs/references/scripting-dom-applescript-idr60.html for examples, AS linking is closer to the natural formatting.
-capitalization is generally left for the engine, with the exception of acronyms, for example 'suite of XML '.
-for identifiers JS, caps indicate spaces in the original name
-your starting names with generic types such as 'Suite', 'Object' will lead to confusion. Omit those who, with the exception of the suite where you make a suffix (put behind the name). for example 'suite of interactive elements '.
-This TabFlow object looks like a singleton or a preference. I would call it "option TabFlow" or "TabFlow preferably" instead, depends on the question of whether it is persistent.
-the name of the corresponding property is the plural form. See, for example
This AppleScript DOM Qouting: (I hate this wysiwyg forum editor!)
script preferences (property kScriptPrefsPropertyScriptElement)
ScriptID= 'DCPDH', name = 'script preferences '.<--- the="" property="">--->
Description = preferences. Script, Plugin = Scripting.InDesignPlugin
Data type = "script of preference"<---- the="" class="">---->Finally, what makes you choose the "do" in "do update... "for the unique event, then omit it for each other?
Have fun
Dirk
-
Only 5000 lines currently supported in a script results
Only 5000 lines currently supported in a script results
5000 selected lines
Is it possible to switch to 10000. I'm looking for but have not found.Yes, it is: preferences - data - sheet - Max rows for print in a script.
Have fun
K. -
Support assistant install script error
HP Pavilion DV - 7 1247dx,
Vista Home premium.
during the installation of support Wizard I get a script host error
"library not registered. 8002801 D code.
Program continues to settle, but not computer
does not appear at the bottom of the support Assistant main window.
HP Pavilion dv7-1245dx Notebook PC (PC x 64)
Vista™ of MS Windows Home Premium 6.0.6002 SP2 Build 6002
2 logical processors, 2 Lossnay, 2100 Mhz, AMD Turion (TM) X 2 Dual - Core Mobile RM-72
BIOS F.49, 17/08/2009Hello
Move everything you don't want to lose out on the external hard drive.
If you use the disks created when first set you up the PC, then all of the programs that you installed after that point in time will be deleted.
Using a power adapter to power your laptop is necessary while you do this.
Once you enter the Recovery Manager choose Factory Image recovery and follow the prompts and wait. Once the recovery began not to interrupt or attempt to stop him.
Best regards
ERICO
-
InDesign script to accept changes in the stories?
Hi Chaps,
I work for an agency, which manages the customer to translate InDesign documents.
From time to time, we must accept all the 'track changes', as 'InsertedText' has been left by the customer.
Is there an automated process, or a script that can loop through all stories in a document and validate every change?
Thanks in advance
Close.
App.documents [0]. Stories.everyItem ().changes.everyItem (). Accept();
-
InDesign script for a text of color replace all other lines in a text box
I have a very long list of names I need to alternate the color CMYK, all other rows value.
changing the hue of every 3rd line:
var i, p; for (i=0; i<app.selection[0].paragraphs.length; i++) { p = app.selection[0].lines[i]; if (i%3 === 2) { p.fillTint = 50; } }
I tried to change the script to change the value of CMYK, do this:
var i, p; for (i=0; i<app.selection[0].paragraphs.length; i++) { p = app.selection[0].lines[i]; if (i%2 === 1) { p.colorValue=[0,100,100,0]; } }
But using 'colorValue' is not supported. How can I change the script to do all the other lines in a text box to change the value of the color?
var i, p, color; for (i=0; i
-
How to run a co-op start up Indesign script?
Hello
I have a script that works well when it runs manually in inDesign CC.
Now I need this script to run automatically when a file is opened in InDesign.
I put the script in the folder "scripts stratup. But get the error that there is no active document. The script runs before the opening of the document.
on:
sommthing is mentioned, but I can't run!Do I have to install the APID toolkit (only has a plugin for CS4 and low) or APID toolassistent? And when I do? What then?
I'm not a computer scientist.
Can anyone help?
TNX
Just click in the box as ok and reopen your application
Mi_D
Maybe you are looking for
-
Windows cannot connect to the server to update game
I can't update the game in the game folder Plese Help
-
I bought a HP7510 all-in-one printer when I moved to China 3 years ago. In China the correct according to HP cartridges 862. I am a UK national and have returned to England and brought the printer with me. I have now purchased cartridges to the Unite
-
Automatic updates you ask again to update me. When I do he does then goes back to asking me to update again.
-
Shortcuts on the desktop are Wordpad
I was copying a screenshot and all my desktop icons are now eager to open in Wordpad. How can I change them back?
-
Whenever I turn on the computer, my clock is wrong.
Whenever I turn on the computer, my clock is wrong. I installed Windows7 in November, but this only started happening after the new year. When I change the time display, it only changes the time on the screen. not on the clock display computer. And w