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

Java Script for resizing the canvas

New Here ,
Jun 23, 2023 Jun 23, 2023

When I open EPS-files generated by Avid Sibelius Notation the canvas size is very small and I need it to be A4-size (210x297 mm). Since I have many files (one for each page) I'm trying to write a script that resize the canvas size, but I have had no luck. I encl. Demo_0002.eps which is the file from Sibelius, and Demo_0002_edited how I would like it to be as A4. Is there anyone that could give me some advice on how to resize the canvas using scripts? The exact placement of the music on the page is more difficult and I assume it needs to be done by hand.

Thanks in advance.

TOPICS
How-to , Scripting
449
Translate
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
Adobe
Community Expert ,
Jun 23, 2023 Jun 23, 2023

Questions:

Is the (old) artboard always centred on the artwork?


Is it important to always bring the staves (the line grid of the musical notes) to the same position (in Y)? Because depending on the type of notes in the top and bottom staves, the position in Y will differ slightly on each new page! in this case: Is it possible to automatically isolate the staves in a separate group?

Translate
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 ,
Jun 23, 2023 Jun 23, 2023
LATEST

You can try the following code:

// artboard_create-new-A4-artboard-based-on-center-of-the-existing-artboard_0.jsx
// provided: There is only one artboard , centred on your entire artwork.

// regards pixxxelschubser 24-06-2023

var aDoc =app.activeDocument;

var ab_0 = app.activeDocument.artboards[0];
var abBounds = ab_0.artboardRect;
var ableft = abBounds[0];
var abtop = abBounds[1];
var abright = abBounds[2];
var abbottom = abBounds[3];

// calculate the new size based on the center of the old artboard
var abcenterX = ableft + (abright-ableft)/2;
var abcenterY = abbottom + (abtop-abbottom)/2;
A4_xHalf = 595.275590551180/2;
A4_yHalf = 841.889763779528/2;

abBounds[0] = abcenterX - A4_xHalf;
abBounds[1] = abcenterY + A4_yHalf;
abBounds[2] = abcenterX + A4_xHalf;
abBounds[3] = abcenterY - A4_yHalf;

// create the new a4 artboard
var ab_1 = activeDocument.artboards.add(abBounds);

// remove the old artboard if you want - or comment out the following line
ab_0.remove();

 

If that works for you
have fun

😉

Translate
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