Hi, I'm running VB.Net code that prints the error file using DOS and it is plain text file. I want it to be more informative. I want to print the error file in HTML format with or without pictures or pdf format. Any help is appreciated.

Thanks

Recommended Answers

All 6 Replies

Try the following tutorial with sample code -

http://www.dreamincode.net/forums/topic/44150-printing-in-vbnet/

Thanks for the link, it is very helpful in printing the documents. I'm actually trying to print the hTML pages but it prints the source code of the html page, it doesnt print html content. Any suggestions in any methods or software for printing the actual html content is highly appreciated.

Thanks

Are you using a web control within your application?

Are you using a web control within your application?

I'm using Shell cmd. Here is the code for print
tempCmd = "C:\WINDOWS\system32\cmd /C print / \\198.168.1.100\HP LaserJet 4200 PCL 6 C:\Documents and Settings\My Documents\ROES_ERRORS" & temp
Shell(tempCmd, 0)
Threading.Thread.Sleep(5000)

Other than the code when i right click the html page and hit print, it prints the source code. I'm looking for code that can print the html content or any software that can solve this issue.

Thanks

If so, use the following -

'Declaration

Public Sub Print

' Prints the current document Imports the current print settings.
Private Sub printButton_Click( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles printButton.Click

    webBrowser1.Print()

End Sub

If not, then -

Your best (and, unfortunately, tedious) bet may be to use XSLT - there's good support in the System.Xml.Xsl namespace. Whether that's workable may depend on how well-formed and predictable your document is.

I would suggest using the IE WebBrowser Control to render & then print the file, though i'm not sure about the validity of this approach in light of .NET. there might be something newer & better... MSDN has some info about this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/wb_print.asp?frame=true. Also have a look at http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22956745.html. This might contain your answer. The following is in asp.net, might help out as well...
http://msdn.microsoft.com/en-us/library/bb250434(VS.85).aspx,

and lastly these -

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/018e7302-24bf-427b-8457-43d9aeb37725

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/1fef6a35-2837-4363-80e8-c9fbd33be603

http://social.msdn.microsoft.com/Search/en-US?query=print%20html%20in%20.net&ac=8

I'm sure there must be an answer for you in there. Happy coding.

Dude I'm using the same method...
for that you should make two HTML files
1. File to store actual HTML format of Invoice
(say original.html) which will act as template
2. File that gonna used over
(say bill_print.html)

steps
1. Copy All from original.html to bill_print.html
2. make changes in bill_print.html
"use some variable text replacment things"
3. navigate webbrowser control to bill_print.html
4. Print webbrowser control
- don't write anything to original.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.