问题
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>
回答1:
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:
- Select Add and Existing Folder... from tree context menu, select the [images]-Folder
- For each image-file, set BuildAction from Image to Content
- 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.
来源:https://stackoverflow.com/questions/26013972/embedding-images-in-chm-help-file-with-sandcastles