Copy link to clipboard
Copied
I'm working on a new product that utilizes HP's Indigo Printer. Because the printer only uses one size of paper, if we can fit multiple projects on one sheet of paper we can print much more economically and save our clients a lot of money. I know how to use scripts to place multiple images on separate pages but as far as I know, there's no way to specify that they need to be placed differently on a left page as opposed to a right page.
I need a script that would allow me to, for example, specify left justification on a left page, and right justification on the right page. This way when the paper is printed on the opposite side the positioning
is correct.
Ideally, I need a way to just specify an exact placement for each page, left and right, multiple times so that I can easily layout multiple projects on a page, like the image I attached.
Any help or direction would be greatly appreciated!
1 Correct answer
Hi there,
Try this below code for your reference...
...var myDoc = app.documents[0];
var page = myDoc.pages[1];
var folder = 'C:/Users/sunily/Desktop/ProjectImages';
placeAllImages(page, folder);
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
function placeAllImages(myCurrentPage, myFolderPath){
var allFiles = Folder(myFolderPath).getFiles('*png');
for(v
Copy link to clipboard
Copied
Hi there,
Try this below code for your reference...
var myDoc = app.documents[0];
var page = myDoc.pages[1];
var folder = 'C:/Users/sunily/Desktop/ProjectImages';
placeAllImages(page, folder);
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
function placeAllImages(myCurrentPage, myFolderPath){
var allFiles = Folder(myFolderPath).getFiles('*png');
for(var i = 0; i < allFiles.length; i++){
var myImage = myCurrentPage.place(allFiles);
if(allFiles.name.toString().toLowerCase().indexOf('projecta') != -1){
if(myCurrentPage.side.toString().toLowerCase().indexOf('left') != -1){
var myX_Y = getCo_Ordinates(myImage, myCurrentPage, 0);
}
else if(myCurrentPage.side.toString().toLowerCase().indexOf('right') != -1){
var myX_Y = getCo_Ordinates(myImage, myCurrentPage, 1);
}
}
else if(allFiles.name.toString().toLowerCase().indexOf('projectb') != -1){
if(myCurrentPage.side.toString().toLowerCase().indexOf('left') != -1){
var myX_Y = getCo_Ordinates(myImage, myCurrentPage, 2);
}
else if(myCurrentPage.side.toString().toLowerCase().indexOf('right') != -1){
var myX_Y = getCo_Ordinates(myImage, myCurrentPage, 3);
}
}
else if(allFiles.name.toString().toLowerCase().indexOf('projectc') != -1){
if(myCurrentPage.side.toString().toLowerCase().indexOf('left') != -1){
var myX_Y = getCo_Ordinates(myImage, myCurrentPage, 4);
}
else if(myCurrentPage.side.toString().toLowerCase().indexOf('right') != -1){
var myX_Y = getCo_Ordinates(myImage, myCurrentPage, 5);
}
}
myImage[0].parent.move(myX_Y);
}
}
///////////////////////////////////
function getCo_Ordinates(img, page, i){
var x = 0;
var y = 0;
var left = page.marginPreferences.left;
var right = page.marginPreferences.right;
var top = page.marginPreferences.top;
var bottom = page.marginPreferences.bottom;
var docHeight = myDoc.documentPreferences.pageHeight;
var docWidth = myDoc.documentPreferences.pageWidth;
var imgGB = img[0].parent.geometricBounds;
var imgWidth = imgGB[3]-imgGB[1];
var imgHeight = imgGB[2]-imgGB[0];
///////////////////////// you can specify here the x & y co-ordinates where to move your object --------------------------
switch (i){
case 0:
x = 0;
y = 0;
break;
case 1:
x = docWidth-imgWidth;
y = 0;
break;
case 2:
x = docWidth-imgWidth-right;
y = top;
break;
case 3:
x = left;
y = top;
break;
case 4:
x = docWidth-imgWidth-right;
y = docHeight-bottom-imgHeight;
break;
case 5:
x = left;
y = docHeight-bottom-imgHeight;
break;
case 6:
x = 0;
y = 0;
break;
}
return [x,y];
}
Best
Sunil

