Find pages in landscape orientation

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

evdbogaard
User
Posts: 97
Joined: Mon May 26, 2008 8:52 am

Find pages in landscape orientation

Post by evdbogaard »

Is there a way to quickly find landscape pages in a large document (> 700 pages) that consists for 99% of portrait pages?

Thanks in advance,
Ed
Ed van den Bogaard
Happy PDF-XChange PRO user since 2008 (version 4)
User avatar
PHK
User
Posts: 1398
Joined: Tue Nov 24, 2020 4:02 pm

Re: Find pages in landscape orientation

Post by PHK »

Show the Thumbnails pane, zoom out until the thumbnails are quite small, and then just navigate around the pane and you should be able to see the orientation of all pages.
All best,

FringePhil
evdbogaard
User
Posts: 97
Joined: Mon May 26, 2008 8:52 am

Re: Find pages in landscape orientation

Post by evdbogaard »

That's exactly what I do, but because in a 700 pages document that is a bit tedious I hoped there is a quicker way using a search.

Maybe something for a feature request: searching on page dimensions (i.e. page width > 21 cm).

Anyway, cheers and thanks again.
Ed
Ed van den Bogaard
Happy PDF-XChange PRO user since 2008 (version 4)
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Find pages in landscape orientation

Post by Stefan - PDF-XChange »

Hello evdbogaard,

Do you need to just find those pages or also rotate them?
I think there was a similar topic in the past here in the forums - and I wrote a small JS that goes through all pages and checks whether their width is larger than their height, and if it was - the script was rotating them accordingly.

Kind regards,
Stefan
evdbogaard
User
Posts: 97
Joined: Mon May 26, 2008 8:52 am

Re: Find pages in landscape orientation

Post by evdbogaard »

Hi Stefan,

your guess is correct, I also want to rotate them to portrait, so I am interested in your script.

Greetings from ‘Max’-country,
Ed
Ed van den Bogaard
Happy PDF-XChange PRO user since 2008 (version 4)
lev
User
Posts: 280
Joined: Fri Apr 11, 2014 1:18 am

Re: Find pages in landscape orientation

Post by lev »

A script below will set page rotation of landscape oriented pages to 0°. Most of the script came from https://forum.pdf-xchange.com/viewtopic.php?p=138973#p138973
Make a copy of your file before running it.

Code: Select all

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) 
	{
		setPageRotations(i, i, 0);
	}
}
User avatar
Chris - PDF-XChange
Site Admin
Posts: 797
Joined: Tue Apr 14, 2009 11:33 pm

Find pages in landscape orientation

Post by Chris - PDF-XChange »

:) thanks lev
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.


Chris Attrell
Tracker Sales & Support North America
http://www.tracker-software.com
evdbogaard
User
Posts: 97
Joined: Mon May 26, 2008 8:52 am

Re: Find pages in landscape orientation

Post by evdbogaard »

Thanks, works like a charm!

I guess there is a similar way to find (portrait oriented) pages with a width larger then 21,00 cm.
It is not necessary to automatically change anything, but in a 500 page document it would be nice to find them in an quick and easy way.

How do edit the code for that purpose?

Oops, nearly forgotten: happy new year for all of you!

Ed
Ed van den Bogaard
Happy PDF-XChange PRO user since 2008 (version 4)
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Re: Find pages in landscape orientation

Post by Stefan - PDF-XChange »

Hello Ed,

Please try this script:

Code: Select all

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 >= 596) //value in points - 1pt = 1/72 inch - 596pt ~= 210.256mm
	{
         console.println("The width of page "+ (i+1) + " is " + 
	  Math.round((width*25.4/72)*100 )/100 + " mm");
	}

}
When you run it - you should get a list of the pages that are wider than 210.255mm with the page width given in mm rounded to two decimal digits.
If you change the value in the if from 596 to 595.27559 you will get as close to 210mm as possible:
image.png

So if you have a mix of e.g. A4 and Letter sized pages - the script will catch all the Letter pages and skip portrait A4 ones. (Landscape A4 will be wider than our check - so such pages will still display in the output list.)

Kind regards,
Stefan
You do not have the required permissions to view the files attached to this post.
evdbogaard
User
Posts: 97
Joined: Mon May 26, 2008 8:52 am

Re: Find pages in landscape orientation

Post by evdbogaard »

Hi Stefan,

This too works like a charm, so thanks!

Kindest regards,
Ed
Ed van den Bogaard
Happy PDF-XChange PRO user since 2008 (version 4)
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19868
Joined: Mon Jan 12, 2009 8:07 am

Find pages in landscape orientation

Post by Stefan - PDF-XChange »

:)