Forum Bugs

.net SetBaseURL doesn't do anything

lordlinton
Hi,

Not sure if this is a bug or if I'm just being a moron, but I'm trying to create a C# .net application that transforms my book. The html includes images which are not found by prince due to a bad path, but I can't change the path.

Here is the situation:
HTML Code:
img src="images/Image2.jpg"


C# Code:
String path = "c:\\library\\master_wace";
Prince p = new Prince("C:\\Program Files\\Prince\\Engine\\bin\\prince.exe");
p.SetBaseURL(path);
p.AddStyleSheet(txtStylesheet.Text);
p.SetHTML(true);
p.SetLog(path + "\\log.txt");
p.Convert(path + "\\master_wace.html", path + "\\master_wace.pdf"))


The log file gives the following error:
C:\library\images\Image2.jpg: warning: can't open input file: No such file or directory

It should have been looking in:
C:\library\master_wace\images\Image2.jpg

The following things don't help:
don't use SetBaseURL(path); (same error)
use SetBaseURL("c:\\library\\master_wace"); (same error)
use SetBaseURL("c:\\library\\master_wace\\"); (prince fails)
use SetBaseURL("c:\\library\\master_wace\\images"); (same error)
use SetBaseURL("c:\\fake dir"); (same error)

It looks to me that the SetBaseURL function simply does nothing. The odd thing is that it seems to be that it should not be nessessary to set it in the first place as the images are relative to input source directory.

Sorry for the lengthy explanation.

Cheers,
Steven.

ps. The update is great! :)
mikeday
As you say, it should not be necessary to specify a base URL in this situation. Can you replicate this behaviour when running Prince from the command-line with the same document?
lordlinton
Sorry for the delay on this one. I got distracted by other projects.

It turns out that it does work, but not as one would expect.

Lets say my output directory should be:

c:\library\master_wace

SetBaseURL("c:\\library\\master_wace"); will not work (should)
SetBaseURL("c:\\library\\master_wace\\ignored"); will work

I say ignored because Prince seems to strip it.

Cheers,
Steven.
mikeday
The base URL is the notional URL of the document that you are formatting, so the "ignored" part is the filename of the notional document. This is similar to the way that the HTML <base> element and xml:base attribute work.