• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Setting the bleed in AI via Javascript

Community Beginner ,
Apr 05, 2017 Apr 05, 2017

Copy link to clipboard

Copied

Hi All,

I'm writing a function to change the artboard size and add bleed depending on certain conditions.

I can't actually believe this is causing me trouble but here it is, I'm trying to set the bleed dimensions in AI document with Javascript. All I've found so far is setting up PDF export options or print options, but not the actual artboard Document Setup. I just want to be able to set bleed to a newly created document like in this window:

So similar to Indesign:

with(myDocument.documentPreferences){

  documentBleedUniformSize = true;

  documentBleedTopOffset = 7;

  }

(CC2017)

Screenshot 2017-04-06 15.45.28.png

TOPICS
Scripting

Views

12.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Mar 23, 2018 Mar 23, 2018

Summarizing best solution by far: we can change bleed size using preinstalled plugin.

Windows

https://goo.gl/YE1Vah by tomr11694738​

Drop plugin in ProgramFiles\Adobe\Adobe Illustrator\Plug-ins\Extensions. Use following code to run it:

app.sendScriptMessage ("My_plugin_name", "mySelector", bleeds);

where bleeds is bleedoffset in points.

Mac

GitHub - ten-A/Bleed by Ten A​

All hail to these two dudes.

Votes

Translate

Translate
Adobe
Valorous Hero ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

That's a good question, I can't find it!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

Save as PDF with Bleed...then re Save as Ai

 

[edit: please ignore, I should have tested it before posting]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 09, 2017 Apr 09, 2017

Copy link to clipboard

Copied

Yes, problem is even setting it up for pdf export does absolutely nothing.

var dest = "~/Desktop/testme1.pdf";

var doc = app.activeDocument;

var myFile = new File(dest);

var saveOpts;

setSaveOptions();

saveFileToPDF(myFile);

function saveFileToPDF(myFile){

    var originalInteractionLevel = userInteractionLevel;     

    userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;  

    doc.saveAs(myFile,saveOpts);    

    userInteractionLevel = originalInteractionLevel;    

}

function setSaveOptions(){

    saveOpts = new PDFSaveOptions();

    saveOpts.compatibility = PDFCompatibility.ACROBAT5;

    saveOpts.generateThumbnails = true;

    saveOpts.optimization = true;

    saveOpts.preserveEditability = true;

    saveOpts.bleedOffsetRect = [2,2,2,2];

    saveOpts.trimMarks = true;

}

After this media box is the size of trim marks but the art is cropped to the Artboard size, (not +2).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Bump,

Is there really no way to do this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

We must not give up the search

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 15, 2017 Apr 15, 2017

Copy link to clipboard

Copied

Matts, do you have Windows system? I can try to make a Win plugin which can be used by your script.

Well, to be honest, I made the one for testing purpose.The plugin sets bleeds from txt file.

You write some number to txt file with  script, run action, bleeds change - voila.

But if you don't have win system, there's no point uploading this plugin.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

What is a difference which would make your plugin Windows-only? To make it for Macs, would the entire code need to be re-written, or only certain parts?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

The difference is I can compile for Windows only

But the C++ code for Mac should be the same.

The meaningful part of code is below.

int bleedOffset; //let the bleed be integer, why not

    ifstream infile ("C:\\Tom_Subscriber\\data.txt"); //read the number from txt file. It's presumed that JS script has already written  the number into it;

    infile >> bleedOffset;

  

    AIRealRect myRect;

//lets make bleeds symmetrical

    myRect.right = bleedOffset;

    myRect.left = bleedOffset;

    myRect.top = bleedOffset;

    myRect.bottom = bleedOffset;

    error = sAIDocument->SetDocumentBleeds (myRect); // command to set bleeds.

As you can see, there's no dialog, input from txt file.

The plugin adds a command to the Objects menu.

Screenshot_2.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

Okay thank you for showing this. So, can you also say one more thing, which is: in order to make this in Mac, what would you need to do to be able to compile? You'd have to buy a mac computer?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 16, 2017 Apr 16, 2017

Copy link to clipboard

Copied

The other option is to install Xcode in virtual machine or Hackintosh.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 17, 2017 Apr 17, 2017

Copy link to clipboard

Copied

Hi, instead of read data from file, is it possible to sendScriptMassage to your plugin in script, so the plugin can use received data to do the job automatically?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 17, 2017 Apr 17, 2017

Copy link to clipboard

Copied

Never used sendScriptMessage, need to take a look.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

"Make Javascript great again!"

That was hard, but once made, always can be made.

Screenshot_3.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

This is magic Tom, how do I use it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 19, 2017 Apr 19, 2017

Copy link to clipboard

Copied

Good news is that it's possible to implement for scripting any feature, offered by SDK(pixel calculation, dividing bezier curves, finding duplicates etc).

For example, you can write pixel calculation in plugin, make it available for scriptmessage. Then you just run, say, such a string:

colorTextString = app.sendScriptMessage ("PluginName", "Calculate_average", "");

and get average color for gradient object or rasterimage (in text string, but it's no problem to parse it).

Keep in mind, that sendscriptmessage can not only send information to plugin, but also receive.

Bad news: plugins are platform-dependent and currently I can compile for Win only.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 19, 2017 Apr 19, 2017

Copy link to clipboard

Copied

I like the good news . So is it possible to implement these missing features, that Adobe do not provide, all in one plugin(say, call it ScriptingHelper), for the rest of us?

If true, maybe it's time for us to vote which features should be added prior to others.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 19, 2017 Apr 19, 2017

Copy link to clipboard

Copied

2moluaple:

Seems it's possible (with native limitations of SDK).

The code in C++ is simple:

if (strcmp(selector, "Selector1") == 0){

//do one function

}

else if (strcmp(selector, "Selector2") ==0)

{

//do 2nd

}

etc.

So one can just send different selectors to plugin to run different functions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2017 Apr 19, 2017

Copy link to clipboard

Copied

agree with others, this is fantastic and promising. Thanks for sharing tom.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 19, 2017 Apr 19, 2017

Copy link to clipboard

Copied

Keep in mind, that sendscriptmessage can not only send information to plugin, but also receive.

Cool, this means that a script can know whether a plugin action was successful and other data, in order to proceed with the script logic. Something that is not inherently available for use in app.executeMenuCommand() and Actions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

Tom, so could you send a link to compiled plugin version where I could send bleed size via app.sendScriptMessage?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 23, 2018 Mar 23, 2018

Copy link to clipboard

Copied

Win64, CC-CC2015.

https://goo.gl/YE1Vah

Usage:

app.sendScriptMessage ("My_plugin_name", "mySelector",  15); // where 15  is bleedoffset in points.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 23, 2018 Mar 23, 2018

Copy link to clipboard

Copied

Hi, Here is a full codes for Macintosh.

GitHub - ten-A/Bleed

Thank you you for your snipet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 23, 2018 Mar 23, 2018

Copy link to clipboard

Copied

HOw much would it cost for you guys to do all the hard work and make me a plugin for both Windows and Mac that we can send our requests for and you add those commands to the plugin?

We need bleeds, we need other impossible stuff like seeing in some art has an opacity mask on it or not (without undoing the mask via actions, etc etc).

I mean, I think I can maybe learn how to finally set up my xcode, and hopefully I soon will to try these babies out!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 24, 2018 Mar 24, 2018

Copy link to clipboard

Copied

check_opacity_mask.gif

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines