Embedding images in CHM help file with Sandcastles
Asked Answered
C

1

6

I am using Sandcastles to generate a CHM help file for my project. I want a standalone CHM file that I can distribute, preferably on its own.

The issue I have is that to embed images it appears that the image needs to exist on the user's system separately from the CHM file. When I view the source of my CHM file, it looks like:

<img src="C:\Users\me\Pictures\wave.jpg" />

So if I email my CHM file to someone and they do not have this image, it will fail. An alternative would be to do:

<img src="images/wave.jpg" />

And email this person a ZIP containing my CHM file and an images folder. This is not a very nice solution either in my opinion.

Is there any way to "embed" an image within a CHM file? Or is there a clean solution to this?

For the record, I am including this image via this XML code on my C# project.

/// <summary>
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit.
/// Pellentesque quis tortor sit amet magna posuere sagittis. 
/// Integer aliquet nibh elit, ut porta ex laoreet et
/// </summary>
/// /// <remarks>A picture: <br />
/// <img src "C:\Users\me\Pictures\wave.jpg" />
/// </remarks>
Crary answered 24/9, 2014 at 9:57 Comment(1)
Minor nitpick: It might be a good idea to add the C# code tag to the code block so that XML syntax highlighting works.Longish
C
9

It's a Visual Basic sample only but I think C# is near by. I assume that you use sandcastle Help File Builder (SHFB).

If the images are not being used in MAML topics, just set the BuildAction in the SHFB project to Content and place them in an images folder. They'll get copied into the working folder automatically and compiled into the CHM help file.

Steps to import the [images]-folder into SHFB Project Explorer, not referenced by MAML topics:

  1. Select Add and Existing Folder... from tree context menu, select the [images]-Folder
  2. For each image-file, set BuildAction from Image to Content
  3. In SHFB, push the Build the help file button

After the build, you have a CHM help file with images.

I attached some snaps of the Visual Basic project, SHFB und the resulting CHM.

enter image description here

enter image description here

enter image description here

Cymose answered 27/9, 2014 at 9:45 Comment(1)
Thanks for the BuildAction = Content tip. Most references suggest that setting it to "Image" with CopyToMedia property set to "true" should deploy the image file and make it available even to non-MAML topics. However that did not work for me, while "Content" does.Organism

© 2022 - 2024 — McMap. All rights reserved.