-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSaveAsPdf-Mobile.jsx
57 lines (40 loc) · 1.55 KB
/
SaveAsPdf-Mobile.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#target illustrator
var sourceFolder = Folder.selectDialog( "Select the folder", "~" );
var distFolder = new Folder( sourceFolder.absoluteURI + "-pdf" );
distFolder.create();
var files = sourceFolder.getFiles( "*.ai" );
for ( i = 0; i < files.length; i++ )
{
app.open(files[i]);
app.activeDocument.selectObjectsOnActiveArtboard();
app.activeDocument.fitArtboardToSelectedArt(0);
var mast = app.activeDocument.layers.add();
mast.name = 'background';
var r = app.activeDocument.artboards[0].artboardRect;
var background = app.activeDocument.pathItems.rectangle(r[1], r[0], r[2]-r[0], r[1]-r[3]);
background.strokeWidth = 0;
background.stroked = false;
var col = new CMYKColor();
col.cyan = 0;
col.magenta = 0;
col.yellow = 5;
col.black = 0;
//background.filled = true;
background.fillColor = col;
//background.strokeColor = col;
//redraw();
for ( var k = 1; k < app.activeDocument.layers.length; k++ )
mast.move( app.activeDocument.layers[k], ElementPlacement.PLACEATEND );
var file_name = app.activeDocument.name.toString().replace(".ai", "");
var options = new PDFSaveOptions();
options.pDFPreset = "[High Quality Print]"
options.acrobatLayers = false;
options.optimization = true;
options.colorDownsampling = 0;
options.colorCompression = CompressionQuality.ZIP8BIT;
options.compatibility = PDFCompatibility.ACROBAT8;
options.generateThumbnails = false;
options.preserveEditability = false;
app.activeDocument.saveAs( new File(distFolder + "/" + file_name), options );
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}