简体   繁体   中英

Printing form with pictures

I'm trying to print out a form that a customer has filled out for them to sign, and then store in our folders, but I can't figure out how to print forms properly. I've tried tons of guides or tutorials online, but I was only able to take a picture of the form and print that, which looked awful.

Is there any way I can print my form, which contains controls, labels, and pictures, in professional quality? I've heard about plugins for visual studio that might be able to do this, and if its not too much of a hassle, price might not be too much of a factor.

If it matters, all my controls are contained in form2, and the printing will be done from a menustrip-button in form2 aswell.

Thanks!

PrintDocument would be the way to go. It uses GDI+ for drawing to the surface of the document. Your now in charge of the layout.

 private void pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
   {
   single yPos = 0;
   int count = 0;
   single leftMargin = e.MarginBounds.Left;
   single topMargin = e.MarginBounds.Top;
   Image img = Image.FromFile({path to img});
   Rectangle logo = New Rectangle(40,40,50,50);
   using (Font printFont = new Font("Arial", 10.0f))
    { 
     e.Graphics.DrawImage(img, logo);
     e.Graphics.DrawString(textbox1.Text, printFont, Brushes.Black, leftMargin, yPos, New StringFormat());
    }
   //etc...
   //taken from the example and added how to draw the text from a textbox
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM