Print from console application

  • Follow


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 


0
Reply Frank 5/30/2010 12:04:31 PM

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
0
Reply Family 5/30/2010 12:19:14 PM


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/>
0
Reply Herfried 5/30/2010 4:59:07 PM

2 Replies
1034 Views

(page loaded in 0.029 seconds)

12/14/2014 9:49:01 AM


Reply: