Printing topics containing toggles

Navigation:  More Advanced Procedures > Toggles: Expanding Text and Images >

Printing topics containing toggles

Previous pageReturn to chapter overviewNext page

Show/Hide Hidden Text

You need to do a little planning to make it possible for your users to print topics containing toggles. Of course, this is only necessary in the formats where toggles are "active" – toggle printing is not a problem in formats like PDF and Word RTF because the toggles are always static in these formats, so their entire contents are always printed (provided you have configured the toggles to be displayed expanded in print mode).

In all formats where dynamic toggles are supported (WebHelp, HTML Help, MS Help 2.0) the toggles are always printed exactly as they are currently displayed. Expanded toggles are printed expanded, collapsed toggles are printed collapsed.

Generally, your users will want to print out the entire contents of the topic, including the contents of all toggles.

Click to expand/collapseIncluding Expand All and Collapse All links

The simplest method is to provide your user with Expand All / Collapse All links in your topic header, as explained in the topic Expand All / Collapse all in this chapter. Then they can click on Expand All before they print.

The disadvantage of this method is that you have to explain it to your users. If they miss the explanation it may take them a while to figure out what they need to do, and they may waste a lot of paper in the process.

Click to expand/collapseCreating an auto-expanding Print link

The best solution is a Print link that automatically expands the toggles in the topic. These are created in exactly the same way as an Expand All link, you just need to add one more small snippet of code to send the topic to the printer after expanding the toggles:

1.Follow the instructions for creating Expand All links to create a new link in the location where you want to have your Print link.

2.Create the code for the link as follows:

Code for a Script Link:

Code for your HTML template:

javascript:HMToggleExpandAll(true); print();

<a href="javascript:HMToggleExpandAll(true); print();">Print this Topic</a>

See Expand All/Collapse All for more detailed instructions on creating Print links and buttons.

Click to expand/collapsePrint link with an icon instead of a text link

You can also use an icon instead of a text link for the Print function. If you use the Link tool in the Write tab you just need to select Picture as the style and then select an appropriate printer icon. If you add the link to your HTML template you need to enter the code manually.

Static icon in the HTML template:

<a href="javascript: HMToggleExpandAll(true); print();">
<img name="printbutton" border="0" alt="Print This Topic" title="Print This Topic" src="print2.gif"></a>

Icon with a mouseover function in the HTML template:

<a href="javascript: HMToggleExpandAll(true); print();" onmouseover="document.images.printbutton.src='print1.gif'" onmouseout="document.images.printbutton.src='print2.gif'">
<img name="printbutton" border="0" alt="Print this Topic" title="Print this Topic" src="print2.gif"></a>

Add your icon images to the Baggage Files section and replace the image names in the above code with the filename of your own icon.

Click to expand/collapseExcluding the Print link in unsupported formats

If you also plan to generate Windows Exe or ePub eBooks from your project you must exclude the Print link there because toggles and JavaScript are not supported in eBooks (toggles are always displayed as static text, fully expanded).

If you use script links enclose the links in conditional text tags to make sure that they are only included in the output formats where dynamic toggles are supported (HTML Help, WebHelp and MS Help 2.0).

If you use links in your HTML templates enclose the link code in a pair of <IFNOT_EBOOK> </IFNOT_EBOOK> build conditions to make sure that they are excluded from eBooks. This will work for both Windows Exe and ePub eBooks.

See also:

Using HTML Templates

The topic page templates

About HTML Templates