Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Assigning Styles to Printed HTML Help

New Here ,
Apr 16, 2008 Apr 16, 2008
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?
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 16, 2008 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 22, 2008 Apr 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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 23, 2008 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 24, 2008 Apr 24, 2008
Pete,

First of all, thanks for taking the time to try and help me with this. I really appreciate it.

My links look like this,

<link rel="StyleSheet" href="..\default.css">

The stylesheet I'm using is named default.css. And the link looks like this in all the topics in all the Help files.

Does this make anything clearer?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 24, 2008 Apr 24, 2008
Hi again,

Where is the style sheet in relation to the project (.hhp) files for the help files? If it's above the "root" of each help project instead of being stored in or below the root folder then you can run into problems. See:

http://helpware.net/FAR/far_faq.htm#Project_Setup

As an experiment, you could try moving the style sheet down into the root folder for one help project and changing the links to the style sheet accordingly.

Pete
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 25, 2008 Apr 25, 2008
I'm starting to feel like I'm being difficult... but the style sheet is in the root folder, long with the other project files. There is noting related to the project above the root folder.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 25, 2008 Apr 25, 2008
Hi,

If you feel comfortable sending me a help file — click my user name at the left — I'd be happy to take a closer look. At this distance, it's hard to provide further suggestions without looking at the source files.

You've already looked at one or two other help files on your computer and established that they don't exhibit the same behaviour?

Does changing the backslash to a forward slash in href="..\default.css" make any difference? It shouldn't do, or at least I was unable to reproduce the problem by using your Link element in my test file, but it may be worth a shot.

Does your style sheet contain any "@media screen" rules?

Pete
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 25, 2008 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 25, 2008 Apr 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2008 Apr 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).
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 28, 2008 Apr 28, 2008
Hi,

> 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

Then you need to try the workarounds mentioned in my first reply.

Pete
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2008 Apr 29, 2008
I think I may be a little confused...

The links to the stylesheet in my Help topic files currently look like this,

<link rel="StyleSheet" href="..\default.css">

And they should look like this?

<LINK REL="stylesheet" MEDIA="all" TYPE="text/css" HREF="ms-its:MyHelpProject.chm::/cssdir/MyStyleSheet.css">

What's "cssdir"? in this statement? Is this the path? If so, can the path be relative -- since I don't know which folder this Help file will wind up in? Perhaps something like ".."?

Am I correct in assuming that I need to change the links in every topic?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 29, 2008 Apr 29, 2008
Hi again,

What you're doing by changing the <link> element as described in the Microsoft article is defining the internal path to the .css file within the help file. So, if the .css file is stored in the same folder as the project (.hhp) file, the link would be something like this:

<LINK REL="stylesheet" TYPE="text/css" HREF="ms-its:YourHelpFile.chm::/default.css">

Whereas if you were to store the .css file one folder down from the root in a subfolder called "styles", the link would become:

<LINK REL="stylesheet" TYPE="text/css" HREF="ms-its:YourHelpFile.chm::/styles/default.css">

But I think you've already said that your style sheet is in the same folder as the other project files, so the first example above is more applicable in your case.

Notice that you're not specifying the path to the folder that contains the help file — only the name of the help file followed by the internal path to the .css file. Consequently, it doesn't matter where the help file is subsequently stored.

Yes, I'm afraid you'll need to make this change in all topics. Perhaps try it in one first to verify that you've got it right before you make wholesale changes, if you decide to use the technique. FWIW, this is exactly the technique that Microsoft uses in many of its help files, not least because it means that multiple help files can all be linked to a single instance of the style sheet, which is stored in just one central .chm file.

Pete
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 02, 2008 May 02, 2008
LATEST
Thanks Pete. I'll give this a try and let you know how it works -- but I'm not going to have a chance to get to until some time next week.

Cheers!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp