【问题标题】:Display printDocument before printing / How to define PoinF打印前显示打印文档 / 如何定义 PointT
【发布时间】: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


【解决方案1】:

有一个简单的方法。添加printPreviewDialog 并提供您的文档路径。 printPreviewDialog1.Document = printDocument1;

You will find more info here.

【讨论】:

    猜你喜欢
    • 2013-04-05
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-23
    • 1970-01-01
    相关资源
    最近更新 更多