Copy link to clipboard
Copied
Hi ALL,
Trying Script:
By using inbuilt script "PlaceMultipagePDF.jsx" import all the pdf in the selected folder (i.e., 111.pdf, 222.pdf, 333.pdf) in the "test.indt"
But my requirement:
1. open test.indt file and import 111.pdf alone after that close with any file naming.
2. open test.indt file and import 222.pdf after that close with any file naming.
3. open test.indt file and import 333.pdf after that close with any file naming.
Trying Script Code:
var myFolder = Folder.selectDialog("Select the folder containing the Indesign Files", "");
var myIFiles = myFolder.getFiles("*.indt")
for(j=0; j<myIFiles.length; j++)
{
var myIndesignFile = myIFiles
app.open(myIndesignFile)
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
var myFolder = Folder.selectDialog("Select the folder containing the PDF Files", ""); //Please check this line
var myFiles = myFolder.getFiles("*.pdf")
for(i=0; i<myFiles.length-1; i++)
{
var myPDFFile= myFiles
var myDocument = app.documents[0];
if(myDocument == true){
var myPage = myChoosePage(myDocument);
}
else{
myPage = myDocument.pages.item(0);
}
myPlacePDF(myDocument, myPage, myPDFFile);
}
}
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);
}
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])[0]; //check this line
if(myCounter == 1){
var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
}
else{
if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){
myPage.remove();
myBreak = true;
}
}
myCounter = myCounter + 1;
}
}
Can anyone give solution for my question.
Thanks
BEGINNER
Hi,
Try b/m code
...
var myFolder = Folder.selectDialog("Select the folder containing the Indesign Files", "");
var myIFiles = myFolder.getFiles("*.indt")
for(j=0; j<myIFiles.length; j++)
{
var myIndesignFile = myIFiles
; app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
var myFolder = Folder.selectDialog("Select the folder containing the PDF Files", ""); //Please check this line
var myFiles = myFolder.getFiles("*.pdf")
for(i=0; i <= myFiles.length-1; i++
Copy link to clipboard
Copied
Hi,
Try b/m code
var myFolder = Folder.selectDialog("Select the folder containing the Indesign Files", "");
var myIFiles = myFolder.getFiles("*.indt")
for(j=0; j<myIFiles.length; j++)
{
var myIndesignFile = myIFiles
; app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
var myFolder = Folder.selectDialog("Select the folder containing the PDF Files", ""); //Please check this line
var myFiles = myFolder.getFiles("*.pdf")
for(i=0; i <= myFiles.length-1; i++)
{
app.open(myIndesignFile);
var myPDFFile= myFiles;
var myDocument = app.documents[0];
if(myDocument == true){
var myPage = myChoosePage(myDocument);
}
else{
myPage = myDocument.pages.item(0);
}
myPlacePDF(myDocument, myPage, myPDFFile);
if(app.activeDocument.modified == true){
app.activeDocument.save(new File(String(myFiles).replace('.pdf','') + ".indd"));
app.activeDocument.save();
app.activeDocument.close()
}
}
}
--
Thanks
Bala...
Copy link to clipboard
Copied
Hi Bala,
Thanks a lot.....
Its really helpful for me.
Copy link to clipboard
Copied
I made a few modifications to make this work for me.
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])[0]; //check this line
if(myCounter == 1){
var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
}
else{
if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){
myPage.remove();
myBreak = true;
}
}
myCounter = myCounter + 1;
}
}
var myFolder = Folder.selectDialog("Select the folder containing the Indesign Files", "");
var myIFiles = myFolder.getFiles("*.indd");
var files_placed = 0;
for(j=0; j<myIFiles.length; j++)
{
var myIndesignFile = myIFiles[j];
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
var myFolder = Folder.selectDialog("Select the folder containing the PDF Files", String(myIndesignFile)); //Please check this line
var myFiles = myFolder.getFiles("*.pdf");
for(i=0; i < myFiles.length; i++)
{
app.open(myIndesignFile);
var myPDFFile= myFiles[i];
var myDocument = app.documents[0];
new_page = myDocument.pages.add();
myPlacePDF(myDocument, new_page, myPDFFile);
files_placed++;
}
}
alert("Complete. " + files_placed + " files placed.");
Copy link to clipboard
Copied
Hi Bala,
Please help!
open test.indt file and import pdf alone with there trim size after that close with crop size placed pdf file naming.
Example:
I have folder with different size 1, 2 or 3 page pdfs. I need to place in .indt file with respective pdf trim size with cropped size placed.
I am getting error message in indesign CC15 and CC18.
Thanks
Sachin