Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900