在C#中打印(wpf) [英] Printing in C# (wpf)

查看:41
本文介绍了在C#中打印(wpf)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个C#WPF程序,我的程序必须能够打印发票,但是我有点努力寻找在WPF中打印的工作方式...如果我对winforms编程的印象很深,那您将使用GDI +进行打印.但是,我认为WPF并非如此.

I'm making a C# WPF program, and my program has to be able to print invoices, but I'm kinda struggling to find out how printing works in WPF... If I remember well from programming in winforms, there you'd use GDI+ to print. However, I assume that's not the case with WPF.

如果有人可以通过指向一些有用文档或示例的链接将我指向正确的方向,我将非常高兴...

I would be very happy if someone could point me in the right direction with some links to helpful documents or examples...

推荐答案

在WPF中打印既简单又不那么简单.

Printing in WPF is both simple and not so simple.

它首先从您已经在打印的一两行代码开始.

It starts with basically with one or two lines of code you are printing already.

private void PrintBtn_Click(object sender, RoutedEventArgs e)
{
    PrintDialog printDialog = new PrintDialog();
    if (printDialog.ShowDialog() == true)
    {
    printDialog.PrintVisual(grid, "My First Print Job");
    }
}

但是,WPF中的分页不是用一行代码完成的.然后进入FlowDocuments和类似的更高级的主题.

However, pagination in WPF is not done with a single line of code. Then you get into FlowDocuments and similar more advanced topics.

如果您要为自己制作非商业工具,请考虑 iTextSharp ,这非常好也是.

If you are making a non-commercial tool for yourself, consider iTextSharp which is very good too.

这篇关于在C#中打印(wpf)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆