Copy link to clipboard
Copied
Help me!
I want to know the JavaScript that shows whether the last page of the document I am working on is left or right.
For example..
var a = 8;
if (a === 8) {
Load the aaa.txt file into the last page on the right.
} else (a ===7) {
Load the bbb.txt file to the last page on the left.
}
Use the page's side property:
if (app.documents[0].pages[-1].side === PageSideOptions.LEFT_HAND) {
// Load bbb.txt
} else {
// Load aaa.txt
}
This works in left-to-right and in right-to-left documents. The last page's document offset is the same in both types of document.
P.
Copy link to clipboard
Copied
For example..
var a = 8;
if (a === 8) {
Load the aaa.txt file into the last page on the right.
} else {
Load the bbb.txt file to the last page on the left.
}
Copy link to clipboard
Copied
if (app.activeDocument.pages.lastItem().documentOffset % 2 == 0) {
//page is odd (usually right)
} else {
//page is even (usually left)
}
Copy link to clipboard
Copied
Thank you for your answer.^^
Copy link to clipboard
Copied
Use the page's side property:
if (app.documents[0].pages[-1].side === PageSideOptions.LEFT_HAND) {
// Load bbb.txt
} else {
// Load aaa.txt
}
This works in left-to-right and in right-to-left documents. The last page's document offset is the same in both types of document.
P.
Copy link to clipboard
Copied
Thank you for your answer.*^^*