Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Nov 06, 2020 12:32 am

Hello .. Good night!
I have a need to find out if a particular PDF file looks like a landscape or portrait.
Is it possible, with the use of Spire.PDF, to know if a PDF is portrait or landscape?
Thank you in advance!

gafforelli
 
Posts: 37
Joined: Sat Sep 15, 2018 6:38 pm

Fri Nov 06, 2020 3:44 am

Hello,

Thanks for your inquiry.
Spire.Pdf can determine the direction of PDF file. Please refer to the following code. If there is any question, please feel free to write back.
Code: Select all
            //Create a new instance of PdfDocument and load a PDF document from file.
            PdfDocument pdf = new PdfDocument();
            pdf.LoadFromFile("sample.pdf");

            //Get the first Page
            PdfPageBase page = pdf.Pages[0];

            string orientation;

            //If width > height, the orientation is "Landscape"
            if (page.Size.Width > page.Size.Height)
            {
                orientation = "Landapace";
            }
            else//else the orientation is "Portrait"
            {
                orientation = "Portrait";
            }

            File.WriteAllText("result.txt", "Orientation = "+ orientation);


Sincerely,
Marcia
e-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Nov 30, 2020 10:13 am

Hello,

Hope you are doing well.

Has your issue been solved now? Could you please give us some feedback at your convenience?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Dec 15, 2020 8:34 pm

Hello Marcia, how are you?
Sorry for the delay ...
Worked perfectly.
Thank you very much for your speed in helping us.
:)

gafforelli
 
Posts: 37
Joined: Sat Sep 15, 2018 6:38 pm

Wed Dec 16, 2020 2:09 am

Hello,

Thanks for your feedback!

Glad to hear that your issue has been solved.

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.PDF