Skip to main content
JKuruvilla
Participating Frequently
November 1, 2016
Question

Acrobat document resizing

  • November 1, 2016
  • 3 replies
  • 1635 views

Hello,

I want to use an applescript to resize my acrobat document (JavaScript also will do). Note that, this is not crop. My current document size is 7.5 inch x 10 inch and I want to make it 8.5 inch x 11 inch. This function available in crop tool (Set Page Boxes/Change Page size/Custom) if I want to do manually. Any help please?

This topic has been closed for replies.

3 replies

Inspiring
November 2, 2016

When you execute it in the console, you have to select all of it and press command+return.

JKuruvilla
Participating Frequently
November 2, 2016

Thanks George. This works Good. One more question. How can I put this in loop? so that, I can select a bunch of PDFs, run at one time. Probably, an external script? how that will work?

Inspiring
November 2, 2016

That what custom Actions are for. You can set one up with a single JavaScript action and process the files you select when you trigger the action. You should be able to find more information on creating and using Action in Acrobat with a search.

Participant
November 2, 2016

  pageCnt = this.numPages;

  // calc target dim in pt

  var targetPageWidth = nSiX * 72 / 25.4;

  var targetPageHeight = nSiY * 72 / 25.4;

  t.duration = pageCnt;

  t.begin();

  for (var i = 0; i < pageCnt; i++ ){

  t.value = i;

  t.text = "Зміна розміру сторінки " + (i + 1);

  // для MediaBox

  var oRect = this.getPageBox("Media", i);// get old value of MediaBox

  // розрахувати різницю

  var mediaBox_dX = (targetPageWidth - oRect[2] - oRect[0]) / 2;

  var mediaBox_dY = (targetPageHeight - oRect[1] - oRect[3]) /2;

  // set new dimentions

  this.setPageBoxes({

  cBox: "Media",

  nStart: i,

  rBox:[

  oRect[0] - mediaBox_dX,

  oRect[1] + mediaBox_dY,

  oRect[2] + mediaBox_dX,

  oRect[3] - mediaBox_dY,

  ]

  });

  // для CropBox

  var oRect = this.getPageBox("Crop", i);// get old value of CropBox

  var dX = (targetPageWidth - oRect[2] - oRect[0]) / 2;

  var dY = (targetPageHeight - oRect[1] - oRect[3]) /2;

  // set new dimentions

  this.setPageBoxes({

  cBox: "Crop",

  nStart: i,

  rBox:[

  oRect[0] - dX,

  oRect[1] + dY,

  oRect[2] + dX,

  oRect[3] - dY,

  ]

  });

  // для TrimBox

  var oRect = this.getPageBox("Trim", i);// get old value of TrimBox

  this.setPageBoxes({

  cBox: "Trim",

  nStart: i,

  rBox:[

  oRect[0] + mediaBox_dX,

  oRect[1] + mediaBox_dY,

  oRect[2] + mediaBox_dX,

  oRect[3] + mediaBox_dY,

  ]

  });

  // для BleedBox

  var oRect = this.getPageBox("Bleed", i);// get old value of BleedBox

  this.setPageBoxes({

  cBox: "Bleed",

  nStart: i,

  rBox:[

  oRect[0] + mediaBox_dX,

  oRect[1] + mediaBox_dY,

  oRect[2] + mediaBox_dX,

  oRect[3] + mediaBox_dY,

  ]

  });

  // для ArtBox

  var oRect = this.getPageBox("Art", i);// get old value of ArtBox

  this.setPageBoxes({

  cBox: "Art",

  nStart: i,

  rBox:[

  oRect[0] + mediaBox_dX,

  oRect[1] + mediaBox_dY,

  oRect[2] + mediaBox_dX,

  oRect[3] + mediaBox_dY,

  ]

  });

  }

  t.end();

Inspiring
November 1, 2016

With JavaScript you'd use the setPagesBoxes method to first set the media box to the size you want and then set the crop box to match.

JKuruvilla
Participating Frequently
November 1, 2016

Can you please give me little more insight on this?

Inspiring
November 1, 2016

Exactly how do you want to go from 7.5 x 10 to 8.5 x 11? It might be by adding an inch to the right side, or 1/2 inch to both the left and right sides. Same thing for the top and bottom.

Also, do you want to do this for every page in the document, or just certain ones?