Link to home
Start Free TrialLog in
Avatar of Member_2_3254
Member_2_3254

asked on

HTML printing from browser control

Background
My (Visual Basic 6) application uses IE's webbrowser control (embedded) to render/view HTML reports. I am not happy with the printing support from the control. I have the following specific problems:
1) THEAD/TFOOT tags does not repeat on the next page when a table is split accross printed pages (as the HTML specification says it should)
2) Lines are sometimes lost at page breaks - this depends on the margin settings & printer driver
3) Very tricky to set page orientation/margins etc. from VB code before using the ExecWB...PRINT method of the browser to do the actual printing (especially if you have to cater for different IE versions).


I am looking for something that will help with all three of the problems above . . .

These are some of the things I am considering:
a) Convert the HTML to some other format (PDF/Rich Text/Postscript) using some conversion tool (?) and then printing the "result"
   --> which format?, which converter?
   --> does these formats (and the tools that goes with them) fix my problems
       ie. does the PDF specification allow for tables with column headers, and the automatic re-print of headers on the "next" page
       how tricky is it to print these formats (from VB code), can one get at the page-setup properties from code (will probably depend on what tool does the actual printing)
   --> I get the feeling that this option will introduce more _new_ problems than it will solve

b) IE Print templates
   --> this one promises a lot but the samples & documentation (MSDN) is somewhat vague - seriously steep learning-curve to try and understand the technology (and all that just to determine if it may be the answer to my problem)
   --> any experts on this subject that can say yea or nea?

c) code my own parser & print logic (we use a very small subset of HTML, mainly <TABLE> stuff)

Any other options that anyone can think of ?


I am cross-posting this one to the HTML and Browser Issues groups

I doubt anyone will give a complete answer, will distribute points between most helfull comments.


ASKER CERTIFIED SOLUTION
Avatar of Sethi
Sethi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_3254
Member_2_3254

ASKER

I believe it is is possible to access print templates from VB
(commercial ActiveX controls are available that wraps the functionality, see http://www.eztools-software.com)


It sounds as if you got _some_ joy from using @Print and @Media (I have not heard of this before, will have a look)
My code uses Internet Explorer's browser control, so I am not concerned with the functionality of "other" browsers - if I can get it to work on IE then I'll be happy . . .
If some Commercial ActiveX control is providing you Print Templates functionality then it may be possible. My comment clearly stated that:- "IE print templates can only be created through C++". If you want to go for Coomercial options and are ready to spend mony for printing purposes then google is there for you. You will get umpteen no. of componenets for this purpose.

If you have gone through the links I have provided you and if you go through the comment I have posted again then you will see that I am pointing my finger to IE again and again considering it to be the most popular one and not at any other browser.
Thnx Sethi,

The control mentioned will only give me access to print templates - I do no (yet) know if templates is the answer to my problems (I know too little about the technology)

I spent some time looking at commercial tools - none of which claims to be able to solve all my problems - most of them leverages the IE print engine, which means that the problems with THEAD/TFOOT will still be there.

I'll even be willing to switch browsers if the other browser has a component that can be embedded on a VB form, and has a print engine that handles my specific problems better

Enricos,

when I had to do this, I found the best way was to save the HTML document and open it in a MS Word object. This tends to print a lot better, but I know that others have had problems doing it this way. For example, list items do not always appears as expected.

If you want some code samples let me know and I'll dig some up.

Regards

bukko
I had hoped to get a lot more people responding . . .

The _excellent_ grading does NOT mean I like your answer    ;)
The answer to problem #1 is to add a style attribute to the thead tag as follow:

<THEAD STYLE='display: table-header-group'>

This will cause the contents of thead to repeat on each printed page.

Matt