【发布时间】:2015-09-17 12:01:58
【问题描述】:
我在 c# windows 应用程序 WinForms 中使用 PrintDialog 和 PrintDocument 来打印文档。
打印工作正常,但我想在打印前显示文档,以便检查 PointF for DrawString 是否符合我的要求。我该怎么做?是否有任何工具可以轻松地在 A4 文档上定义 pointF?
private void buttonPrintShows_Click(object sender, EventArgs e)
{
PrintDialog pd = new PrintDialog();
pd.Document = printDocumentStatistic;
if (pd.ShowDialog() == DialogResult.OK)
{
printDocumentStatistic.Print();
}
}
private void printDocumentStatistic_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("Shows:",new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(35, 50));
e.Graphics.DrawString("Act:", new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(35, 75));
e.Graphics.DrawString(show_name, new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(100, 50));
e.Graphics.DrawString(akt_name, new System.Drawing.Font("Arial", 20f), new SolidBrush(Color.Red), new PointF(100, 75));
}
【问题讨论】:
-
谢谢,它有帮助。不过,我如何定义我想要的点?有比手动计数更简单的方法吗?
标签: c# winforms printing point drawstring