How to get the lanscape page numbers from a whole pdf? SOLVED
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
How to get the lanscape page numbers from a whole pdf?
Hi, Everyone
Take one pdf book including 500 pages as an example, a few were landscape, the majority were portrait
How can I get the landscape pages numbers as soon as possible
The problem puzzled me for a very long time
Please help, thank you!
Take one pdf book including 500 pages as an example, a few were landscape, the majority were portrait
How can I get the landscape pages numbers as soon as possible
The problem puzzled me for a very long time
Please help, thank you!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17908
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to get the lanscape page numbers from a whole pdf?
Hello celk2010,
The quickest way would be to run the below JS code. To run it - use Ctrl + J on your keyboard to open the JS console, then copy and paste the entire script below, and then hit the Run button in the console. You should get a line with the result in the output area.
Regards,
Stefan
The quickest way would be to run the below JS code. To run it - use Ctrl + J on your keyboard to open the JS console, then copy and paste the entire script below, and then hit the Run button in the console. You should get a line with the result in the output area.
Code: Select all
var numLandscapePages = 0;
for (var i = 0; i<this.numPages; i++)
{
var pageRect = this.getPageBox("Crop",i);
var width = pageRect[2]-pageRect[0];
var height = pageRect[1]-pageRect[3];
if (width >= height)
{
numLandscapePages++;
}
}
console.println("There are "+ numLandscapePages + " landscape pages in this file");
Stefan
Re: How to get the lanscape page numbers from a whole pdf?
Hi, Dear Stefan,
If I have one pdf file, in total 10 pages, landscape pages are page 2, 4, 6,
By your code, the result will be "There are 3 landscape pages in this file"
Then I want to know exact pages numbers, just like: pages 2, 4, 6 are landscape pages.
How to achieve this goal?
Thank you!
If I have one pdf file, in total 10 pages, landscape pages are page 2, 4, 6,
By your code, the result will be "There are 3 landscape pages in this file"
Then I want to know exact pages numbers, just like: pages 2, 4, 6 are landscape pages.
How to achieve this goal?
Thank you!
Tracker Supp-Stefan wrote: ↑Tue Dec 17, 2019 3:09 pm Hello celk2010,
The quickest way would be to run the below JS code. To run it - use Ctrl + J on your keyboard to open the JS console, then copy and paste the entire script below, and then hit the Run button in the console. You should get a line with the result in the output area.
Regards,Code: Select all
var numLandscapePages = 0; for (var i = 0; i<this.numPages; i++) { var pageRect = this.getPageBox("Crop",i); var width = pageRect[2]-pageRect[0]; var height = pageRect[1]-pageRect[3]; if (width >= height) { numLandscapePages++; } } console.println("There are "+ numLandscapePages + " landscape pages in this file");
Stefan
- Tracker Supp-Stefan
- Site Admin
- Posts: 17908
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to get the lanscape page numbers from a whole pdf? SOLVED
Hello celk2010,
A simple addition will output an additional line for each landscape page:
And if you want a list of all the landscape pages on a single line - something like this can be used:
Regards,
Stefan
A simple addition will output an additional line for each landscape page:
Code: Select all
var numLandscapePages = 0;
for (var i = 0; i<this.numPages; i++)
{
var pageRect = this.getPageBox("Crop",i);
var width = pageRect[2]-pageRect[0];
var height = pageRect[1]-pageRect[3];
if (width >= height)
{
numLandscapePages++;
console.println("Page "+ (i+1) + " is landscape");
}
}
console.println("There are "+ numLandscapePages + " landscape pages in this file");
Code: Select all
var numLandscapePages = 0;
var landscapePages = new Array ();
for (var i = 0; i<this.numPages; i++)
{
var pageRect = this.getPageBox("Crop",i);
var width = pageRect[2]-pageRect[0];
var height = pageRect[1]-pageRect[3];
if (width >= height)
{
numLandscapePages++;
landscapePages.push(i+1);
console.println("Page "+ (i+1) + " is landscape"); //Comment this out by adding // at the front of the line if you do not want to see in the output a line for each landscape page.
}
}
console.println("There are "+ numLandscapePages + " landscape pages in this file");
console.println("List of landscape pages "+ landscapePages);
Stefan
Re: How to get the lanscape page numbers from a whole pdf?
Thank you Stefan very much for your nice code, it have saved and will go on saving me much time.
My admiration for you is like a mighty river, even the seas run dry and the rocks crumble, the sky collapses and the earth cracks, I will never change my mind.
My admiration for you is like a mighty river, even the seas run dry and the rocks crumble, the sky collapses and the earth cracks, I will never change my mind.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17908
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: How to get the lanscape page numbers from a whole pdf?
Glad I could assist celk2010!
Season's greetings and
Kind Regards,
Stefan
Season's greetings and
Kind Regards,
Stefan
Re: How to get the lanscape page numbers from a whole pdf?
Merry Christmas to you Stefan!
Wish you a nice holiday!
Wish you a nice holiday!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17908
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact: