Printing html document from ST 
Author Message
 Printing html document from ST

Quote:

>I have an html document generated in Smalltalk.  I am have the need to print
>this document from a batch process where I cannot display a web browser with
>the html document first and have the user print from there.  I am using VA
>4.5 on Windows 95/98/NT.  Any ideas on how to print the html document would
>be appreciated.

>Thanks,
>Kevin Badinger


I have been trying to solve this problem as well (on VW, however). My solution depends on the
Document and DocumentRenderer classes, which are relatively straightforward, and there should be
equivalent stuff in VA.

To summarize:

The Document class builds a "display list" of messages (e.g. #startParagraph:, #addText:,
#addImage:) and then asks a DocumentRenderer to render the list. DocumentRenderer draws to a
Printer graphics context, and actually implements the display list methods.

My approach has been to use the XML parser from InDelv ( http://www.*-*-*.com/ ) to build an HTML
parse tree. This code is based on Smallwalker, but the original author appears to be immersed in
building new Java foundation classes and does not appear to be able to support this stuff.
However, this code also seems to be part of the Squeak release, so I am not worried that I will
be the only one using it.

I subclassed Document and DocumentRenderer to meet my needs (e.g. adding a lookup dictionary for
tags and building rendering primitives for tables, horizontal rules, etc.). When one of these
tags is hit, my user agent displays the HTML appropriately for my printing requirements.

Unfortunately, there are a few problems.

(1) The parser is not as forgiving as most of us are used to in dealing with bad HTML (i.e.
compared to commercial browsers). As far as I have been able to see, does not actually
understand any of the semantics of the tags, it just looks for <TAG> </TAG> pairs to build up
the nodes in the parse tree.

(2) There are some HTML tags which are not containers (e.g. <BR>, <HR> and others such as <P>
and <TR> which have optional end tags). These wind up being treated as "root" tags when they
should be peers with their children (I need to look into this further). This means I have to
walk back up the tree when I should not need to, but I guess this may be why they are pushing
for XML to replace HTML.

(3) The W3C DOM spec is IDL-based, and does not really have a Smalltalk feel to it (e.g. the
NodeList class is particularly stupid). I am not sure if I should extend these classes or if I
should rigorously adhere to the SPEC (heil zero-origin array accessing!).

I am in the process of trying to resolve this problem as elegantly as possible (i.e. by writing
as little code as possible). Take a look at this stuff and let me know if this approach makes
sense for what you are trying to do.

Steve



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Print only a specific control or indicator on a front panel to HTML document

2. printing multiple html documents

3. printing html document with internet explorer

4. Q: Viewing/Printing HTML documents in Tcl

5. wanted: IBM ST/VA 2.0 Documents

6. Writing a multi-document app in ST/V for Mac

7. Viewing the HTML documents

8. Displaying an HTML Document *on the front panel*

9. ATLAST for dynamic html documents

10. Library to use html-documents as help

11. HTML Groups/documents???

12. VRML in an HTML document

 

 
Powered by phpBB® Forum Software