WPF打印 - 如何打印文本以便打印驱动程序将其识别为TEXT [英] WPF Printing -- how do I print text so print driver recognizes it as TEXT

查看:110
本文介绍了WPF打印 - 如何打印文本以便打印驱动程序将其识别为TEXT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个打印应用程序(在WPF / VB.NET中),它使用以下方法(煮沸的样本)进行打印:



 Dim fd As New FixedDocument()
Dim pc As New PageContent()
Dim fp As New FixedPage()

Dim tb As TextBlock = New TextBlock
tb .Text =T PLAN TEXT,K PLANE?
tb.FontFamily = New System.Windows.Media.FontFamily(Arial)
tb.FontStyle = FontStyles.Normal
tb.FontSize = 32
tb.FontWeight = FontWeights .Bold
tb.Foreground = Brushes.Black

'将文本框添加到FixedPage
fp.Children.Add(tb)
'将FixedPage添加到PageContent
pc.Child = fp
'将PageContent添加到FixedDocument
fd.Pages.Add(pc)

Dim printDialog As New PrintDialog()
printDialog.PrintDocument(fd.DocumentPaginator,NB Card Print Job)





问题是,它不会将文本打印为TEXT对象;它被封装,使得打印机不会将其识别为文本。那么,如何打印文本以便打印机驱动程序识别文本存在?



我的要求:

- 必须具有双面打印功能打印

- 必须能够支持OpenType字体系列(以及TrueType)

- 必须能够打印图像和矢量图形

- 必须具有强大的文本格式功能



如果它有助于了解原因:

我有一个使用的打印应用程序使用覆盖色带打印到卡片打印机。简单地说,它有一个特殊的色带,用于打印某些东西,通常是文字,用炭黑和他们称之为K平面的东西。要以典型的方式使其工作,您必须将文本对象发送到打印机。

解决方案

您可以将整个屏幕保存为图像,然后发送打印







其他选项







在WPF中打印既简单又不那么简单。但是要指出一篇很容易找到谷歌的介绍文章,请看这里(http://www.eggheadcafe.com/tutorials/aspnet/9cbb4841-8677-49e9-a3a8-46031e6​​99b2e/wpf-printing-and-print-pr .aspx)。



基本上,您已经打印了一两行代码。



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



如果你正在为自己制作一个非商业工具,请考虑iTextSharp也非常好。 (http://sourceforge.net/projects/itextsharp/)





这些链接可以帮助您了解打印的工作原理和内容确切使用:



http://www.charlespetzold.com/blog/2006/02/201111.html



http://msdn.microsoft.com/en-us/library/ms742418.aspx



http://www.switchonthecode.com/教程/打印进行中WPF

I have a print application (in WPF/VB.NET) that uses the following method (boiled down sample) to print:

Dim fd As New FixedDocument()
Dim pc As New PageContent()
Dim fp As New FixedPage()

Dim tb As TextBlock = New TextBlock
tb.Text = "TEST TEXT, ON K PLANE?"
tb.FontFamily = New System.Windows.Media.FontFamily("Arial")
tb.FontStyle = FontStyles.Normal
tb.FontSize = 32
tb.FontWeight = FontWeights.Bold
tb.Foreground = Brushes.Black

'add the text box to the FixedPage
fp.Children.Add(tb)
'add the FixedPage to the PageContent
pc.Child = fp
'add the PageContent to the FixedDocument
fd.Pages.Add(pc)

Dim printDialog As New PrintDialog()
printDialog.PrintDocument(fd.DocumentPaginator, "NB Card Print Job")



The problem is, it does NOT print the text as a TEXT object; it is encapsulated such that the printer doesn't recognize it as text. So, how can I print text such that the printer driver recognizes that text is present?

My Requirements:
-- must have duplex printing
-- must be able to support OpenType font families (as well as TrueType)
-- must be able to print images and vector graphics
-- must have robust text formatting capabilities

In case it helps to know why:
I have a print application that is used to print to a card printer with an overlay ribbon. Simply put, it has a special ribbon for printing certain things, usually text, in carbon black with what they call the K Plane. To get this to work in the typical way, you have to send text objects to the printer.

解决方案

you can save the whole screen as an image, and send that to print



Other options



Printing in WPF is both simple and not so simply. But to point you to an introduction article, easily found with google, look here ( http://www.eggheadcafe.com/tutorials/aspnet/9cbb4841-8677-49e9-a3a8-46031e699b2e/wpf-printing-and-print-pr.aspx ).

Basically, with one or two lines of code you are printing already.

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

If you are making a non-commercial tool for yourself, consider iTextSharp which is very good too. ( http://sourceforge.net/projects/itextsharp/ )


These links may help you in understanding how printing works and what exactly to use:

http://www.charlespetzold.com/blog/2006/02/201111.html

http://msdn.microsoft.com/en-us/library/ms742418.aspx

http://www.switchonthecode.com/tutorials/printing-in-wpf


这篇关于WPF打印 - 如何打印文本以便打印驱动程序将其识别为TEXT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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