Tech Write Tips

June 28, 2006

HTMLHelp Multiple Page Printing

Filed under: HTMLHelp,Technology — AndyR @ 6:55 am

HTMLPrint.gifIt wasn’t until I was reading of another authors struggle to get multiple topics printing correctly out of HTMLHelp that I realised that I had hit the problem myself. If you haven’t tried it you should try multiple page printing for your HTMLHelp and see if it still has your style applied.

The issue is that when you print multiple topics from a .chm it doesn’t just print each topic in turn. What happens is an intermediate html file is created from the selected topic. 

You can view this file as follows:

  1. Right clicking a book in the TOC of your .chm.
  2. Selecting print all topics. Leave the Print dialog open and browse to “C:\Documents and Settings\USERNAME\Local Settings\Temp”.
  3. Sort this folder by date, and you should see an .htm file thats name starts with “~hh…”.
  4. Open this file in a text editor to view how it has been compiled.
  5. Note the single <Head> section, and updated SRC sttributes for <IMG> tags.
  6. Also note the location of the .css which will reference your .chm absolutely but include the relative path from the topic and therefore not work.

Head Problem
This intermediate file only has one head section. This can cause a few headaches such as the IE header states the first topic on all printed pages. But worse than this is that if you have included any script calls or any automation in your header, or if you have a script that references header information will not work. In my case I was generating the topic title from the page title tag in the header. Therefore when I printed mulitple pages they all had the same header. Doh!

This is something that you may need to work around for your printed output. In my case I ended up including a hidden topic title that was then turned on just for printing via a “@media print {H1.print {display:block}}” in my style sheet.

CSS and JS Location Problem
This intermediate file is generated in a temp folder. To ensure that the images are displayed correctly the print routine automatically adjusts the src elements to reference from its new location. However, if you have referenced a .css or .js it doesn’t update the location.

To get around this you need to implement an absolute location to these files in your topics. You are essentially replacing the relative location (“../../Style.css”) with an absolute location (“ms-its:HELP.chm::Style.css”). These absolute references are dealt with properly in the intermediate file for printing.

Create a free website or blog at WordPress.com.