Copy link to clipboard
Copied
I have an Illustrator script that opens a number of illustrator files and exports them as jpgs. I now want to add them into a single pdf file - preferably from within the same illutrator script.
So e.g. add fish1.jpg and fish2.jpg into one two page pdf called fish.pdf
Many thanks
This should create a PDF Presentation in Photoshop via BridgeTalk, thePath and theFiles need to be amended naturally:
var thePath = "~/Desktop/aPdfPresentation.pdf";
var theFiles = ["~/Desktop/gradient01.jpg", "~/Desktop/gradient02.jpg"];
saveAsPdfPresentationFromIllustrator (theFiles, thePath);
////// save pdf presentation //////
function saveAsPdfPresentationFromIllustrator (theFiles, thePath) {
// the bridgetalk;
var bt = new BridgeTalk;
bt.target = 'photoshop';
var myScript = 'app.bringToFr
...
Copy link to clipboard
Copied
Seems more of a job for InDesign. Or Word. Or Acrobat.
Copy link to clipboard
Copied
Even Photoshop might work out and like Indesign it could be addressed via BridgeTalk.
Copy link to clipboard
Copied
Hi - the script does a whole load of things like opening multiple illustrator files, hiding layers and exporting a number of jpegs that need to be rotated (new Illustrator functionality! now allows this so the jpegs are the right way up) and combined into a pdf for customer approval. So the final step would be easy I guess in acrobat but can it be done from the Illustrator scripting engine? Haven't used BridgeTalk - is this the way to go?
Thanks
Copy link to clipboard
Copied
This should create a PDF Presentation in Photoshop via BridgeTalk, thePath and theFiles need to be amended naturally:
var thePath = "~/Desktop/aPdfPresentation.pdf";
var theFiles = ["~/Desktop/gradient01.jpg", "~/Desktop/gradient02.jpg"];
saveAsPdfPresentationFromIllustrator (theFiles, thePath);
////// save pdf presentation //////
function saveAsPdfPresentationFromIllustrator (theFiles, thePath) {
// the bridgetalk;
var bt = new BridgeTalk;
bt.target = 'photoshop';
var myScript = 'app.bringToFront();\n';
var theString = "[\""+String(theFiles.join("\",\""))+"\"]";
myScript += 'var theFiles = '+String(theString)+';\n';
myScript += 'var thePath = \"'+String(thePath)+'\";\n';
myScript += ' var idPDFExport = stringIDToTypeID( "PDFExport" );\n';
myScript += ' var desc1 = new ActionDescriptor();\n';
myScript += ' var idflst = charIDToTypeID( "flst" );\n';
myScript += ' var list1 = new ActionList();\n';
myScript += ' for (var m = 0; m < theFiles.length; m++) {\n';
myScript += ' list1.putPath( new File( theFiles[m] ) );\n';
myScript += ' };\n';
myScript += ' desc1.putList( idflst, list1 );\n';
myScript += ' var idT = charIDToTypeID( "T " );\n';
myScript += ' desc1.putPath( idT, new File( thePath ) );\n';
myScript += ' var idincludeAnnotations = stringIDToTypeID( "includeAnnotations" );\n';
myScript += ' desc1.putBoolean( idincludeAnnotations, true );\n';
myScript += ' var idBckC = charIDToTypeID( "BckC" );\n';
myScript += ' var idBckC = charIDToTypeID( "BckC" );\n';
myScript += ' var idWht = charIDToTypeID( "Wht " );\n';
myScript += ' desc1.putEnumerated( idBckC, idBckC, idWht );\n';
myScript += ' var idAs = charIDToTypeID( "As " );\n';
myScript += ' var desc2 = new ActionDescriptor();\n';
myScript += ' var idpdfPresetFilename = stringIDToTypeID( "pdfPresetFilename" );\n';
myScript += ' desc2.putString( idpdfPresetFilename, "High Quality Print" );\n';
myScript += ' var idpdfPreserveEditing = stringIDToTypeID( "pdfPreserveEditing" );\n';
myScript += ' desc2.putBoolean( idpdfPreserveEditing, false );\n';
myScript += ' var idpdfDownSample = stringIDToTypeID( "pdfDownSample" );\n';
myScript += ' var idpdfDownSample = stringIDToTypeID( "pdfDownSample" );\n';
myScript += ' var idNone = charIDToTypeID( "None" );\n';
myScript += ' desc2.putEnumerated( idpdfDownSample, idpdfDownSample, idNone );\n';
myScript += ' var idpdfCompressionType = stringIDToTypeID( "pdfCompressionType" );\n';
myScript += ' desc2.putInteger( idpdfCompressionType, 7 );\n';
myScript += ' var idPhtP = charIDToTypeID( "PhtP" );\n';
myScript += ' desc1.putObject( idAs, idPhtP, desc2 );\n';
myScript += ' executeAction( idPDFExport, desc1, DialogModes.NO );\n';
bt.body = myScript;
bt.send(10);
};
Copy link to clipboard
Copied
If I may ask, why do you want to make a pdf from the jpgs and not the vector data?
Copy link to clipboard
Copied
A multi-artboard document can be saved as a multipage PDF. So you can try placing your JPGs in a document, each on an artboard. The following is a basic idea. (Put the paths of your JPGs into the array "a".)
var a = ["fish1.jpg", "fish2.jpg", "fish3.jpg" /*et cetera*/]
var file1 = new File("~/Desktop/" + a[0]);
var pic1 = app.activeDocument.placedItems.add();
pic1.file = file1;
app.activeDocument.artboards[0].artboardRect = pic1.geometricBounds;
for (var i = 1; i < a.length; i++) {
var file2 = new File("~/Desktop/" + a[i]);
var b = app.activeDocument.artboards[i - 1].artboardRect;
var AB = app.activeDocument.artboards.add([b[2], b[1], b[2] + (b[2] - b[0]), b[3]]);
var pic2 = app.activeDocument.placedItems.add();
pic2.file = file2;
pic2.position = [b[2], b[1]];
AB.artboardRect = pic2.geometricBounds;
}
var file3 = new File("~/Desktop/fish");
var PDF = new PDFSaveOptions();
app.activeDocument.saveAs(file3, PDF);