Every document I run the script, the height changes to 35 cm and the width remains the same.
I have a document size 10 width by 21 height, I want to change the height to 35.
The media size, not the crop size.
Document size 15 width by 20 height, I want to change the height to 35.
The script will be inside the menu in Acrobat.
Copy link to clipboard
When you say you want the height changed, are you wanting the contents of the page to change?
Only to add white up and down
Can you help me with that?
Copy link to clipboard
You can use this code to do it:
var pageBox = this.getPageBox("Media", this.pageNum); var pageWidth = pageBox-pageBox; var newPageBox = [0, pageWidth, 35*28.3465, 0]; this.setPageBoxes("Media", this.pageNum, this.pageNum, newPageBox);
Yes, the code only changes the height. However, you can use the same technique shown in the code for the height, to change the width.
Here is an article on how to add a menu item to Acrobat:
I could not put it in the menu menu
And I think it changes the width and not the height.
If anything can help me - in both things - I would be very grateful to him.
@Thom Parker has pointed you to a page the provides all the steps to add a menu item, if you have given it a shot and it is not working, post the code here and we can take a look to see if we can spot an issue.
For the crop box change the word "Media" to "Crop" in the this.setPageBoxes method call.
And for the width change the other paramter the is "pageWidth" in the script given by @try67
It may take a little bit of tweaking to get the exact result you want but everything is there for you to achieve your aim.
var pageBox = this.getPageBox("Crop", this.pageNum);
var pageHeight = pageBox-pageBox;
var newPageBox = [0, pageHeight, 35*28.3465, 0];
this.setPageBoxes("Crop", this.pageNum, this.pageNum, newPageBox);
I tried according to what you said, but still it changes the width and not the height.
Also, I need 2 more things:
A. Change also to media box (I tried to duplicate the code but it does not work)
B. Insert all of this under a file menu or other.
Attached is the code.
This line : var newPageBox = [0, pageHeight, 35*28.3465, 0];
in between the square brackets (is roughly, "this could start a fight 😛 " ) [ 0, pageHeight, pageWidth, 0]; so if you change the pageHeight and pageWidth you should manage what you want.
Your code does not appear to be there ( if it is just 4 lines long then you have not follows the website that you where directed to for adding a menu item)
To do this effectively you need to understand a bit about geometry and the PDF coordinate system.
Here's an article on PDF coordinates:
For example, the height of a rectangle is found by subtracting the bottom coordinate from the top coordinate. You'll note that this is done in the code, and then the new placement rectangle is created using this number, e.t., the height is unchanged. To get a new height the code needs to calculate a new hieght, similar to how the new width is calculated.
Let's make the code more explicit.
// Get existing Page Crop Box var pageBox = this.getPageBox("Crop", this.pageNum); // Find the existing height and width var pageHeight = pageBox-pageBox; var pageWidth = pageBox-pageBox; // Calculate new values var pointsPerCm = 28.3465; var nLeft = 0; var nRignt = pointsPerCm * 35; var nTop = pointsPerCm * 60; var nBottom = 0; // Create new page Crop Box var newPageBox = [nLeft, nTop, nRight, nBottom]; this.setPageBoxes("Crop", this.pageNum, this.pageNum, newPageBox);
I don't know what your actual width and height requirements are, so the numbers in the code are just for demonstration.
Okay, friends, thanks, but keep in mind I'm not a programmer
And do not understand it so much.
I'm happy if someone corrects my code and sends me something perfect,
With a change in media (below the code) and menu.
This site is of course about helping you to learn how to do it yourself. If you are interested in a custom solution, then you can contact me through the messaging on this site.
You'll find a free page resizeing tool here: