Skip to main content
Known Participant
May 16, 2023
Question

'addAnnot' still using original coordinates after page crop with acrobat javascript 'setPageBoxes'

  • May 16, 2023
  • 0 replies
  • 399 views

I want to change size of a page (of thousands) to 842pt x 595pt using Javascript. 

The original page dimensions read like this in the console:

console.println(this.getPageBox("Media",0));	
// output: 0,898.5830078125,651.968994140625,0
console.println(this.getPageBox("Crop",0));		
// output: 0,898.5830078125,651.968994140625,0

Now, to change the page size, I run:

this.setPageBoxes("Media",0,0,[30,867,625,25]);

console.println(this.getPageBox("Media",0)); 	
// output: 0,842,595,0
console.println(this.getPageBox("Crop",0)); 	
// output: 0,842,595,0
console.println(this.getPageBox("Art",0)); 		
// output: -30,873.5830078125,621.968994140625,-25
console.println(this.getPageBox("Bleed",0)); 	
// output: -30,873.5830078125,621.968994140625,-25
console.println(this.getPageBox("Trim",0)); 	
// output: -30,873.5830078125,621.968994140625,-25

Now I have my desired page size.

Then I run this code to draw a rectangle annotation that should start at the bottom left corner of the new page, meaning, it should have the origin at new (0,0):

this.addAnnot({	page: 0, type:"Square", rect:[0,0,595,842] });

But, the problem is, this rectangle starts at the original page coordinates (0,0). Meaning, rectangle goes partially outside the new "Media pageBox". Like this in the picture:

 

 

I want the cropped page size to be the actual page size. I don't want to change (0,0) in 'addAnnot'. Any suggestions?

Note: I have attached a sample file here.

This topic has been closed for replies.