Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm pretty new to C# and I've had problems with printing an PrintDocument containing a Graphics-Element. Printout works fine quality is good (swapped from using Bitmaps to EMF's) and paper size is now correct. The problem I have is the amount.

Background:
What I want to do is create the sticker (this works)
print the sticker according to amount entered in a Windows.Form.TextBox (Problem)

All I get is one copy.
Any info, what I'm doing wrong? Or ideas?

Thanx.

Here my code:

C#
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);
}
Posted
Updated 20-Feb-16 8:36am

1 solution

 
Share this answer
 
Comments
Richard MacCutchan 21-Feb-16 3:36am    
This question is nearly three years old. Please don't add answers to dead questions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900