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

Need a script for acrobat for free/nominal fee - to change height in document

Explorer ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Every document I run the script, the height changes to 35 cm and the width remains the same.

For example:
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.
another example:
Document size 15 width by 20 height, I want to change the height to 35.

 

The script will be inside the menu in Acrobat.

TOPICS
Acrobat SDK and JavaScript

Views

825

Translate

Translate

Report

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
Community Expert ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

Hi,

When you say you want the height changed, are you wanting the contents of the page to change?

 

Regards

 

Malcolm

Votes

Translate

Translate

Report

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
Explorer ,
Oct 27, 2020 Oct 27, 2020

Copy link to clipboard

Copied

No.

Only to add white up and down

Votes

Translate

Translate

Report

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
Explorer ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

Can you help me with that?

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

You can use this code to do it:

 

var pageBox = this.getPageBox("Media", this.pageNum);
var pageWidth = pageBox[1]-pageBox[3];
var newPageBox = [0, pageWidth, 35*28.3465, 0];
this.setPageBoxes("Media", this.pageNum, this.pageNum, newPageBox);

Votes

Translate

Translate

Report

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
Explorer ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

Hey

Thank you!!



I put it in the "Java Scripts" folder

Of Acrobat

But I do not see it appearing

You can please arrange for it to appear under a menu

"file"?

Votes

Translate

Translate

Report

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
Explorer ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

I also tried through the acrobat and it only changes the width and not the height.

In addition, the same should be changed to cropbox as well.

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

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:

https://acrobatusers.com/tutorials/add_custom_menu_items/

  

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Explorer ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

HI,

 

@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.

 

Regards

 

Malcolm

 

Votes

Translate

Translate

Report

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
Explorer ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

var pageBox = this.getPageBox("Crop", this.pageNum);
var pageHeight = pageBox[1]-pageBox[3];
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.

 

 

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

Hi,

 

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)

 

Regards

 

Malcolm

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

To do this effectively you need to understand a bit about geometry and the PDF coordinate system.

Here's an article on PDF coordinates:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm

 

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[1]-pageBox[3];
var pageWidth = pageBox[2]-pageBox[0];

// 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. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Explorer ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

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.
Thanks!!!!!!!!

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

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.  

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

LATEST

You'll find a free page resizeing tool here:

https://www.pdfscripting.com/public/Free_Acrobat_Automation_Tools.cfm

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

The script provided by Try67 is meant to be run in the Acrobat JavaScript Console. You'll find a tutorial on using the console window here:

https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

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