Print PDF (GDI+)

Printing
7/3/2014

1 Document document; 2 int index; 3 4 void print() 5 { 6 index = 0; 7 8 PrintDocument printDocument = new PrintDocument(); 9 printDocument.DocumentName = document.DocumentInfo.Title; 10 11 printDocument.DefaultPageSettings.Margins.Left = 0; 12 printDocument.DefaultPageSettings.Margins.Top = 0; 13 printDocument.OriginAtMargins = true; 14 15 PageSetupDialog setupDialog = new PageSetupDialog(); 16 setupDialog.Document = printDocument; 17 18 if ( DialogResult.OK == setupDialog.ShowDialog() ) 19 { 20 printDocument.DefaultPageSettings = setupDialog.PageSettings; 21 printDocument.PrinterSettings = setupDialog.PrinterSettings; 22 23 printDocument.PrintPage += new PrintPageEventHandler( printPage ); 24 printDocument.Print(); 25 } 26 } 27 28 void printPage( object sender, PrintPageEventArgs e ) 29 { 30 e.Graphics.PageUnit = GraphicsUnit.Point; 31 32 Page page = document.Pages[ index++ ]; 33 page.Draw( e.Graphics ); 34 35 e.HasMorePages = index < document.Pages.Count; 36 }