Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Acrobat document resizing

New Here ,
Nov 01, 2016 Nov 01, 2016

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?

TOPICS
Acrobat SDK and JavaScript
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2016 Nov 01, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 01, 2016 Nov 01, 2016

Can you please give me little more insight on this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2016 Nov 01, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 01, 2016 Nov 01, 2016

Thanks George for your feed back. I know how to do this manually, I have a bunch of PDFs with single pages. I am trying to find out an automated system such as applescript or JavaScript for the ongoing solution.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2016 Nov 01, 2016

Yes, I'm willing to show you how, but it would be helpful if you provided the information I asked about. The details are important.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 01, 2016 Nov 01, 2016

Yes. It is single page document. I want to add 1/2 inch each on all four sides. meaning currently, it is 7.5x10 inches and want to get it as 8.5x11. thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 01, 2016 Nov 01, 2016

Here's a basic script that should help you get started. It adds 1/2 inch to all sides of the page and assumes the page isn't rotated.

// Get the rect (left, top, right, bottom) for the media box of the current page

var aRect = getPageBox({cBox: "Media", nPage: 0});

// Set the  increment value, in points (72 points/inch)

var inc = 0.5 * 72;

// Set a new media box

setPageBoxes({cBox: "Media", nStart: 0, nEnd: numPages - 1, rBox: [aRect[0] - inc, aRect[1] + inc, aRect[2] + inc, aRect[3] - inc]});

You can run this script in the interactive JavaScript console (command + J), in a custom action, custom toolbar or menu item, etc. Post again if you need more help and consulting the Acrobat JavaScript reference is always a good idea.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 02, 2016 Nov 02, 2016

Thanks George, I think I am very close. I am getting the following error.

ReferenceError: aRect is not defined

1:Console:Exec

undefined

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 02, 2016 Nov 02, 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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2016 Nov 02, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 02, 2016 Nov 02, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 02, 2016 Nov 02, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines