0

I have this code for printing a panel to a printer. It has labels and those labels are the only thing that I want to print. It works but when it prints, the labels doesn't print clearly. Its like blurred or something.

private void btnPrint_Click(object sender, EventArgs e)
{ 
     Print(panel1);
}

public void Print(Panel pnl)
{
        pannel = pnl;
        GetPrintArea(pnl);

        if (cmbPrinter.SelectedIndex != -1)
        {
            printdoc1.PrinterSettings.PrinterName = cmbPrinter.SelectedItem.ToString();
        }

        if (batchForm.printInBatch)
            printdoc1.Print();
        else
        {
            previewdlg.Document = printdoc1;
            previewdlg.ShowDialog();
        }
}

public void GetPrintArea(Panel pnl)
{
        MemoryImage = new Bitmap(pnl.Width, pnl.Height);
        Rectangle rect = new Rectangle(0, 0, pnl.Width, pnl.Height);
        pnl.DrawToBitmap(MemoryImage, new Rectangle(0, 0, pnl.Width, pnl.Height));
}

protected override void OnPaint(PaintEventArgs e)
{
        if (MemoryImage != null)
        {
            e.Graphics.DrawImage(MemoryImage, 0, 0);
            base.OnPaint(e);
        }
}

public void printdoc1_PrintPage(object sender, PrintPageEventArgs e)
{
        Rectangle pagearea = e.PageBounds;
        e.Graphics.DrawImage(MemoryImage, 0, 0);
}
ViFer
  • 283
  • 1
  • 6
  • 23
  • Have you set up a custom form for the labels? Since you're drawing to bitmap it may be 'sizing to fit'. Are your labels text (names and addresses) or do they contain graphics? Bar codes don't count as graphics, find a bar code font. – Meredith Poor Jul 15 '13 at 10:04
  • Thanks for your help but I found a way. using DrawString instead. :) – ViFer Jul 15 '13 at 11:05
  • 1
    why dont you answer your question?people may need it – r.hamd Nov 22 '15 at 22:08
  • I answered and I said I used DrawString instead of DrawImage.. – ViFer Nov 24 '15 at 08:06

0 Answers0