Forum How do I...?

where is the base dir for images

haprogrammer
If I have this in my xhtml file....

<img src="kris.jpg" />

And I am using the Prince Java API, where does Prince excpect kris.jpg to be located?

I know that I could do...

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

IF I hava c:\ images\kris.jpg... but I'd like to avoid fully qualified paths if possible.

I've tried putting the images in WEB-INF, WEB-INF/classes with no luck.
mikeday
Relative URLs will be resolved relative to the URL of the document. However, transient documents that are piped into Prince from stdin or from an InputStream have no URL, so the "current directory" will be used.

In future we may add an API to set the base URL of the document, however it will be difficult to convince Prince to load images out of a JAR file for the time being.
haprogrammer
I'm sorry but I don't understand what you mean by "current directory" when in the case one is using the API with an InputStream. To be exact, the input stream is not a FileInputStream but it is ByteInputStream which was generated from a String..... the page is being built dynamically.

The future plans are nice but what you have today will probably be fine once I understand what it needs.
mikeday
Basically, for now you will need to use absolute paths to refer to images if you are converting files using the streaming interface.
zebedee
Jut wanted to give my vote for getting support in Prince for <base href="URI" /> tag implemented.
mikeday
Today we have released Prince 5.1 rev 8, which supports a new --baseurl command-line option for specifying the base URL of the input document. Please give it a try and see if it does what you need. We will release updated versions of the Java and COM interfaces for Prince with a setBaseURL() method later this week.
mikeday
The updated Java and ActiveX/COM interfaces that support setBaseURL() are now available for download.