Printing with C #
I in the network relatively few or Tutorials poor have found here a little guide to C # to implement a simple expression with printer selection.
PrintDocument PrintDocument = New PrintDocument ();
printDoc.PrintPage + = new PrintPageEventHandler (printDoc_PrintPage);
PrintDialog print dialog = new Dialog ();
printDialog.Document = printDoc;
if (printDialog.ShowDialog () = = DialogResult.OK) {
printDoc.Print ();}
What exactly happened here? First, a document is created. This is the area to be printed. Subsequently an event handler to the Event print page detect down to may be printed exactly when.
the print dialog, we use a print dialog to select the printer display.
By calling the function print () print the documents to start the printing, which is the print page event triggered. It now must be printed content will be written in the resulting Graphics object:
private void printDoc_PrintPage (object sender, PrintPageEventArgs e)
{
String textToPrint = "Hello World";
font print font = new Font ("Arial" , 18, FontStyle.Bold);
e.Graphics.DrawString (textToPrint, print font, Brushes.Black 10, 25);}
In this case, printed text with specified font in Arial, font size 18 and bold on the coordinates x = 10 and y = 25.
0 comments:
Post a Comment