HTML Help Workshop - How to link an external file

1.9k Views Asked by At

I'm looking into the possibility of providing an external link to a file such as a PDF.

Would I need to include this .pdf file within the .hpp file under [Files] section?

What's the best way to do this?

1

There are 1 best solutions below

2
On BEST ANSWER

That depends on what you want to achieve. Working on a stand alone PC/Laptop is different to working in a company network because of some security issues in terms of *.CHM files.

First please follow the steps described in Including a PDF file in SHFB generated .chm (Html Helpfile 1).

You'll find some files for self learning help authoring. Of course a PDF example is integrated as HTML help example too. Please note that the topics themselve and PDF files include specific information.

Example for e.g. embedded PDF:

Make sure to add your *.PDF file to the [FILES] section of the **.HHP file like this:

[FILES]
design.css
index.htm
embedded_files\example_embedded.pdf

and linking from HTML (CHM):

<p><a href="../embedded_files/example-embedded.pdf">Link relative to PDF</a></p>

enter image description here

Example for linking to PDF from Table of Contents (TOC):

This is a solution to avoid compiling the CHM again (see TOC in screenshot above). You may want to save updated PDF on the users PC e.g. by installer. Please note this is for Windows and Internet Explorer use only.

This is a PDF example for launching Acrobat Reader from the Table of Contents (TOC). You can see how to show the PDF file in the topic window of the HTMLHelp file (CHM). The PDF document isn’t compiled into the CHM file. You can update this file without recompiling the CHM file.

The PDF file must reside in a subfolder under your local CHM file e.g. external_files/example-external-pdf.pdf.

To link from TOC to “external_files/ example-external-pdf.pdf” add following lines to the HTMLHelp Table of Contents file (HHC):

<LI> <OBJECT type="text/sitemap">
     <param name="Name" value="How to link to PDF file (not embedded)">
     <param name="Local" value="HTMLHelp_Examples/example-external-pdf.htm">
     </OBJECT>

This HTML example-external-pdf.htm has following code:

<html>
<head>
<title>Example load PDF from TOC</title>
<SCRIPT Language="JScript">
function parser(fn) {
var X, Y, sl, a, ra, link;
ra = /:/;
a = location.href.search(ra);
if (a == 2)
X = 14;
else
X = 7;
sl = "\\";
Y = location.href.lastIndexOf(sl) + 1;
link = 'file:///' + location.href.substring(X, Y) + fn;
location.href = link;
}
parser('external_files/example-external-pdf.pdf');
</SCRIPT>
</head>
<body>
</body>
</html>

You'll need to know something more about Acrobat Reader and Internet Explorer:

https://helpx.adobe.com/acrobat/using/display-pdf-in-browser.html

You can download the samples as needed: Project with all files and tricky examples