Loading ...
Sorry, an error occurred while loading the content.

Re: FOP as a Servlet - Images won't display!

Expand Messages
  • alzoid69
    You need to specify a Base Directory because FOP needs it to display external resourses. You can do it the the fop configuration file
    Message 1 of 9 , Jan 8, 2005
    • 0 Attachment
      You need to specify a Base Directory because FOP needs it to display
      external resourses. You can do it the the fop configuration file
      {fop-dir}/conf/userconfig.xml. Or you can do it with Java code (my
      prefrence)

      Here is my code in the doGet():
      ...

      ServletContext servletContext = getServletConfig().getServletContext();

      String appPath = servletContext.getRealPath(""); //root of web app
      org.apache.fop.configuration.Configuration.put("baseDir",appPath);

      ...

      My FOP looks like this:

      <fo:external-graphic src="file:images/logo.jpg"/>

      Hope this helps.

      Allan


      --- In XSL-FO@yahoogroups.com, "carbonejim" <Jim.Carbone@N...> wrote:
      > I've searched every place I can think of, and tried everything too.
      > I'm trying to put a graphic into a PDF using FOP 0.20.3 as a
      > servlet. Graphics to appear in my documents when I run FOP from the
      > command line.
      >
      > Here is a list of some things that I've tried:
      >
      > First, I put the img in almost every directory in Apache Tomcat
      >
      > No image displays
      > -----------------
      > 1: Used this fo tag - <fo:external-graphic src="url(imgs/jpeg.jpg)"/>
      > 2: Used this fo tag - <fo:external-graphic src="imgs/jpeg.jpg"/>
      > 3: Used this fo tag - <fo:external-graphic src="jpeg.jpg"/>
      >
      > No document displays
      > --------------------
      > 4: Used this fo tag - <fo:external-graphic
      > src="http://localhost:8080/examples/imgs/jpeg.jpg"/>
      > 5: Used this fo tag - <fo:external-graphic
      > src="file:c:\imgs\jpeg.jpg"/>
      > 6: Used this fo tag - <fo:external-graphic src="/imgs/jpeg.jpg"/>
      > 7: Used this fo tag - <fo:external-graphic src="url(/imgs/jpeg.jpg)"/>
      > 8: Used this fo tag - <fo:external-graphic src="url
      > (http://localhost:8080/examples/imgs/jpeg.jpg)"/>
      >
      > When no image displays in the document I can see this error message:
      >
      > ERROR 10171 [fop ] (): Error while creating area : Error with
      > image URL: imgs\jpeg.jpg (The system cannot find the path specified)
      > and no base directory is specified
      >
      >
      > Help! And you will sleep well knowing that you saved a person from
      > jumping out a four story window! Thanks!
      >
      > Jim
    Your message has been successfully submitted and would be delivered to recipients shortly.