将WinForm保存为PDF并打印多页WinForm

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

谢谢,Ofir

一个好的框架是pdfSharp 。

您可以捕获表单(执行此操作的方法很少, 这是一个示例)。 然后将图像流写为pdf对象(您可以在pdfSharp网站上找到许多样本)。

您可以使用绘制方法捕获表单的整个客户区域,然后使用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类进行打印。