I need a simple way to just send a string to the Print Preview document. I don't care about fonds, sizes, any of that. I just want to send vanilla text to a print preview window.
I have this:
Dim printPreviewDialog1 As New PrintPreviewDialog() ' instantiate new print preview dialog
printPreviewDialog1.Document = PrintMeString
printPreviewDialog1.ShowDialog() ' Show the print preview dialog
Which is wrong, because PrintMeString is a String. Everything I found online is way too complictaed for what I want to do. Any ideas?
Loading
Mike GoldPosted May 7, 2008, 10:15 PM
print preview works just like print. you need to assign a PrintDocument control to the print preview dialog. you need to handle the PrintPage event handler. You need to draw your string in the PrintPage event handler with a font.
e.Graphics.DrawString(myString, ...)
There are ways to print text directly to the printer using a print driver, but it requires PInvoke to call directly to the printer,and yes, this is efficient but much more complicated with .NET. It requires understanding the lower level print calls in the Windows SDK. If you are interested, however, there is article by microsoft on the topic:
http://support.microsoft.com/Default.aspx?kbid=322091