473,569 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing HTML in VB .NET

What i am trying to accomplish is programatically creating Invoices and then
Printing them out. I don't really need to "View" them before they print.

How I am trying to do this is I have created a "Template" of the invoice in
HTML. Througout the text of the HTML are keywords or variables. I load this
in .NET with a streamreader, edit the string to find/replace the keyword
(variable) with the value (example: in the string are the characters
"INVNUM". So, i find "INVNUM" and replace it with "123456", or whatever the
invoice number is).

When it is done, i use a streamwriter to create a "Text" file with the HTML
Code.

Then I use a WebBrowser class to Load (myWebBrowser.U RL = New
URI("Path\Of\HT MLFile.HTML")

and create an Event Handler (myWebBrowser.D ocumentComplete d) to print the
file when it is done loading. WebBroswer (myWebBrowser.P rint).

This works perfect if there is only one invoice. However, i use a loop
(either for/next or while) to iterate through a database, and create all the
invoices. Instead of printing after each one, it seems like the
myWebBrowser.Do cumentCompleted event is not raised until the entire routine
(thus All of the invoices) are loaded.

If I have a couple html files, it still works, however as soon as i have
more than a few, the program crashes.

Any suggestions on how to accomplish this? Either have the html file sent
to the printer after each one is created (instead of at the end) or even
another method? I'm not married to HTML, but this seemd the easiest way to
create/edit on the fly and make it pretty as well.

Thank you
MATT
Apr 18 '07 #1
2 9059
=?Utf-8?B?TUFUVA==?= <MA**@discussio ns.microsoft.co mwrote in
news:93******** *************** ***********@mic rosoft.com:
This works perfect if there is only one invoice. However, i use a
loop (either for/next or while) to iterate through a database, and
create all the invoices. Instead of printing after each one, it seems
like the myWebBrowser.Do cumentCompleted event is not raised until the
entire routine (thus All of the invoices) are loaded
I believe each instance of the web browser control spawns an IE session
under the covers... so it's not all that "efficient" . It's probably best to
load documents in series (one by one) rather than in parallel.

There are a couple 3rd party components that are designed to print HTML...
but I'm not sure what rendering engine these use, so I'm not sure what the
quality is like. These components might be worth a look if you need higher
performance.
Apr 18 '07 #2
Matt,

Could you save the html into a temp file and then call
Process.Start(T emp.html,"print ")?

I think this may instantiate IE for each print job, but it will close
afterward.

You might also try to WebBrowser.Navi gate("about:bla nk") +
Application.DoE vents between invoices and see if that helps.

Rick
"MATT" <MA**@discussio ns.microsoft.co mwrote in message
news:93******** *************** ***********@mic rosoft.com...
What i am trying to accomplish is programatically creating Invoices and
then
Printing them out. I don't really need to "View" them before they print.

How I am trying to do this is I have created a "Template" of the invoice
in
HTML. Througout the text of the HTML are keywords or variables. I load
this
in .NET with a streamreader, edit the string to find/replace the keyword
(variable) with the value (example: in the string are the characters
"INVNUM". So, i find "INVNUM" and replace it with "123456", or whatever
the
invoice number is).

When it is done, i use a streamwriter to create a "Text" file with the
HTML
Code.

Then I use a WebBrowser class to Load (myWebBrowser.U RL = New
URI("Path\Of\HT MLFile.HTML")

and create an Event Handler (myWebBrowser.D ocumentComplete d) to print the
file when it is done loading. WebBroswer (myWebBrowser.P rint).

This works perfect if there is only one invoice. However, i use a loop
(either for/next or while) to iterate through a database, and create all
the
invoices. Instead of printing after each one, it seems like the
myWebBrowser.Do cumentCompleted event is not raised until the entire
routine
(thus All of the invoices) are loaded.

If I have a couple html files, it still works, however as soon as i have
more than a few, the program crashes.

Any suggestions on how to accomplish this? Either have the html file sent
to the printer after each one is created (instead of at the end) or even
another method? I'm not married to HTML, but this seemd the easiest way
to
create/edit on the fly and make it pretty as well.

Thank you
MATT

Apr 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2206
by: Mark Preston | last post by:
Admission first - I don't actually have a problem here but have noticed that a lot of people have been asking similar questions and getting very varied answers. What I've done is to sort of "compile the questions" into a theoretical problem to see what people think should be done to solve it. Maybe it will be a worthwhile discussion, but...
7
2478
by: Dennis C. Drumm | last post by:
I was wondering if someone could suggest were/how I could get started with setting up printing of a collection of text that includes tables from a grid and other supporting information about the grid's contents. If you could just point me at the classes that I should consider and some very broad guidelines that would be great. For instances,...
3
2404
by: Ahmad Abu-Raddad | last post by:
Hey Guys, Does anyone knows of a way to print HTML source directly to the printer (Server Side)?. I tried the PrintDocument class and the e.Graphics.DrawString and e.Graphics.DrawImage() but these does not take HTML. If anyone can help please do.
1
1737
by: Raymond Du | last post by:
Hi, I have serveral web forms used by users, these users often use IE browser print function to print out the form, the problems I have is what users see on the screen is usually different from what's being printed. Somtimes it looks good on screen, but it wraps differently in printing. How do I format the HTML so it will look the same in...
7
1676
by: Amirallia | last post by:
Hello! I have a wecontrol table in a page, this table has a number of variable rows depending of the choice of the user. But when the table has a large number of rows, the printing of the page requires 2 pages . The first page is ok, but in the second page of the printing I have no ligne of the row and no ligne of the column printing on...
2
2876
by: Jurjen de Groot | last post by:
I'm about to start a new ASP.NET application, this application will generate several types of documents (PDF HTML XML-DOC) wich have to be printed at the client-side... (probably on different printers A3 and A4 type) At this time I'm trying to figure out what would be the best way to accomplish this : 1. printing through HTML in a IE...
12
6341
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but of course it's thrown up a whole host of new issues... I'm generating a multi page printable document in HTML from my app, and displaying it in a...
4
5890
by: Lucas Ponzo | last post by:
Hi All, I have an ASP.NET 2.0 app. The users access the pages, uniquely via pocket pc ... I need to print a page. But I need that the page print on a printer installed on the web server hosting my application. Step 1) The user clicks the Print icon in the web page
8
5879
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web clients (Internet Explorer). My flash content was originally brought in via the “flash satay” method, but I have since used some server-side magic...
0
2217
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom application specific headers are to be added in the print out. Problem: The System.Drawing.Printing namespace .Net provides objects and dialogs to take care...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.