Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- Print();
- }
- public void Print()
- {
- PrintDocument my_doc = new PrintDocument();
- my_doc.PrintPage += new PrintPageEventHandler(this.PrintPage);
- PrintPreviewDialog my_preview = new PrintPreviewDialog();
- my_preview.Document = my_doc;
- my_preview.ShowDialog();
- my_doc.Dispose();
- my_preview.Dispose();
- }
- private void PrintPage(object sender,
- System.Drawing.Printing.PrintPageEventArgs e)
- {
- e.Graphics.PageUnit = GraphicsUnit.Pixel;
- string s = "String height is ";
- SizeF h = e.Graphics.MeasureString(s, new Font("Arial", 24));
- e.Graphics.DrawString(s + Convert.ToString(h.Height),
- new Font("Arial", 24), new SolidBrush(Color.Black), 1, 1);
- }
- SizeF hT = TextRenderer.MeasureText(s, new Font("Arial", 24));
Add Comment
Please, Sign In to add comment