Skip to content
This repository has been archived by the owner on Apr 26, 2018. It is now read-only.

PrintDocument in .net core #10

Open
cex-pnaik opened this issue Aug 20, 2017 · 1 comment
Open

PrintDocument in .net core #10

cex-pnaik opened this issue Aug 20, 2017 · 1 comment

Comments

@cex-pnaik
Copy link

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.

@303248153
Copy link
Member

The bad news is, my version doesn't support printing on linux now,
although mono has linux printing support (with cups) but many code just not compatible with netstandard 1.5,
I may perform a update base on netstandard 2.0 later and see if that help.

And the good news is, net core 2.1 will bring official System.Drawing, you can wait for it.
https://github.com/dotnet/corefx/tree/master/src/System.Drawing.Common/src

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants