Printing with Printdocument, Printpreviewdialog C#

Asked

Viewed 665 times

1

I’m trying to print labels of my products straight from my app.

However I am not able to reduce the size of the paper in the printing, for this reason I’m losing 1 label every 1 impression I make, follow the photo:

inserir a descrição da imagem aqui

Man PreviewDialog shows that really the paper is bigger than it should: Follow the photo:

inserir a descrição da imagem aqui

I can’t get it set up for printing, does anyone have a solution? Follow my code so far:

    private void btnPreview_Click(object sender, EventArgs e)
    {
        DVprintPreviewDialog1.Document = DVprintDocument1;
        DVprintPreviewDialog1.ShowDialog();

    }

    private void DVprintDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        Bitmap bmp = Properties.Resources.logo;
        Image newImage = bmp;
        e.Graphics.DrawImage(newImage, 10, 3, newImage.Width, newImage.Height);
        e.Graphics.DrawString("TESTE", new Font("Arial", 12, FontStyle.Bold), Brushes.Black, new Point(130, 13));
    }

1 answer

0


PROBLEM SOLVED !

I just set up the Settings in the property, as in the Code below: The values in the prowess of the PAPERSIZEis an account: All sizes are converted from MM to INCHES and then multiplied by 100.

In my case, I rounded up the value, but my label has 1" x 3".
An A4 for example would ("A4", 827, 1170);

      DVprintDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("TAM DA MINHA ETIQUETA", 300, 90);

Hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.