【问题标题】:Save WinForm to PDF & print multipage WinForm [closed]将 WinForm 保存为 PDF 并打印多页 WinForm [关闭]
【发布时间】:2010-01-20 12:50:35
【问题描述】:

如何将多页 WinForm 保存为 PDF 以及如何打印?

谢谢, 关门

【问题讨论】:

    标签: c# .net winforms pdf


    【解决方案1】:

    一个好的框架是pdfSharp

    您可以捕获表单(有几种方法可以做到这一点,this 就是一个示例)。 比将图像流写入一个 pdf 对象(您可以在 pdfSharp 网站上找到许多示例)。

    【讨论】:

      【解决方案2】:

      您可以使用paint方法来捕获Form的整个客户区域,然后使用Print方法来打印它们。

       Graphics myGraphics = this.CreateGraphics();
       Size s = this.Size;
       memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
       Graphics memoryGraphics = Graphics.FromImage(memoryImage);
       memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
      

      然后使用 PrintDocument 类进行打印。

      【讨论】:

        猜你喜欢
        • 2012-09-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-28
        • 2020-12-23
        相关资源
        最近更新 更多