You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Brent Snook <ka...@iinet.net.au> on 2003/06/17 08:49:21 UTC

external image provided via servlet - image type not being read

Hi, 

I am currently developing a Java servlet that uses embedded FOP 
(0.20.5rc3a)under Tomcat 4.1.18 and am having a few problems with external
graphics and PDF generation. 

The external graphics in question are streamed using another servlet, which is
causing a few problems such as FOP not being able to determine the image 
type. 

The first problem I had was with using a relative URL. FOP could not find the

servlet and I thought this was because it was treating the value of the src 
attribute as a relative file rather than URL path. I got around this
temporarily by using the full URL although I would ideally not want to hard 
code this. 

The main problem I have is with FOP determining image type properly. The 
servlet that streams the image sets the content type of the response correctly
according to the image MIME type (stored in a metadata file). FOP is finding
the servlet but keeps giving me errors: 

Error while creating area : No ImageReader for this type of image 

External graphics work fine when I link to a static file. It is the dynamic 
output from the servlet that is causing the bother. 

I have tried adding servlet mappings to Tomcat such as "fetch/img.jpg" and 
"fetch.jpg" but FOP still complains that it can not find an ImageReader for 
that image type. Am I wrong in thinking that FOP determines which ImageReader

to use by reading the file extension of the URL? 

I would be gratefull for any suggestions. 

Cheers. 

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: external image provided via servlet - image type not being read

Posted by Jeremias Maerki <de...@greenmail.ch>.
On 17.06.2003 08:49:21 Brent Snook wrote:
> I am currently developing a Java servlet that uses embedded FOP 
> (0.20.5rc3a)under Tomcat 4.1.18 and am having a few problems with external
> graphics and PDF generation. 
> 
> The external graphics in question are streamed using another servlet, which is
> causing a few problems such as FOP not being able to determine the image 
> type. 
> 
> The first problem I had was with using a relative URL. FOP could not find the
> 
> servlet and I thought this was because it was treating the value of the src 
> attribute as a relative file rather than URL path. I got around this
> temporarily by using the full URL although I would ideally not want to hard 
> code this. 

See here for how to set a base URL:
http://xml.apache.org/fop/servlets.html#cfg
http://xml.apache.org/fop/embedding.html#config-internal

You can use an URL, not only a directory as shown in the documentation.

> The main problem I have is with FOP determining image type properly. The 
> servlet that streams the image sets the content type of the response correctly
> according to the image MIME type (stored in a metadata file). FOP is finding
> the servlet but keeps giving me errors: 
> 
> Error while creating area : No ImageReader for this type of image 
> 
> External graphics work fine when I link to a static file. It is the dynamic 
> output from the servlet that is causing the bother. 
> 
> I have tried adding servlet mappings to Tomcat such as "fetch/img.jpg" and 
> "fetch.jpg" but FOP still complains that it can not find an ImageReader for 
> that image type. Am I wrong in thinking that FOP determines which ImageReader
> to use by reading the file extension of the URL? 

Yes, totally. FOP has ImageReader implementations (package
org.apache.fop.image.analyser) which actually look into the contents of
the file being loaded to determine the image format. Neither the file
extension nor the MIME type are evaluated.

> I would be gratefull for any suggestions. 

If you generate such a dynamic image from your servlet and save it to a
local file and run FOP from the command-line, can FOP then open the
image? If not, I think you have a strange JPEG format there. If yes, you
could try to change FopImageFactory so it evaluated the MIME type sent
by the servlet. But that only helps if the FOP image implementations can
really load your image.

Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org