Sunday, 15 May 2011

winforms - C# Printing Inconsistent -


I have a form on which I have many text boxes I print text from these text boxes in those places I want to where they are on the farm. It's printing using the code below at the moment. However, the text prints separately on different printers (on some it is just right, something is too much, etc.). It is being printed on the pre-printed form with the blank space for the text, so it should be quite accurate, what am I missing to print it on every printer?

  Public Zero Print DevicePropage (Object Sender, PrintPageEventArgs e) {Panel Curpanel = this.FormPanel; Graphics G = (graphics) e.Graphics; Pen apien = new pen (brush black, 1); // Set the cycle through each control, whether it is a checkbox or text box and inside // inside the information, then come to the place xLocation, yLocation; For (int j = 0; j & lt; curPanel.Controls.Count; j ++) {// Check whether there is a text box type by comparing one of the types of text boxes, if (curpanel.Controls [ J] is a text box) {/ Unbox the textbox text box TheText = (text box) curPanel.Controls [j]; // Draw a text box string on the condition of the text box on the form, scale to print page xLocation = theText.Bounds.Left; YLocation = theText.Bounds.Top; G. Drawstring (text, text, fonts, brushes black, x lockation, y lotion); }}}}  

The problem is how are you aligning the controls inside . The default alignment is approximately equal to StringFormat.Anignment = StringAlignment.Center, it can be changed to the button and check the box with your TextAlign property. You must use a drawer () surcharge which takes a rectangle and string formatting. Note that the text box is difficult, so you can also close some pixels.

Take a look at Control.DrawToBitmap () for a completely different approach.


No comments:

Post a Comment