Sandcastle help builder - Dead pictures

Topics: Developer Forum
Jun 19, 2012 at 6:13 AM
Edited Jun 19, 2012 at 9:38 AM

Hi all,

I was using sandcastle to build my chm files and I was trying to put pictures into my help file. I used absolute path for my picture (as src=C:\\Project\picture\image.gif ) since sandcastle will not take in relative path(as src=\picture\image.gif).

The absolute path worked well at first on my own computer, I was able to see my pictures in the .CHM. However, as I move the built .chm file (yes, the built file..) out into another computers, the pictures cannot display properly. I'm assuming the cause of this is that somehow the sandcastle built the CHM with my pictures as urls to local files instead of embedded them with the CHM - which is quite weird..

Can anyone tell me how do I solve the problem???


ps: I heard that I'm suppose to put all picture in the root directory where help file is generated?? So does that mean I should put all pictures in one folder like C:\\Project\picture if my generated help file folder is at C:\\Project\Help (the Help is the generated folder) ??

Jun 19, 2012 at 7:39 PM

Assuming you do mean that you don't want the images compiled into the help file, most likely you'll need to use some form of "file://" URL for this to work.  There may also be security issues.  This is purely a CHM file issue so searching for "reference external file CHM" should turn up the information you need.  Unless you've got a specific reason for keeping them external to the compiled help file, embedding them by setting their BuildAction to Content and using a relative path to access them is usually the preferred solution (i.e. src="../Image.gif" if at the root or src="../Images/Image.gif" if in a sub-folder off of the root).



Jun 20, 2012 at 1:34 AM
Edited Jun 20, 2012 at 4:52 AM

Sorry I didn't make myself clear. I was trying to let the images to be compiled into the help file instead of linking them. What my current CHM file does right now is linking the image instead of compiling them, and I Don't want that. 

I used MS word to edit my content and saved them as filtered HTML pages. The word makes a xxx_files folder and stored all the images as imagexx.gif for each filtered HTMl, and all of them has image link src = "xxx_files/image001.gif" format. When I put this HTML directly into the Sandcastle, the picture does not display properly, instead it gives me an red X. And if I change the image link to src="C:\project\xxx_files\image001.gif" the picture display properly only if there is that picture at that directory. 

I want the pictures to be compiled into the CHM instead of a external link. Please give me some tips!

PS: the picture displayed properly when i was using the old HTML help workshop to compile the same HTML file....

Jun 20, 2012 at 7:23 PM

Add the images to your SHFB project and set their BuildAction property to Content.  In your HTML, use a relative path to access them as I noted above.  If you added them to the root of your SHFB project, the path will be "../Image1.gif".  If you put them in a folder, .\Images for example, the path will be "../Images/Image1.gif".  The leading "../" in both cases may not be required if the HTML file in question is also at the root.  If it's deeper in the folder hierarchy, additional ones may be needed to reach the images.



Jun 21, 2012 at 1:22 AM

AWESOME!! Thank you so much!!