Copy link to clipboard
Copied
I am utilizing the AWESOME script created by CarlosCanto.... THANK YOU SO MUCH by the way!!!
Open multipage PDF | Ai Scripts
I was wondering if someone could help me figure out how to scale the pages (and corresponding art boards)?
and also have an option to rotate the pages 90 degrees counterclockwise?
Any help or insite would be greatly appreciated.
Thanks in advance and thank you again CarlosCanto!
(working with Windows 7 64 bit, javascript, Illustrator CS4)
Copy link to clipboard
Copied
wolfeEditio, hello!
CS4 is very sad ...
Please describe, in detail, how and what to do. You can attach the original file and the final result.
Copy link to clipboard
Copied
CS4 is what my work gives me so.....
I want to open a multipage pdf file. Ask the user if each page should be rotated 90 degree counterclockwise. Have it scale each page down 50% then lay each page side by side. No more than 4 pages per row of pages.
Here is a link where you can download the multipage pdf example.... The desired final .ai file and the script as it sits now...(again all credit to carlosCanto)
Copy link to clipboard
Copied
Resize (with scale factor 50%) and rearrange (in 4 columns):
//@target illustrator
(function processArtbs () {
var doc = activeDocument,
lays = doc.layers,
i, j,
artbs = [],
gap = 10, x = 0, y = 0,
columns = 4,
scaleFactor = 50;
for (var i = 0; i < activeDocument.artboards.length; i++) {
var obj = activeDocument.artboards;
artbs.push (obj);
}
for (i = 0; i < lays.length; i++) {
var lay = lays;
lay.groupItems[0].resize (scaleFactor, scaleFactor, true, true, true, true, scaleFactor, Transformation.CENTER);
}
for (i = lays.length - 1 , j = 1; i >= 0; i--, j++) {
var gr = lays.groupItems[0];
gr.position = [x, y];
if (!(j % columns)) {
y = gr.geometricBounds[3] - gap;
x = 0;
} else {
x += gr.width + gap;
}
}
for (i = 0; i < lays.length; i++) {
var lay = lays;
doc.artboards.add (lay.groupItems[0].geometricBounds);
}
for (i = artbs.length - 1; i >= 0; i--) {
artbs.remove ();
}
} ());
I can not test in Illustrator cs4. In Illustrator CC-2015 it works. I used the only Illustrator cs4 functional. But I doubt in coordinates calculation.
Copy link to clipboard
Copied
Resize (scale factor 50%) + rotate 90° counterclokwise + arrange (in 4 columns):
//@target illustrator
(function processArtbs () {
var doc = activeDocument,
lays = doc.layers,
i, j,
artbs = [],
gap = 10, x = 0, y = 0,
columns = 4,
scaleFactor = 50,
angle = 90;
for (var i = 0; i < activeDocument.artboards.length; i++) {
var obj = activeDocument.artboards;
artbs.push (obj);
}
for (i = 0; i < lays.length; i++) {
var lay = lays;
lay.groupItems[0].resize (scaleFactor, scaleFactor, true, true, true, true, scaleFactor, Transformation.CENTER);
}
for (i = 0; i < lays.length; i++) {
var lay = lays;
lay.groupItems[0].rotate (angle, true, true, true, true, Transformation.CENTER);
}
for (i = lays.length - 1 , j = 1; i >= 0; i--, j++) {
var gr = lays.groupItems[0];
gr.position = [x, y];
if (!(j % columns)) {
y = gr.geometricBounds[3] - gap;
x = 0;
} else {
x += gr.width + gap;
}
}
for (i = 0; i < lays.length; i++) {
var lay = lays;
doc.artboards.add (lay.groupItems[0].geometricBounds);
}
for (i = artbs.length - 1; i >= 0; i--) {
artbs.remove ();
}
} ());
Offcouse, this script should be run after the opening of a multi-page pdf
Copy link to clipboard
Copied
Ok so this works on my sample file. When I run it on an actual document I need I get these results....
Here is after running Carlos's script...
Here is after I run your script....
I figured it was because some of the pages were hanging off the Illustrator workspace?? Which is why I wanted it to scale before it sorts. Any ideas?
Here is a link to another example file after Carlo's script (before running your script)...
Stripped - Example.ai - Google Drive
Thank you sooo much for your help!
Copy link to clipboard
Copied
And is there in CS4 this menu item: "Object> Artboards> Rearrange ..."?
Or in the Artboards panel menu?
Before starting my script run Rearrange, then the artboards will move to the work area and the script will work normally.
Copy link to clipboard
Copied
Yeah there is no option for that in CS4. HHHhhhmmmm
Copy link to clipboard
Copied
I'm installed Illustrator CS4 for testing. This code requires significant improvement, but in your last example works correctly.
//@target illustrator-14
(function processArtbs () {
setMaxZero ();
var i, j,
d = activeDocument,
lays = d.layers,
groups = [],
tmpLay = d.layers.add (),
artbs = [],
gap = 10,
x = 0,
y = 0,
columns = 4,
scaleFactor = 50,
angle = 90;
for (i = 0; i < activeDocument.artboards.length; i++) {
var obj = activeDocument.artboards;
artbs.push (obj);
}
for (i = 0; i < d.groupItems.length; i++) {
groups.push (d.groupItems);
}
var mainGr = tmpLay.groupItems.add ();
for (i = 0; i < groups.length; i++) {
var obj = groups;
obj.move (mainGr, ElementPlacement.INSIDE);
}
mainGr.position = [mainGr.groupItems[0].height / 2, mainGr.groupItems[0].height / 2];
try {
for (i = 1, j = 0; i < activeDocument.layers.length; i++, j++) {
var obj2 = activeDocument.layers;
groups
.move (obj2, ElementPlacement.INSIDE); }
} catch (e) {
}
for (i = 0; i < groups.length; i++) {
var obj3 = groups;
obj3.rotate (angle, true, true, true, true, Transformation.CENTER);
}
tmpLay.remove ();
for (i = 0; i < lays.length; i++) {
var lay = lays;
lay.groupItems[0].resize (scaleFactor, scaleFactor, true, true, true, true, scaleFactor, Transformation.TOPLEFT);
}
for (i = lays.length - 1 , j = 1; i >= 0; i--, j++) {
var gr = lays.groupItems[0];
gr.position = [x, y];
if (!(j % columns)) {
y = gr.geometricBounds[3] - gap;
x = 0;
} else {
x += gr.width + gap;
}
}
for (i = 0; i < lays.length; i++) {
var lay = lays;
d.artboards.add (lay.groupItems[0].geometricBounds);
}
for (i = artbs.length - 1; i >= 0; i--) {
artbs.remove ();
}
/**LIB*/
function setMaxZero () {
var d = activeDocument,
rect = d.pathItems.rectangle (0, 0, 16000, 16000),
artbMax,
screenModeStore = d.views[0].screenMode;
rect.stroked = false;
rect.selected = true;
cut ();
d.views[0].screenMode = ScreenMode.FULLSCREEN;
d.views[0].zoom = 64;
d.views[0].zoom = 0.0313;
paste ();
rect = selection[0];
artbMax = d.artboards.add (rect.geometricBounds);
d.rulerOrigin = [0, d.height];
d.artboards[d.artboards.getActiveArtboardIndex ()].rulerOrigin = [0, 0];
rect.remove ();
artbMax.remove ();
d.views[0].screenMode = screenModeStore;
}
} ());
I'm sorry for this agly sheet. I will try to fix soon. %\