Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > Components & Controls > Reporting / Printing

Reporting / Printing Discussion on output-creation components such as reporting, pdf, etc.

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-14-2007, 7:12 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2007
Posts: 14
Reputation: 39
InDistress is on a distinguished programming path ahead
Default How to print a txt file

Howdy all,

Can anyone help me with some code that will print a txt file without any dialogue boxes?

The file path is C:\test.txt

I've scoured google and can't quite find what I'm looking for.


Thanks in advance
InDistress
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-14-2007, 11:01 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,328
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

Here is a plain text printing class 'TextPrint' by Karl Moore http://www.developer.com/net/net/article.php/3102381
It could be used as follows:
Code:
 
Dim tp As New TextPrint(My.Computer.FileSystem.ReadAllText("test.txt"))
tp.Print()
You can also call the OS to print the file with default application (usually Notepad for .txt files):
Code:
 
Dim p As New Process
Dim info As New ProcessStartInfo
info.FileName = "test.txt"
info.Verb = "print"
p.StartInfo = info
p.Start()
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-14-2007, 5:30 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2007
Posts: 14
Reputation: 39
InDistress is on a distinguished programming path ahead
Default

Cheers for that JohnH - it worked a treat. As a off spin question, is there any way that I can prevent the screen from displaying the textfile before it prints? Whenever ever I hit the print button, it brings the text file into view for a brief second and then disappears - I guess I just want it to look seemless to the user.


Cheers
InDistress
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-14-2007, 6:12 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,328
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

You would have to use the first option, it's printing with the .Net PrintDocument class.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-14-2007, 6:37 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2007
Posts: 14
Reputation: 39
InDistress is on a distinguished programming path ahead
Default

Hi John,

I tried your first print option that you mentioned and it didn't seem to pickup the 'TextPrint' portion of the code. It tells me that the Type 'TextPrint' is not defined.

Here's what I've been using

Dim tp As New TextPrint(My.Computer.FileSystem.ReadAllText("C:\t est.txt"))

Any suggestions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-14-2007, 7:06 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,328
Reputation: 1315
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

You have copy the TextPrint class (="type") I linked to and add to your project.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-14-2007, 7:34 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Mar 2007
Posts: 14
Reputation: 39
InDistress is on a distinguished programming path ahead
Default

CHAMPION!!! Thanks John - works like a charm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 12:30 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.