How can I change the paper size and paper orientation when generating PDF using PDFDCEX?

Q: In your PDFDC (PDF Device Context) example, how can I change the
paper size and orientation in the ‘pdftron.PDF.PDFDCEX’ part of the
example?

Normally, we use CreateDC with a DevMode specifying the size and
orientation. How can I accomplish the same thing with PDFDCEX?


A: There is no way to set the bounding box ahead of time however you
can modify the page boxes (page.SetCropBox()/SetMediaBox()/
SetRotation()) after the page is created. You could use
page.GetBoundingBox() to determine the extents of the content area -
in case you would like to adjust the page rectangle based on the
content.

The latest PDFNet releases now have the option to set the page dimension in the PDFDCEX class (not PDFDC though).

The PDFDCEX.Begin() method can now take in a pdftron.PDF.Point object, where x=width and y=height of the page in inches.

Note we no longer advise the PDFDC interface, as it is easy to replace with the more powerful PDFDCEX, which now includes the above option.