This section covers the following topics:
All graphics operations are implicitly expressed in units, called 'page units'. By default, the unit used is the Point, or 1/72nd of an inch. You can change the unit used by graphics operation at any point by setting the PageUnit property of a Graphics instance to one of the following values:
Note: Some values and operations are always expressed in points, regardless of the current page unit. Font size and spacing values used in rendering text are always expressed in points.
Although PDF Graphics.NET deals with vector graphics (expect for images) and is therefore not dependent on device resolution, it does have an intrinsic resolution that is used to convert values in pixels to values in points. This resolution is only interesting while the PageUnit property of the Graphics object is set to Pixels.
By default, the resolution is set to 72 dpi in both X and Y direction. This means that a pixel corresponds to a point, since they are both 1/72nd of an inch. To change these values, use the DpiX and DpiY properties of the Graphics class.
Graphics are always rendered on a page. If you don't explicitly create a page in your PDF document, PDF Graphics .NET will implicitly create a DIN A4 page. To create a new page, use the NewPage() method. This method has three overloads:
You can also create a Graphics instance with a preset size, using one of its constructor overloads. This is functionally equivalent to creating an instance and calling NewPage() overload with a page size.
PDF Graphics .NET has a number of standard pages that can be used to create pages in popular formats. They standard pages are found in the StandardPages static class, and can be used in overloads of NewPage() as well as the Graphics constructors. The full list of standard pages is as follows:
The standard set of page sizes included in the PDF Graphics.NET library is mostly based on portrait-oriented sheets. To create a landscape-oriented page you can do either of the following:
When viewing the PDF document, any landscape-oriented pages will appear as landscape-oriented pages; with their long sides across. This is convenient for viewing the document on-screen but may cause issues when printing.
The PDF standard allows a document to specify the display direction of a page. In PDF Graphics .NET, this is controlled through an overload of NewPage() that accepts an Orientation argument.
Using the Orientation argument, you can pass a landscape page size to NewPage() and still display it with the short side across, like portrait pages.
It can also be used to orient pages upside-down, which may be a requirement for some printers.