Skip to main content
New Participant
September 13, 2019
Answered

Getting page dimensions (pageWidth and pageHeight), not document dimensions with JSX?

  • September 13, 2019
  • 1 reply
  • 426 views
var pageWidth = app.activeDocument.documentPreferences.pageWidth

will give me the document page width

but i need something like this

var pageWidth = app.activeDocument.pages[0].documentPreferences.pageWidth

 

How can i get the dimensions for page, which has not the dimensions of the document preferences settings?

Thanks for your help

This topic has been closed for replies.
Correct answer Kasyan Servetsky
main();

function main() {
	var doc = app.activeDocument;
	var page = doc.pages[0];
	var bounds = page.bounds;
	var width = RoundWithDecimal(bounds[3] - bounds[1], 3);
	var height = RoundWithDecimal(bounds[2] - bounds[0], 3);
}

function RoundWithDecimal(number, decimals){
    var multiplier = Math.pow(10,decimals);
    return Math.round(number*multiplier)/multiplier;
}

1 reply

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Brainiac
September 13, 2019
main();

function main() {
	var doc = app.activeDocument;
	var page = doc.pages[0];
	var bounds = page.bounds;
	var width = RoundWithDecimal(bounds[3] - bounds[1], 3);
	var height = RoundWithDecimal(bounds[2] - bounds[0], 3);
}

function RoundWithDecimal(number, decimals){
    var multiplier = Math.pow(10,decimals);
    return Math.round(number*multiplier)/multiplier;
}
New Participant
September 13, 2019
Thank you very much, that helped me!