using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ImprimirImagen_I
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Salir
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
// Abrir Fichero
private void button3_Click(object sender, EventArgs e)
{
using (OpenFileDialog abrir = new OpenFileDialog()
{
Filter = "jpg|*.jpg", ValidateNames = true})
{
if (abrir.ShowDialog() == DialogResult.OK)
pictureBox1.Image = Image.FromFile(abrir.FileName);
}
}
//Imprimir Fichero
private void button2_Click(object sender, EventArgs e)
{
PrintDialog dialogoimpresion = new PrintDialog();
PrintDocument documento = new PrintDocument();
documento.PrintPage += Doc_PrintPage;
dialogoimpresion.Document = documento;
if (dialogoimpresion.ShowDialog() == DialogResult.OK)
documento.Print();
}
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
Bitmap mapadebits = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.DrawToBitmap(mapadebits, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
e.Graphics.DrawImage(mapadebits, 0, 0);
mapadebits.Dispose();
}
}
}
Llegados a este punto elegimos la impresora que queramos, incluso lo podemos guardar como PDF.
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.