private void btnDruck_Click(object sender, EventArgs e){ PrintDocument Druckjob = new PrintDocument(); PrintDialog Druckermenue = new PrintDialog(); PrintPreviewDialog Druckpreview = new PrintPreviewDialog(); Druckjob.DocumentName = "Rechnung";
Druckjob.PrintPage += new PrintPageEventHandler(Druckjob_PrintPage); Druckpreview.Document = Druckjob; Druckermenue.Document = Druckjob; if (Druckermenue.ShowDialog() == DialogResult.OK) { Druckjob.Print(); } Druckjob.PrintPage -= new PrintPageEventHandler(Druckjob_PrintPage); }void Druckjob_PrintPage(object sender, PrintPageEventArgs e){ Graphics g = e.Graphics; StringFormat lineFmtRight = new StringFormat(); lineFmtRight.Alignment = StringAlignment.Far; g.PageUnit = GraphicsUnit.Millimeter;
// Druckausgabe ... // Drucken ..
g.Dispose();}