Illustrator Scripting :: How To Place Textframe Central To Artboard
Apr 15, 2012
This is my very first attempt at a script:
* this script will prompt the user for a file name and location and then save the current file as a .pdf with secure save options*/
var curDoc = app.activeDocument;
var destName = prompt ("Enter a Filename Daniel", "", "Save With Security");
var destFolder = Folder.selectDialog('Select which folder to save to :');
saveFileToPDF(destFolder+ '/' + destName); // not sure if i need this here ?
[Code] .......
i can do the math of (artboard width)-(text width) / 2 is start point of text but how do i find out the text width and the artboard width?
I am working with scripting in Ai, fill gradient color in TextFrame. I search in this forum but the other topics fill color to path or line. For now, I can make a gradient color, but I don't know how to apply it to textframe.
I'm trying to read a text file into a textFrame. It reads in but is not including linefeeds so it's just one big long line of text. I'm using the following code to read the file. I attempted to insert a character after each readln() but that didn't work. I also tried creating a variable that the readln() was stuffed into before setting the textFrame.contents to the variable, but that didn't work either. I'm stumped.
while (! notesDoc.eof) { noteTextRef.contents += notesDoc.readln();}
I think I might be doing this wrong, I am trying to get contents of a specific textFrame within first group on layer called "page numbers"
It seems to work, but is a bit sketchy, the documentation indicates textFrame is all the text frames in a document, and that textFrameItem should be the specific one within collections of groups etc, maybe I am misunderstanding. this is what I am using:
var existingPageNumbers = app.activeDocument.layers.getByName('page numbers').groupItems[0].textFrames[0].contents;
I'm trying to find the smallest textframe within a group and then matching that textframe font size to the minimum size allowed for printing. Everything else works, except I can't figure out how to resize the textframe while also resizing its parent, the group.
I edited a couple images in Photoshop for postcards to be printed, I converted them to CMYK and then saved as PDFs. I then tried to open them in Illustrator to finish up the project, but when I tried to place the images a box pops up that says "unknown error has occured" and when I try and open the images, all you can see is a blank artboard.
I want to write a script for Illustrator that will apply a step and repeat as a transform effect based on the dimensions of the artboard. I've figured out how to get the dimensions of the artboard, but I'm at a loss as to how to apply a transform effect with a script. It looks like it might be in the Matrix suite, but none of the descriptions there make much sense to me.
1. Is there an easy/precise way to place a guide in the exact center of an artboard?
2. I want to use the guide to create a balanced design for a poster by making sure that I place my focal image on the center of guide to ensure that half of it displays on either side of the guide. How important is it to strive for complete balance? Sometimes I see ads that seem to have balance while other times there might be tons of white space an some graphic element on one side or the other of the layout.
When i call the method selectObjectsOnActiveArtboard on an artboard, is there a way to easily group all items in the selection? Like in the menu found under "right click > group"
My script creates an artboard in my pdf file. i need to print this artboard only.
if i go to file/print manually there is an option 'Bereich' (pls see screenshot, my illustrator is in german language), so only the 2nd page is printed. (exactly what i want)
up to now i could not find this option (or something similiar) within vbscript.
code: ... appRef.ActiveDocument.Artboards.Add(Array(Rminx,Rmaxy,Rmaxx,Rminy)) ' vars are correctly set before Set jobOptionsRef = CreateObject("Illustrator.PrintJobOptions") Set printOpts = CreateObject("Illustrator.printOptions") printOpts.JobOptions = jobOptionsRef jobOptionsRef.Designation = 2 'aiAllLayers jobOptionsRef.PrintArea=2 appRef.ActiveDocument.PrintOut printOpts ....
these lines prints 2 pages: 1) main document 2) artboard
if i set jobOptionsRef.Designation = 1 only the main document is printed - but not the artboard. i need exactly the other way round, only the artboard but no main image.
I have the common problem to resize the artboard to standardize technical illustrations to the format 50x50mm.
I would like to group the objects for further transformationsI would transform the group to 45mm and scale stroks and effectsN.B.: here It should be a test on landscape format
I would align the group to the page center
Public Sub copy_paste_with_transformation () 'Duplicates grouped items in a new document with landscape sensitive transformation Set appRef = CreateObject("Illustrator.Application")
'calculate the size of objects do define if it's landscape or not Bounds = appRef.ActiveDocument.VisibleBounds
I'm trying to create a script via javascript for Illustrator.
My problem is : I have a AI file with multiple layers, i want to create one artboard per layer, in order to export a multipage PDF ( each page contain 1 layer ).
The layers represents the differents type of print ( vernish, color, hot gold, pressure ... ) and/or color type ( Pantone, CMYK, cut, kisscut ... ). My client want a PDF for see each type of print or color type per page.
I'm trying 2 ways :
1st solution : Create new artboards, and duplicate ( or move ) layers content on the new artboad, but the function move/duplicate don't work to move content on another artboard.
2nd solution : Create new document with the same number of layers as artboard and duplicate layer to the new artboard on the new document.
Is there a way to write a script to copy a selected/chosen artboard (and it's contents) to another opened document, placing it in exactly the same place on the global x/y coordinates? I'm either unable to find this feature built in to Illustrator, or it's simply missing.
Is it possible to use a JS script to find/replace artboard names? For example if I have artboards that are currently named 39 and 42...can I use a script to change the name of the art boards to 39E and 42C etc?
Also part of the script a simple find/replace of text on locked layers.
I've made this small script to test a few things, before moving on to the bigger stuff (some of it have been cut out, since it's not important):
var exportOptions = new ExportOptionsJPEG(); var type = ExportType.JPEG; var fileSpec = new File(dest); exportOptions.antiAliasing = false; exportOptions.qualitySetting = 70; exportOptions.artboardRange = "3"; app.activeDocument.exportFile( fileSpec, type, exportOptions );
I'm trying to export artboard #3 as a JPEG. But it doesn't work.
According to the scripting reference guide, most of the "ExportOptions"-functions support the artboardRange-parameter, but alas - JPEG does not.
Is there another way to do this? Right now I'm only getting all the artboards into a single JPEG-file, which is not what I'm searching for
I am having trouble with the Paste in Front/Back function. I will copy my selected layers and then want to paste them in place on the selected artboard next to it and often times it pastes it back on the artboard where it copies from. Sometimes the function does what I want, but often times it pastes in a different location, either on the same artboard, or next to the artboard where I want it pasted. It also tends to slightly move the X and Y values (again, sometimes). Each time I go to paste, I am creating a new layer and selecting the artboard where I want everything pasted, but sometimes it works, and other times it doesn't. I am using CS5 on MacBook Pro.
I want to select the objects outside artboard using javascript. Their are many objects outside activeartboard i want to select all those object using script.
Simple solution to aligning selected items to the artboard. I was going to create an action but then realized it would be more convenient for me to include it in my script file....I have a script to align objects with each other but they dont align to the artboard.
trying to make an object the exact size of the artboard. This is something I do on a daily basis for several different reasons and it would be very useful if this can happen automatically for whatever size the artboard may be. As I understand it the only way is with a script but I have no experience with making illustrator scripts, im definately no programmer. I have set up quickkeys in the past to copy from the artboard inputs when you are on the artboard tool but these round to the nearest .01 and this is not accurate enough for what I am working with. Also if I do this with multiple pages open illustrator is very slow to respond to the artboard tool.
Below is a script that I saw on here that I believe may contain what I need but now knowing programming. Where to start on editing. All I need is the part where an object is placed on the artboard that is the exact same size as the artboard.
#target illustrator function main() { if (app.documents.length == 0) { alert('Open a document before running this script'); return; // Stop script here no doc open… } else { var docRef = app.activeDocument; with (docRef) { if (selection.length == 0)
how do I center my current selection to the artboard? just like hitting the "horizontal align-center" and "vertical align-center" buttons. I've been searching for the last two hours and before my head hits the keyboard.
What I'm struggling with: in my init function i create a new document and then copy all layers from the previous document step by step to the new document and then save it as SVG.
// Init (function(){ destination = Folder.selectDialog('Select folder for SVG files.', docPath); if (!destination){return;} holderDoc = app.documents.add(); stepThroughAndExportLayers(docRef.layers); }());
my problem is that holderDoc = app.documents.add(); always creates a document that is not the same size as my initial document where the layers get copied from.
so I want the exact same artboard size as in my initial document.I'm fine with either doing it as fixed values or taking directly the values of the inital doc. i tried this in the segment where I create the new document:
which from what I've read on the web means that illustrator doesnt know what document to pick. but i have called it directly. I do not want to fit the artboard to the images/layer. the artboard should always have a certain size. (for me 128px by 128px)
// edit: workaround (function(){ destination = Folder.selectDialog('Select folder for SVG files.', docPath); if (!destination){return;} var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveAr tboardIndex()]; var ABRect = activeArtboard.artboardRect; holderDoc = app.documents.add(); holderDoc.artboards.add(ABRect); holderDoc.artboards.remove(0); holderDoc.artboards.setActiveArtboardIndex(0); //stepThroughAndExportLayers(docRef.layers); }());
i now added a new artboard to the new document with the same size as the artboard on the initial document.i remove the predefined artboard on the new doc and set the new artboard as active the artboard is now not centered into the window. which lets illustrator place my image with ctrl+c -> ctrl+v somewhere outside the artboard.
i now need to align my selection to the center of the artboard. but i cant find any reference on how to center a selection to the artboard.
I have a document with several artboards. In each artboard is a different linked image. Is there a way to add the linked filename to the bottom of each artboard?
I have an Illustrator document with ~100 artboards, each artboard named by me. Each artboard has one textbox in it. Is there a way to take whatever name I assign to the artboard and print it into the text box inside that artboard? So in the end I would be able to see the name associated with each artboard on the artboard itself. Ideally I could run the script once (i.e. "turn it on"), have it populate all the text boxes with the artboard names, and then have it dynamically update the textboxes when I change an artboard name regardless of whether the file has been closed and opened since I originally ran the script.