Skip to main content
Known Participant
April 16, 2008
Question

Assigning Styles to Printed HTML Help

  • April 16, 2008
  • 2 replies
  • 2233 views
I seem to remember there was a trick for assigning styles to how HTML Help would print when users print directly from the .chm. The problem is, I can't remember the trick.

What I want to do is to force the printing to use the same fonts as the Help (for example to print in Verdana rather than Times Roman).

Does any one know if there's a way to assign style sheets or formats to a .chm so that topics print out the way I want them to (rather than just using the printer's defaults)? Any ideas?
This topic has been closed for replies.

2 replies

MergeThis
Inspiring
April 25, 2008
If "the style sheet is in the root folder, long(sic) with the other project files," then why the "..\" in the path?

Why not simply href="default.css"?


Good luck,
Leon
MergeThis
Inspiring
April 25, 2008
Oh, by the way, if you've made changes to the default.css (which is the HTML standard), other browsers on other machines might simply use their system's default.css file instead of looking for yours (same name, you know).

I'd rename your .css file to something else, just for giggles (company or product acronym, such as we do).


Good luck,
Leon
GayresAuthor
Known Participant
April 28, 2008
Thanks to all for the suggestions.

I was convinced that renaming the stylesheet to something besides default.css was going to work. Alas. No such luck.

With a little more research, I can add that the problem seems to be with using the "Print selecting heading and all subtopics" option in the Print Topics dialog box. Printing just the selected topic works fine (and uses the format defined in the default stylesheet).
Participating Frequently
April 16, 2008
Hi, Gayres,

Here's an explanation from Marc Islam of the Microsoft help development team of why this problem occurs:
quote:

When printing multiple topics, HTML Help will concatenate all of the topics together into one temporary file, load the file into a new HTML Help process, and issue a command to IE to print the file.

Since the merged file can only have one <HEAD> section, the first topic in the merged file is the one that gets to define which JS and CSS files are used by all of the topics in the merged file.
There's an article in the Microsoft Knowledge Base that suggests a workaround:

http://support.microsoft.com/?kbid=830609

And snippet 46 on Peter Grainge's site may help, but it does require you to keep duplicate copies of the .css file in your project.

http://www.grainge.org/pages/snippets/snippets.htm

Pete
GayresAuthor
Known Participant
April 22, 2008
quote:

Since the merged file can only have one <HEAD> section, the first topic in the merged file is the one that gets to define which JS and CSS files are used by all of the topics in the merged file.

Pete,

Thanks for your reply. I'm sure you've pointed me in the right direction, but the problem isn't only with multiple topics: it happens with single topics, too. It seems like the style sheet that defines the Help file is not used at all during printing. Even when I'm only printing one topic.

I've also noticed that the printed topics may not bear any relationship to my style sheets. For example, the topics print out in what looks like Times Roman, while all of my style sheets use only Verdana.

Any ideas?
Participating Frequently
April 23, 2008
Hi, Gayres,

The behaviour you describe is rather unusual. Is only one help file affected, or can you reproduce the problem with other help files on your computer? If only one help file is affected, perhaps you can open it, right-click the topic pane and select View Source on the context menu, and then report back with how the style sheet is linked to the topic file. The link should look something like this:

<link href="YourStyleSheet.css" type="text/css" rel="stylesheet">

What should happen when you choose to print a single topic and get as far as the Print dialog box is that Windows should store the contents of the topic in a temporary HTML file in your %TEMP% folder. Then, when you click Print, the contents of the temporary file are sent to the printer and deleted shortly afterwards. If you look at the contents of this temporary file, you should see a couple of extra elements that specify the absolute path back to the source topic in the help file, but the <link> element should be undisturbed.

Pete