This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I have been generating a PDF file using FOP, I want to put a gif onto the PDF. I can do this but only when the .gif file is on the C:/ drive of the machine. I want to use relative path, so that it works for all users. When I put the logo.gif in my c:/ drive and have the below it works:
I am looking for the syntax to use for src='url("/logo.gif")' Notice the single outer quotes and the double inner quotes - it only works this way for me. My <xsl:stylesheet version="1.0"> and also xml version is 1.0. The .gif file is actually in my Eclipse project workspace under WebContent, I am just not sure how I can refer to it using relative path. I have tried various different syntax combinations, but have been unsuccessful.
That's not a relative URI you have there. A relative URI would look like this:
And from what I can see, that would be relative to the base URI of your stylesheet. The XSL-FO recommendation doesn't say how relative URIs are handled, but it makes several references to the CSS specification, and that's what it says.
Joined: Jun 08, 2007
I tried your idea of relative path so now my code is:
I have placed the logo.gif in the same folder in Eclipse as the .xsl sheet, however this does not work. I am getting the message below in Console:
[ERROR] 03/25/08 15:04:44 <org.apache.fop.fo.flow.ExternalGraphic:bind():68>: Image not available: url("logo.gif")
Okay. So the next question would be, what is the base URI of your stylesheet?
Joined: Jun 08, 2007
Since I posted my previous message I have done the following- I have rewritten my code to use UserAgent, we were using some old methods of FOP which are now deprecated. I am now back to getting the PDF generated correctly but still no image, after code restructuring. I am setting the base URL as follows:
I want the base URL to be where the .xsl file is currently located in the Eclipse project, not a hardcoded absolute path like the one in the example in the link provided below, which suggest: userAgent.setBaseURL("file:///C:/Temp/");
If I did this only the machine running the application with this folder structure will be able to set the base URL all other machines will not. so I set the base URL as userAgent.setBaseURL("./"); However when trying to generate PDF I get in the console:
[ INFO] 03/26/08 10:10:31 >: FOP base url is ./
[ERROR] 03/26/08 10:10:32 >: Error with base URL "./"): no protocol: ./
I have placed the logo.gif in the same directory in Eclipse as the .xsl file, but it doesnt seem to like the base URL. My .xsl file has
Also another question teh code for setbaseURL() is in a separate class which is located in a different directory than the .xsl. I placed the logo in this dir as well as where the .xsl is, still no luck!
Anybody know how to set baseURL to current location of .xsl. I really appreciate any help.