Created
August 31, 2017 06:46
-
-
Save alvin2ye/a114e62e0e175c2a57075bf56f8c9cbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PrintDocument p = new PrintDocument(); | |
if (options.PrinterName.Length > 0) | |
{ | |
p.PrinterSettings.PrinterName = options.PrinterName; | |
} | |
p.PrintPage += delegate(object sender1, PrintPageEventArgs e1) | |
{ | |
Font font = new Font(options.FontName, options.FontSize); | |
SolidBrush solidBrush = new SolidBrush(Color.Black); | |
string line; | |
int lineno = 0; | |
System.IO.StreamReader file = new System.IO.StreamReader(options.PrintFile); | |
while ((line = file.ReadLine()) != null) | |
{ | |
e1.Graphics.DrawString(line, font, solidBrush, new RectangleF(startX, startY + lineHeight * lineno, lineWidth, lineHeight)); | |
lineno++; | |
} | |
file.Close(); | |
}; | |
p.Print(); | |
p.Dispose(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment