var pdfs = File.openDialog( "Выберите pdf для импорта", "Files: *.pdf", true );
if( pdfs.length ){
for (var i = 0; i < pdfs.length; i++) {
page = i == 0 ? app.documents[0].pages[0] : app.documents[0].pages.add();
myPlacePDF( app.documents[0], page, pdfs[i] );
}
}
function myPlacePDF(myDocument, myPage, myPDFFile){
var myPDFPage;
app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
var myCounter = 1;
while(true){
if(myCounter > 1){
myPage = myDocument.pages.add(LocationOptions.after, myPage);
}
app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
if(myCounter != 1 && myPDFPage.pdfAttributes.pageNumber == 1){
myPage.remove();
break;
}
myCounter++;
}
}