Col*_*son 6 .net c# printing image console-application
我试图找到如何在C#中打印图片(如在纸上).我试图保持它非常简单.因此,不使用WinForms并仅使用控制台输出.
我自己寻找答案,但无法理解任何结果.
您一定不需要WinForm应用程序来进行打印.JUst使用PrintDocument和DrawImage类,你可以做这样的事情:
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();
Run Code Online (Sandbox Code Playgroud)
希望有助于.(我已经使用Lambada和Anonymous Delegate来处理事件,我不明白,请告诉我将发布正常版本)