Copy link to clipboard
Copied
I have a two page document &, I want to use Action Wizard to center the page contents, using an Exectute Javascript command. Unfortunatelly I know nothing about Javascript, can anyone please help me with a script do do this?
All the information on the attached two page pdf is currently aligned to the top left, I cannot adjust how its printed to PDF because it is outputted via an ancient 16bit program.
Thanks, in advance for any help and advice!
John
While JS can't select or move (static) page contents, it can add white-space to a page by setting the page boxes to a different size (ie, cropping it). Try this code to add an half-inch white space to the left side of all the pages in the file (and take it off the right side):
for (var p=0; p<this.numPages; p++) {
var pageBox = this.getPageBox("Crop", p);
var pageWidth = pageBox[2]-pageBox[0];
var pageHeight = pageBox[1]-pageBox[3];
this.setPageBoxes("Crop", p, p, [-36, pageHeight, pageW
...
Duplicate the setPageBoxes command, replacing "Crop" with the these strings:
Art
Bleed
Media
Trim
Thanks for your help again try67
Copy link to clipboard
Copied
Javascript can't select the objects.
Copy link to clipboard
Copied
Oh, is there anyway I can achieve my goal, using the Action wizard, or Js?
I am having to make this process as simple as possible, for someone else to use.
Copy link to clipboard
Copied
While JS can't select or move (static) page contents, it can add white-space to a page by setting the page boxes to a different size (ie, cropping it). Try this code to add an half-inch white space to the left side of all the pages in the file (and take it off the right side):
for (var p=0; p<this.numPages; p++) {
var pageBox = this.getPageBox("Crop", p);
var pageWidth = pageBox[2]-pageBox[0];
var pageHeight = pageBox[1]-pageBox[3];
this.setPageBoxes("Crop", p, p, [-36, pageHeight, pageWidth-36, 0])
}
Copy link to clipboard
Copied
Thanks for the help, that worked a treat!
Copy link to clipboard
Copied
I was a little hasty & didn't spot an issue.
The pdf is 8.27 x 11.69in, but when I run the script it is 8.26 x 11.69in, which is fine, but when I save and reopen the pdf it is 7.96 x 11.44in. How do I maintain the correct page size, when I re-open the document ?
I modified try67's script slightly to:-
/* Re-position Dathan1 */
for (var p=0; p<this.numPages; p++) {
var pageBox = this.getPageBox("Crop", p);
var pageWidth = pageBox[2]-pageBox[0];
var pageHeight = pageBox[1]-pageBox[3];
this.setPageBoxes("Crop", p, p, [-22, pageHeight+18, pageWidth-22, +18])
}
Thanks in advance.
John
Copy link to clipboard
Copied
You might have to change the other page boxes, too, such as Trim, Art and Media.
Copy link to clipboard
Copied
Hi try67 thanks for the quick reply.
I'm new to all this & know nothing about JS. How do I change the other page boxes?
I just tried changing the scripts "Page" to Media, Art & Trim, but that didn't work.
Copy link to clipboard
Copied
Duplicate the setPageBoxes command, replacing "Crop" with the these strings:
Art
Bleed
Media
Trim
Copy link to clipboard
Copied
Thanks for your help again try67