Buenas:
Quiero imprimir un folio, una hoja con la consola en C#, no con Windows Form.
Aquí hay un ejemplo pero es con Windows Form en el cual no me interesa.
https://msdn.microsoft.com/es-es/lib...code-snippet-2
He modificado el código así un poco.
Código:
using System;
using System.IO;
namespace Impresora_Consola_01
{
class Program
{
static void Main(string[] args)
{
void Printing(string printer)
{
try
{
streamToPrint = new StreamReader(@"Hola amigo.");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
// Specify the printer to use.
pd.PrinterSettings.PrinterName = printer;
if (pd.PrinterSettings.IsValid)
{
pd.Print();
}
else
{
Console.WriteLine("Printer is invalid.");
}
}
finally
{
streamToPrint.Close();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
}
Cuando ejecutes el ejecutable, lo que tiene que hacer, buscar una impresora que tenga dispuesta, y imprima solo un folio. El mensaje que imprime una hoja es este:
Hola amigo.
Solo te he gastado un folio.
¿Es posible hacer en modo consola o tiene que ser si o si con Windows Form?
Saludos.
Marcadores