How to print a PDF document as landscape/portrait using PDFTron?

Q: How to make my PDF document to be printed in landscape using
PDFTron. I have three more questions for you:

1. Portrait/Landscape: I am creating a printing framework, where some
applications will send print requests in PDF format to be printed.
Does the application have to provide the paper orientation (landscape
or portrait) in the request? I mean, isn't it possible to identify
that from the pdf document provided by the requester?

2. Portrait/Landscape 2: If the requester send me a document with some
pages in portrait and some in landscape, how to identify that?

3. Paper size: Do I have to code something to support different paper
sizes (legal, A4, etc)? Or the approach provided in your code is
enough?
-----
A: Using PDFNet SDK you have full control over how the page is
printed. In the nutshell you could rotate pages using either
page.SetRotation(angle) or pdfdraw.SetRotate(angle) and can obtain
page dimensions from the page object (i.e. page.GetPageWidth()/
page.GetPageHeight()).

If you would like to print the page using exactly the same scaling
that you use in the portrait mode, the rectangle parameter in
pdfdraw.DrawInRect should have the same width that you use in the
portrait mode. Of course, in this case some parts of PDF page may not
be visible (since they would lie outside of the bounds of the physical
page).

For example,
rect.x1 = 0; rect.x2=rect.Height(); // or something similar
pdfdraw.DrawInRect(page, gr, rect);

Does the application have to provide the paper orientation
(landscape or portrait) in the request? I mean, isn't it possible
to identify that from the pdf document provided by the requester?

The paper orientation (landscape or portrait) is a printing
preference. This information is not stored within a PDF document (some
users may want to print a given page as portrait, others as
landscape). PDF documents store dimensions for each page and this
information could be used to guide your decision regarding the paper
orientation.

2. Portrait/Landscape 2: If the requester send me a
document with some pages in portrait and some in landscape,
how to identify that?

This information is not explicitly provided in PDF. You could obtain
page dimensions (page.GetPageWidth()/page.GetPageHeight()). If the
page width is greater than the page height you may want to print the
page as landscape, and portrait otherwise.

3. Paper size: Do I have to code something to support
different paper sizes (legal, A4, etc)? Or the approach
provided in your code is enough?

The above approach should work for any paper size.