You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2018. It is now read-only.
I want to use PrintDocument in .net core. Is there any way through which I can achieve that?
I want the following implementation:
public void Print()
{
PrintDocument pdPrint = null;
using (pdPrint = new PrintDocument())
{
pdPrint.PrinterSettings.PrinterName = printerName;
pdPrint.DefaultPageSettings.PaperSize = paperSize;
pdPrint.PrintPage += new PrintPageEventHandler((sender, e) => PrintPage(sender, e);
pdPrint.Print();
}
}
private void PrintPage(object sender, PrintPageEventArgs e)
{
float x, y, lineOffset;
Font printFontA = new Font("Microsoft Sans Serif", Convert.ToSingle(11), FontStyle.Bold, GraphicsUnit.Point); // Substituted to FontA Font
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Far;
e.Graphics.PageUnit = GraphicsUnit.Point;
//Specify the line spacing between lines
lineOffset = printFontA.GetHeight(e.Graphics);
//Specify the starting position for printing
x = 50;
y = 50;
e.Graphics.DrawString("****Test****", printFontA, Brushes.Black, x, y);
}
My aim is to do printing in Linux using 'PrintPageEventArgs', can you please suggest me a way.