G
Guest
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.URL = New
URI("Path\Of\HTMLFile.HTML")
and create an Event Handler (myWebBrowser.DocumentCompleted) to print the
file when it is done loading. WebBroswer (myWebBrowser.Print).
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.DocumentCompleted 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
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.URL = New
URI("Path\Of\HTMLFile.HTML")
and create an Event Handler (myWebBrowser.DocumentCompleted) to print the
file when it is done loading. WebBroswer (myWebBrowser.Print).
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.DocumentCompleted 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