private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { // Fills the e.Graphics Element Size 74mm x 34mm // Works fine EmfImagePrintout(e.Graphics, 74, 34, 100); } private void button1_Click(object sender, EventArgs e) { PrintDocument PrintDocEtikettKlein = new PrintDocument(); // Searched ages for this code snipit Had problems, // the printout used an A4 although I'm using stickers with different // Printable Areas. // So what I done was create a PaperSize in the Printer Driver // and now call up the Info from there. PaperSize Before = PrintDocEtikettKlein.DefaultPageSettings.PaperSize; IEnumerable<PaperSize> paperSizes = PrintDocEtikettKlein.PrinterSettings.PaperSizes.Cast<PaperSize>(); PaperSize VET1 = paperSizes.First<PaperSize>(size => size.PaperName == "VET-1 (Typenschild)"); // doing this double as I read it might not work in some situations PrintDocEtikettKlein.DefaultPageSettings.PaperSize = VET1; PrintDocEtikettKlein.PrinterSettings.DefaultPageSettings.PaperSize = VET1; PrintDocEtikettKlein.DefaultPageSettings.PrinterSettings.Copies = 4; PrintDocEtikettKlein.PrinterSettings.DefaultPageSettings.PrinterSettings.Copies = 4; PrintDocEtikettKlein.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); PrintDialog PrnDlg = new PrintDialog(); //PrnDlg.ShowDialog(); if (PrnDlg.ShowDialog(this) == DialogResult.OK) { PrintDocEtikettKlein.Print(); } PrintDocEtikettKlein.PrintPage -= new PrintPageEventHandler(printDocument1_PrintPage); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)