问题描述
我正在尝试使用 Mono 加载位图并在 Linux 上打印它,但我遇到了异常.Mono 是否支持在 Linux 上打印?代码/异常如下:
I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below:
不再出现异常,但我仍然很好奇有什么样的支持.留下代码供后代使用.
No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something.
private void btnPrintTest_Click(object sender, EventArgs e)
{
_printDocTest.DefaultPageSettings.Landscape = true;
_printDocTest.DefaultPageSettings.Margins = new Margins(50,50,50,50);
_printDocTest.Print();
}
void _printDocTest_PrintPage(object sender, PrintPageEventArgs e)
{
var bmp = new Bitmap("test.bmp");
// Determine center of graph
var xCenter = e.MarginBounds.X + (e.MarginBounds.Width - bmp.Width) / 2;
var yCenter = e.MarginBounds.Y + (e.MarginBounds.Height - bmp.Height) / 2;
e.Graphics.DrawImage(bmp, xCenter, yCenter);
e.HasMorePages = false;
}
推荐答案
来自 Mono 文档,我认为是的:
Managed.Windows.Forms(又名System.Windows.Forms):一个完整且跨平台,基于 System.DrawingWinforms 实现.
Managed.Windows.Forms (aka System.Windows.Forms): A complete and cross platform, System.Drawing based Winforms implementation.
如果您先运行 Mono 迁移分析器,它也很有用.
It also useful if you run the Mono Migration Analyzer first.
这篇关于Mono 是否支持 System.Drawing 和 System.Drawing.Printing?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!