main();
function main(){
var selectFile = File.openDialog ("选择 PDF...", "*.pdf");
var pageCount = prompt('请输入总页数','');
var pt = 72/25.4;
var k=0;
var spaceHorizontal = 400;
var spaceVertical = 350;
var rc = getRC(pageCount);
for(r=0;r<rc.r;r++){
for(c=0;c<rc.c;c++){
k++;
var pdfOptions = app.preferences.PDFFileOptions;
pdfOptions.pageToOpen = k;//此处选择置入页码
var myPlacedItem = app.activeDocument.placedItems.add();
myPlacedItem.file = selectFile;
var w = myPlacedItem.width/pt;
var h = myPlacedItem.height/pt;
myPlacedItem.position = Array(r*(w+spaceHorizontal)*pt,c*(h+spaceVertical)*pt);
myPlacedItem.embed(); //置入
}
}
}
function getRC(pageCount){
var a = Math.round(Math.sqrt(pageCount));
for(var i=0;i<10;i++){
var b = pageCount/(a+i);
if(b === Math.round(b)){
return {r:b,c:pageCount/b}
}
}
return {r:1,c:pageCount}
}
Illustrator js 脚本 导入多页Pdf
最新推荐文章于 2024-08-16 08:21:27 发布