从WinForms应用程序打印的最佳实践是什么?

时间:2022-07-03 20:04:51

I am looking for best practices in regards to printing from a WinForms application.

我正在寻找有关从WinForms应用程序打印的最佳实践。

  • What are the pitfalls?
  • 有什么陷阱?

  • What layout techniques work?
  • 什么布局技术有效?

  • Would it be easier to use WPF for printing (MSDN WPF Printing Overview)?
  • 使用WPF进行打印会更容易吗(MSDN WPF打印概述)?

In my particular case, I have an existing WinForms application that needs to be extended with printing functionality. The program should not just print the content on the screen, but take some of the data in the form and put it in a template and print that.

在我的特定情况下,我有一个现有的WinForms应用程序,需要使用打印功能进行扩展。程序不应该仅仅在屏幕上打印内容,而是将表格中的一些数据放入模板并打印出来。

Thanks, Egil.

2 个解决方案

#1


Broadly there are two main methods of printing in .NET. The original printing api which involves a callback on a method repeatably and you setting the arguments correctly (HasMorePages) to indicate whether there are more pages to print. It is pretty much all or nothing to use this API.

从广义上讲,在.NET中有两种主要的打印方法。原始打印api涉及对方法的回调,并且您正确设置参数(HasMorePages)以指示是否有更多页面要打印。使用此API几乎全有或全无。

The second involves the use of WPF and unlike the previous API. They have various level of complexity ranging from using a printvisual method on the elements of a WPF forms to the level of control in the regular printing API.

第二个涉及使用WPF,与之前的API不同。它们具有各种复杂程度,从使用WPF表单元素的printvisual方法到常规打印API中的控制级别。

The third alternative, especially for WinForms, is to use Printer Compatibility Library from the VB Power Pack 3.0 from here It restores the simplicity of the older methods of Visual Basic. Despite it focus on Visual BASIC.NET it can be referenced from any .NET language.

第三种选择,特别是对于WinForms,是从这里使用VB Power Pack 3.0中的打印机兼容性库它恢复了Visual Basic旧方法的简单性。尽管它专注于Visual BASIC.NET,但它可以从任何.NET语言中引用。

Another alternative is use something like Crystal Reports for your printing.

另一种方法是使用Crystal Reports等方法进行打印。

#2


One option would be using .net reportViewer control and .rdlc reports...

一种选择是使用.net reportViewer控件和.rdlc报告...

#1


Broadly there are two main methods of printing in .NET. The original printing api which involves a callback on a method repeatably and you setting the arguments correctly (HasMorePages) to indicate whether there are more pages to print. It is pretty much all or nothing to use this API.

从广义上讲,在.NET中有两种主要的打印方法。原始打印api涉及对方法的回调,并且您正确设置参数(HasMorePages)以指示是否有更多页面要打印。使用此API几乎全有或全无。

The second involves the use of WPF and unlike the previous API. They have various level of complexity ranging from using a printvisual method on the elements of a WPF forms to the level of control in the regular printing API.

第二个涉及使用WPF,与之前的API不同。它们具有各种复杂程度,从使用WPF表单元素的printvisual方法到常规打印API中的控制级别。

The third alternative, especially for WinForms, is to use Printer Compatibility Library from the VB Power Pack 3.0 from here It restores the simplicity of the older methods of Visual Basic. Despite it focus on Visual BASIC.NET it can be referenced from any .NET language.

第三种选择,特别是对于WinForms,是从这里使用VB Power Pack 3.0中的打印机兼容性库它恢复了Visual Basic旧方法的简单性。尽管它专注于Visual BASIC.NET,但它可以从任何.NET语言中引用。

Another alternative is use something like Crystal Reports for your printing.

另一种方法是使用Crystal Reports等方法进行打印。

#2


One option would be using .net reportViewer control and .rdlc reports...

一种选择是使用.net reportViewer控件和.rdlc报告...