Embed PDF files in CHM files

CHM files usually consist of pure HTML content. But also other file formats like PDF can be integrated. In this article I will show you two ways how PDF files can be integrated into CHM files with DA-HelpCreator.

Embed together with other content

In the first example we want to integrate the PDF directly into an article. I.e. there is normal content and the PDF is additionally integrated into it. In the first step we create the article, drag the PDF file into the file list:

To be able to display the file directly in the CHM file, we bind it via iframe in. This works with the following code:

<iframe src="example.pdf" name="iframe" scrolling="yes" frameborder="0" marginheight="0px" marginwidth="0px" height="1000" width="100%">
</iframe> 

A corresponding iframe generator can be found here. In the code you can see the file name “example.pdf”, settings for the size of the iframe and the design. This can be adjusted if you like.

We insert the code now into our document:

In the Markdown editor the code can be inserted just like that. The display in the editor is a bit insecure, but we can ignore that:

If we export the project as a CHM file, the same error occurs:

We can’t ignore that now! 🙂 What is the reason? The reason is that the CHM compiler does not recognize the PDF file as part of the project and does not include it in the CHM file. What to do?

The solution is simple. The PDF file must still be linked normally in the document:

We simply add a normal link to the PDF file at the end. This causes the PDF file to be recognized and included in the CHM file. If you don’t want to include a particularly visible link, you can, for example, simply link a “.” point. The PDF file is now displayed in the result:

Open PDF directly

In the second example only the PDF should be opened. Also here we insert the PDF into the file list again:

We add a link to the PDF again:

Labeling and display are irrelevant, the page is not displayed to the user. We forward directly to our PDF. To accomplish this we go to the HTML view:

There we insert the following code:

<meta content="0; URL=example.pdf" http-equiv="refresh">

This causes an automatic forwarding to the “example.pdf” file when opening the page. The result, it is forwarded directly to the PDF file and this is now displayed as a page.

Translated with www.DeepL.com/Translator

Leave a Reply

Your email address will not be published. Required fields are marked *