Search code examples
c#.netpicturebox

How can I print image big size in A4 paper c#


I want to print image from picturebox in big size in my current code its print in original size , I tried the following code :

private void btnID_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            PrintDocument pdoc = new PrintDocument();
            pdoc.PrintPage += doc_printID;
            pd.Document = pdoc;
            if (pd.ShowDialog() == DialogResult.OK)
                pdoc.Print();


        }

        private void doc_printID(object sender, PrintPageEventArgs e)
        {
            Bitmap bm = new Bitmap(pictureIDIQAMA.Width, pictureIDIQAMA.Height);
            pictureIDIQAMA.DrawToBitmap(bm, new Rectangle(0, 0, pictureIDIQAMA.Width, pictureIDIQAMA.Height));
            e.Graphics.DrawImage(bm, 200,400);
            bm.Dispose();
        }

How can I print the image in bigger size at lease double original size ?


Solution

  • To draw the image that is within the margin of your page

    e.Graphics.DrawImage(bm, args.MarginBounds);

    or

    To draw the image across total area of the page

    e.Graphics.DrawImage(bm, args.PageBounds);