![]() |
Click here to advertise with us
|
|
|||||||
| Reporting / Printing Discussion on output-creation components such as reporting, pdf, etc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
|
||||
|
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()
Code:
Dim p As New Process Dim info As New ProcessStartInfo info.FileName = "test.txt" info.Verb = "print" p.StartInfo = info p.Start()
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
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 |
|
||||
|
You would have to use the first option, it's printing with the .Net PrintDocument class.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
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? |
|
||||
|
You have copy the TextPrint class (="type") I linked to and add to your project.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|