I am trying to find how to print a picture (as in on paper) in C#. I'm trying to keep it very simple. So no use of WinForms and just using Console output.
I looked for an answer myself, but couldn't make sense of any of the results.
Writing in Console App 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.
Console applications are used primarily for text only applications. There is no way to display an image. You could launch another application which does display the image. This other application would most likely need to support a command line option to pass an image to it.
Print PDF as an image Printing a PDF file as an image bypasses that processing by sending the printer a simple image of the document instead. This process can cause images and fonts to look slightly rougher, especially at the edges. However, you can specify the resolution in dots per inch (dpi) to suit your needs.
Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.
You necessarily don't need a WinForm application to do printing. JUst use PrintDocument and DrawImage class and you can do somthing like this:
PrintDocument pd = new PrintDocument();
pd.PrintPage += (thesender, ev) => {
ev.Graphics.DrawImage(Image.FromFile("Your Image Path"),
//This is to keep image in margins of the Page.
new PointF(ev.MarginBounds.Left,ev.MarginBounds.Top));
};
pd.Print();
Hope that Helps. (I have used Lambada and Anonymous Delegate to handle the Event, I f you dont understand that please tell i will post the normal version)
Isn't it as simple as sending the byte stream of the picture to a C# printing library? just like how you would print any other document, like a PDF say, which is actually a collection of images. And the settings of say alignment, layout, B/W or color will then be printer-specific.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With