photoshop javascript实现文件夹下的jpg批量导出pdf
- 编辑工具(Adobe ExtendScript Toolkit CC)
var inputFolder = Folder.selectDialog("选择导入的文件夹:");
var outputFolder = Folder.selectDialog("请选择输出的文件夹:");
var maxWidth = 0;
var totalHeight = 0;
var fileList = inputFolder.getFiles();
for (var i = 0; i < fileList.length; i++) {
if (fileList[i] instanceof File && fileList[i].hidden == false) {
var doc = app.open(fileList[i]);
var newname = app.activeDocument.name.substr(0, app.activeDocument.name.lastIndexOf("."));
totalHeight = doc.height;
maxWidth = doc.width;
doc.close();
var pdfDoc = app.documents.add(maxWidth, totalHeight, 72, "myPDF", NewDocumentMode.RGB);
if (fileList[i] instanceof File && fileList[i].hidden == false) {
var doc1 = app.open(fileList[i]);
doc1.activeLayer.copy();
app.activeDocument = pdfDoc;
app.activeDocument.paste();
var bounds = app.activeDocument.activeLayer.bounds;
app.activeDocument.activeLayer.translate(0, 0 - parseInt(bounds[1]));
doc1.close();
}
var file = new File(outputFolder + "/" + newname + ".pdf");
var options = new PDFSaveOptions();
pdfDoc.saveAs(file, options, true, Extension.LOWERCASE);
pdfDoc.close(SaveOptions.DONOTSAVECHANGES);
}
}