From: Frank GTL on
Hi
I am trying to make my program send a page to a printer from my console
application.
I want to print the content of a string variable.

I have tried the following to print from a text file:

Dim myPrint as New PrintDocument
myPrint.DocumentName="C:\temp\MyTextDocument.txt"
myPrint.Print

This works, but the printed page is blank.

However - what I really need is to print a text string (several lines).

Any ideas?


best regards
Frank


From: Family Tree Mike on
On 5/30/2010 8:04 AM, Frank GTL wrote:
> Hi
> I am trying to make my program send a page to a printer from my console
> application.
> I want to print the content of a string variable.
>
> I have tried the following to print from a text file:
>
> Dim myPrint as New PrintDocument
> myPrint.DocumentName="C:\temp\MyTextDocument.txt"
> myPrint.Print
>
> This works, but the printed page is blank.
>
> However - what I really need is to print a text string (several lines).
>
> Any ideas?
>
>
> best regards
> Frank
>
>

Printing works the same in .Net, whether it is from a console app or
from a windows forms app. Try the example at
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx.
It's a bit more involved than you have shown.

--
Mike
From: Herfried K. Wagner [MVP] on
Am 30.05.2010 14:04, schrieb Frank GTL:
> I am trying to make my program send a page to a printer from my console
> application.
> I want to print the content of a string variable.
>
> I have tried the following to print from a text file:
>
> Dim myPrint as New PrintDocument
> myPrint.DocumentName="C:\temp\MyTextDocument.txt"
> myPrint.Print
>
> This works, but the printed page is blank.
>
> However - what I really need is to print a text string (several lines).

Handle the 'PrintDocument' object's 'PrintPage' event and send the text
to the printer there using 'e.Graphics.DrawString(...)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>