Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Drawing.Printing;
- using System.Windows.Forms;
- namespace R814ImprimirDocumento
- {
- public partial class Principal : Form
- {
- public Principal()
- {
- InitializeComponent();
- }
- private void btnImprimirDocumento_Click(object sender, EventArgs e)
- {
- PrintDocument documento = new PrintDocument();
- documento.PrintPage += this.Documento_PringPage;
- PrintDialog dialogoImpresion = new PrintDialog();
- dialogoImpresion.Document = documento;
- if (dialogoImpresion.ShowDialog() == DialogResult.OK)
- {
- documento.Print();
- }
- }
- private void Documento_PringPage(object sender, PrintPageEventArgs e)
- {
- using (Font fuente = new Font("Trebuchet", 30))
- {
- float x = e.MarginBounds.Left;
- float y = e.MarginBounds.Top;
- float altoLinea = fuente.GetHeight(e.Graphics);
- for (int i = 0; i < 5; i++)
- {
- e.Graphics.DrawString("Línea de texto no. " + i.ToString(), fuente, Brushes.Black, x, y);
- y += altoLinea;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement