Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing support in .net core

My .net framework 4 service is using PrintDocument class of System.Drawing.Printing for printing.

How can I achieve this in .net core. I am not able to find System.Drawing.Printing in .net core.

Can someone guide me on this?

like image 351
Purnima Naik Avatar asked Aug 26 '16 08:08

Purnima Naik


People also ask

How do I print in .NET core?

To print the Grid, use the print method from grid instance. The print option can be displayed on the toolbar by adding the Print toolbar item.

Does print work in C#?

In C# you can write or print to console using Console. WriteLine() or Console. Write(), basically both methods are used to print output of console.

What is print command in C#?

Through command line arguments, users of the program can pass it values. Console. WriteLine("This is C#"); In this code line, we print the "This is C#" string to the console. To print a message to the console, we use the WriteLine method of the Console class.


3 Answers

.NET Core 3 supports System.Drawing.Printing

I have an app sorta working on Linux now. I'm experiencing some weirdness which led me to this question.

FWIW, my app is a pretty complete example of how to use the System.Drawing.Printing APIs. Find it here: https://github.com/tig/winprint

like image 102
tig Avatar answered Oct 10 '22 00:10

tig


One option is to split monolithic service(s) into multiple microservices and run your .NET Core app under i.e. Linux and let your print service on windows and have the .NET Core service call into the print service when it needs to print something

like image 34
Tseng Avatar answered Oct 09 '22 23:10

Tseng


System.Drawing is windows-dependent and excluded from cross-platform NETStandard libraries (not available for .NET Core apps).

As alternative you may consider composing PDF or PS document (for instance, wkhtmltopdf tool can convert HTML pages to PDF/PS formats) and sending it to printer with OS-specific command line tool (for linux this might be "lp" command; for windows PowerShell "lpr").

like image 36
Vitaliy Fedorchenko Avatar answered Oct 10 '22 00:10

Vitaliy Fedorchenko