PageDraw Method (Graphics)
Assembly: TallComponents.PDF.Rasterizer (in TallComponents.PDF.Rasterizer.dll) Version: 22.214.171.124
Graphics object to which content is drawn.
Page.Draw assumes a coordinate sysem where each unit equals a point (1/72 inch). The PageUnit property of the supplied graphics instance indicates how each unit maps onto the actual device. Page.Draw uses this information to produce the most appropriate result, and in particular the resolution of rendered images:
- GraphicsUnit.Pixel: each unit is assumed to map onto a single pixel. This is appropriate for Graphic instances that have been obtained from a bitmap and that are used as shown in the example. The DPI values of the Graphics instance are ignored in this case.
- GraphicUnit.Display: this is the default value for a Graphic instance that has been created from a bitmap. It will be treated in the same way as GraphicUnit.Pixel.
- GraphicUnit.Point: each unit is assumed to represent a single point (1/72 inch). The DPI values of the Graphic instance determine how many pixels correspond to a unit. This value may take longer to render, but it gives the best results for printing. Please note that .Net does not automatically specify GraphicUnit.Point for printer instances of Graphic, so for best results this will have to be set explicitly.
Page page = document.Pages[selectedPage]; const float DPI = 300; bitmap = new Bitmap( (int) ( page.Width / 72 * DPI ), (int) ( page.Height / 72 * DPI ) ); Graphics graphics = Graphics.FromImage( bitmap ); float scale = DPI / 72; graphics.ScaleTransform( scale, scale ); <b>page.Draw( graphics );</b>