Сходи сюда:Stern сказал(а):Единственное неудобство - нет никаких дополнительных параметров. PDF располагается в левом верхнем углу, и так все остальные страницы. А хотелось бы указать конкретное место, где эти страницы должны лежать.
См. 5-й диск дистрибутива CS2:Но есть ли версия скрипта для CS2? Если да - то нужна ссылка на него.
Rem PlaceMultipagePDF.vbs
Rem An InDesign CS script
Rem
Rem Places all of the pages of a multi-page PDF.
Rem
Set myInDesign = CreateObject("InDesign.Application.CS2")
Rem Use JavaScript to display a standard Open File dialog box.
myJavaScript = "myPDFFile = File.openDialog(""Choose a PDF File"");if(myPDFFile != null){myFileName = myPDFFile.fsName}else{myFileName = """"};"
myFileName = myInDesign.DoScript(myJavaScript, idScriptLanguage.idJavascript)
If myFileName <> "" Then
myNewDocument = True
If myInDesign.Documents.Count <> 0 Then
Set myDocument = myChooseDocument(myInDesign, myNewDocument)
Else
Set myDocument = myInDesign.Documents.Add
End If
If myNewDocument = False Then
Set myPage = myChoosePage(myInDesign, myDocument)
Else
Set myPage = myDocument.Pages.Item(1)
End If
myPlacePDF myInDesign, myDocument, myPage, myFileName
End If
Function myChooseDocument(myInDesign, myNewDocument)
ReDim myDocumentNames(0)
myDocumentNames(0) = "New Document"
Rem Get the names of the documents
For myDocumentCounter = 1 To myInDesign.Documents.Count
ReDim Preserve myDocumentNames(UBound(myDocumentNames) + 1)
myDocumentNames(myDocumentCounter) = myInDesign.Documents.Item(myDocumentCounter).Name
Next
Set myChooseDocumentDialog = myInDesign.Dialogs.Add
myChooseDocumentDialog.Name = "Choose a Document"
myChooseDocumentDialog.CanCancel = False
With myChooseDocumentDialog.DialogColumns.Add
With .DialogRows.Add
With .DialogColumns.Add
With .StaticTexts.Add
.StaticLabel = "Place PDF in:"
End With
End With
With .DialogColumns.Add
Set myChooseDocumentDropdown = .Dropdowns.Add
myChooseDocumentDropdown.StringList = myDocumentNames
myChooseDocumentDropdown.SelectedIndex = 0
End With
End With
End With
myChooseDocumentDialog.Show
If myChooseDocumentDropdown.SelectedIndex = 0 Then
Set myDocument = myInDesign.Documents.Add
Else
Set myDocument = myInDesign.Documents.Item(myChooseDocumentDropdown.SelectedIndex)
myNewDocument = False
End If
myChooseDocumentDialog.Destroy
Set myChooseDocument = myDocument
End Function
Function myChoosePage(myInDesign, myDocument)
ReDim myPageNames(0)
Rem Get the names of the pages in the document
For myCounter = 1 To myDocument.Pages.Count
If Not (IsEmpty(myPageNames(0))) Then
ReDim Preserve myPageNames(UBound(myPageNames) + 1)
End If
myPageNames(myCounter - 1) = myDocument.Pages.Item(myCounter).Name
Next
Set myChoosePageDialog = myInDesign.Dialogs.Add
myChoosePageDialog.Name = "Choose a Page"
myChoosePageDialog.CanCancel = False
With myChoosePageDialog.DialogColumns.Add
With .DialogRows.Add
With .DialogColumns.Add
With .StaticTexts.Add
.StaticLabel = "Place PDF on:"
End With
End With
With .DialogColumns.Add
Set myChoosePageDropdown = .Dropdowns.Add
myChoosePageDropdown.StringList = myPageNames
myChoosePageDropdown.SelectedIndex = 0
End With
End With
End With
myChoosePageDialog.Show
Set myPage = myDocument.Pages.Item(myChoosePageDropdown.SelectedIndex + 1)
myChoosePageDialog.Destroy
Set myChoosePage = myPage
End Function
Function myPlacePDF(myInDesign, myDocument, myPage, myFileName)
myInDesign.PDFPlacePreferences.PDFCrop = idPDFCrop.idCropMedia
myCounter = 1
myBreak = False
Do While myBreak = False
If myCounter > 1 Then
myDocument.Pages.Add
End If
myInDesign.PDFPlacePreferences.PageNumber = myCounter
Set myPDFPage = myDocument.Pages.Item(-1).Place(myFileName, Array(0, 0))
If myCounter = 1 Then
myFirstPage = myPDFPage.PDFAttributes.PageNumber
Else
If myPDFPage.PDFAttributes.PageNumber = myFirstPage Then
myDocument.Pages.Item(-1).Delete
myBreak = True
End If
End If
myCounter = myCounter + 1
Loop
End Function
//PlaceMultipagePDF.jsx
//An InDesign CS2 JavaScript
//
//Places all of the pages of a multi-page PDF.
//
//For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting.html
//or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
//
//Display a standard Open File dialog box.
var myPDFFile = File.openDialog("Choose a PDF File");
if((myPDFFile != "")&&(myPDFFile != null)){
var myDocument, myPage;
if(app.documents.length != 0){
myDocument, myNewDocument = myChooseDocument();
}
else{
myDocument = app.documents.add();
myNewDocument = false;
}
if(myNewDocument == false){
myPage = myChoosePage(myDocument);
}
else{
myPage = myDocument.pages.item(0);
}
myPlacePDF(myDocument, myPage, myPDFFile);
}
function myChooseDocument(){
var myDocumentNames = new Array;
myDocumentNames.push("New Document");
//Get the names of the documents
for(var myDocumentCounter = 0;myDocumentCounter < app.documents.length; myDocumentCounter++){
myDocumentNames.push(app.documents.item(myDocumentCounter).name);
}
var myChooseDocumentDialog = app.dialogs.add({name:"Choose a Document", canCancel:false});
with(myChooseDocumentDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Place PDF in:"});
}
with(dialogColumns.add()){
var myChooseDocumentDropdown = dropdowns.add({stringList:myDocumentNames, selectedIndex:0});
}
}
}
myChooseDocumentDialog.show();
if(myChooseDocumentDropdown.selectedIndex == 0){
myDocument = app.documents.add();
myNewDocument = true;
}
else{
myDocument = app.documents.item(myChooseDocumentDropdown.selectedIndex-1);
myNewDocument = false;
}
myChooseDocumentDialog.destroy();
return myDocument, myNewDocument;
}
function myChoosePage(myDocument){
var myPageNames = new Array;
//Get the names of the pages in the document
for(var myCounter = 0; myCounter < myDocument.pages.length;myCounter++){
myPageNames.push(myDocument.pages.item(myCounter).name);
}
var myChoosePageDialog = app.dialogs.add({name:"Choose a Page", canCancel:false});
with(myChoosePageDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Place PDF on:"});
}
with(dialogColumns.add()){
var myChoosePageDropdown = dropdowns.add({stringList:myPageNames, selectedIndex:0});
}
}
}
myChoosePageDialog.show();
var myPage = myDocument.pages.item(myChoosePageDropdown.selectedIndex);
myChoosePageDialog.destroy();
return myPage;
}
function myPlacePDF(myDocument, myPage, myPDFFile){
var myPDFPage;
app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
var myCounter = 1;
var myBreak = false;
while(myBreak == false){
if(myCounter > 1){
myPage = myDocument.pages.add(LocationOptions.after, myPage);
}
app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place(File(myPDFFile), [0,0]);
if(myCounter == 1){
var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
}
else{
if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){
myPage.remove();
myBreak = true;
}
}
myCounter = myCounter + 1;
}
}
OOleg сказал(а):
А это скрипт для CS, который под CS2 не работает!!!OOleg сказал(а):А это что?
Подтверждаю. У меня тоже прекрасно работает под CS2 !!!sakhar сказал(а):А это скрипт для CS, который под CS2 не работает!!!