Creating HTML Screenshots from Thomas Dickey's XFree86 XTerm

Update 2016-03-29:

Jens Schweikhardt informed me about the following (I roughly translated along his email), thanks for letting me know!

Meanwhile xterm has implemented its own screen shot functionality:
Since patch level 323 there is an --enable-screen-dumps configure option,
so that the "Main Options" menu shows new entries "XHTML Screen Dump" and "SVG Screen Dump".
These actions create the respectice files{xhtml,svg}
You can also trigger this with control sequences:

    CSI Pm i  Media Copy (MC).
            Ps = 0  -> Print screen (default).
            Ps = 4  -> Turn off printer controller mode.
            Ps = 5  -> Turn on printer controller mode.
            Ps = 1  0  -> HTML screen dump.
            Ps = 1  1  -> SVG screen dump.

End of Update.

That makes it a lot easier indeed.

(At the time of this writing [2002] a terminalemulator-independent solution, using OCR with perl's Image::Magick, can be found at Christoph Biedl's page.
Update: link broken. See the saved page in the Wayback Machine.)

But here is a solution converting direct output from the print action of Thomas Dickey's xterm, i.e., the XFree86 xterm..

You need:

In the following there are "screenshots" listed from

And by the way:

With HTML 3.2 tables (here with empty header line) and bgcolor attributes in table cells:

(IMHO opera-5b1(SunOS) and -6tp2(Linux) are not really accurate in table rendering. You might get better results by choosing a normal font not bigger than size 10, because opera uses a normal font even for the monospaced <tt> rendering (how strange). This might also be the reason, why opera needs a table header. Even then the results are far from perfect for me. (If every character got its own table cell, which would result in really huge files, then opera might render better.)

With HTML 4.01 <span> tags:

(In opera i get thin horizontal gaps between the rows.)

In some browsers (netscape 4.7, early mozillas) span tags are rendered markedly faster. But in some browsers, minimal variations of the line length are visible.

And for the sake of completeness screenshots in png format:

The original xterm dumps:

About the "Alternate linedrawing characters":

This might only work on Unix, only with some browsers, definitely only with an appropriate font. Here's a test for the 12 (from 15) probably displayable characters:
Configure e.g. (Sony-)"Fixed"(-Misc). as fixed-width (or probably monospaced) font in your browser: Size 10 is fine.

A small screen shot (gif) while using a proper fixed-width font.
It looks like this on Unix in netscape-2.0, netscape-4.7, mozilla-1.3 and opera-5b1/6tp2:

Your browser (using the <tt> tag in an HTML 3.2 table)

Your browser (using <pre> and HTML 4.01 <span> tags)


(My opera version refuses to display the last character, "&#25;". Well it's illegal, anyway...)

Options for the script:

  -h[elp]          : this help
  -width <x>       : width of xterm
  -linedrawing <x> : 0 - don't try to show alternate linedrawing characters
                     1 - try to show them
                     2 - show the original plain characters (without sense)
  -fg <color>      : xterm foreground color
  -bg <color>      : xterm background color
  -spantags        : do not use HTML 3.2+ tables but HTML 4.01 <span> tags
  -htmlcolors      : don't use original xterm colors but HTML color names
                     (more dim, though)
  -noheader        : don't insert a table header (opera needs it)
  -spacing         : table cellspacing, to debug bad rendering (e.g. for opera)