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 Jerome Munchenberg <Je...@intecgroup.com.au> on 2008/01/07 03:07:33 UTC
Help! URI for fo:external-graphic in web service
Hello,
I am developing a web service which returns a PDF generated by FOP
(fop-0.94) which must include an image. The web service is deployed as
an EAR to a WebLogic server, and the image to be inserted into the PDF
is contained within this EAR.
How do I correctly access the image embedded in the EAR? I have been
able to use a file file path when testing on my own box, but this is
obviously unsuitable for other environments!
The code I am using that works for my local environment looks like this:
<fo:block>
<fo:external-graphic
width="70mm"
content-height="scale-to-fit"
content-width="scale-to-fit"
src="C:\Project\src\au\com\aaa\services\certificate.gif"
/>
</fo:block>
Thanks for your help!
Jerome
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Help! URI for fo:external-graphic in web service
Posted by Abel Braaksma <ab...@xs4all.nl>.
Jerome Munchenberg wrote:
> Abel,
>
> Thanks for such a comprehensive response! Much appreciated.
>
> In the end it all got too hard, and after much experimentation, I
> embedded the GIF in the XSL-FO using BASE64 encoding.
>
> <fo:external-graphic
> width="70mm"
> content-height="scale-to-fit"
> content-width="scale-to-fit"
> src="data:image/gif;base64,R0lGODlhhAl...
> ..."/>
>
> Worked a treat...
Nice to hear that. I wouldn't consider data: URIs to be easy (getting
the GIF encoded is usually the hardest part as you cannot do that with
straight XSLT), but if it works for you that's good ;)
Note that not all XSL-FO processors will support the data: scheme (but
that can actually be true for just about any scheme, though currently
http and file are supported by all of them) as it is much less common
than http: and file:.
Cheers,
-- Abel Braaksma
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
RE: Help! URI for fo:external-graphic in web service
Posted by Jerome Munchenberg <Je...@intecgroup.com.au>.
Abel,
Thanks for such a comprehensive response! Much appreciated.
In the end it all got too hard, and after much experimentation, I
embedded the GIF in the XSL-FO using BASE64 encoding.
<fo:external-graphic
width="70mm"
content-height="scale-to-fit"
content-width="scale-to-fit"
src="data:image/gif;base64,R0lGODlhhAl...
..."/>
Worked a treat...
Regards,
Jerome
-----Original Message-----
From: Abel Braaksma [mailto:abel.online@xs4all.nl]
Sent: Monday, 7 January 2008 12:59 PM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Help! URI for fo:external-graphic in web service
Jerome Munchenberg wrote:
> Hello,
>
> I am developing a web service which returns a PDF generated by FOP
> (fop-0.94) which must include an image. The web service is deployed as
> an EAR to a WebLogic server, and the image to be inserted into the PDF
> is contained within this EAR.
>
You might try the JAR scheme, but I am not sure whether that scales well
to a EAR. Another option is to use the real filepath (you can get the
real unpacked EAR location through your web application server
interface, I believe), or a relative path (often it is quite easy to get
the WEB-INF directory and go from there).
If all fails, the next easiest thing to do is to use the public URI
which would also be accessible from your website to retrieve that same
file. It is probably best to use localhost as server to prevent an extra
server roundtrip.
If you don't like any of these scenarios because of their lack of
scalability, start using Catalogs (see OASIS website) and use a
URIResolver (possibly with a specific scheme) to resolve the catalogs
unambiguously regardless the platform / system / paths your services are
running on.
> How do I correctly access the image embedded in the EAR? I have been
> able to use a file file path when testing on my own box, but this is
> obviously unsuitable for other environments!
>
You were lucky that it worked, because if a file path is allowed, than
that's a bug in the FOP implementation: XSL-FO prescribes that only a
URI is allowed. To go from a filepath to a URI you should rewrite it
something like "file:///c:/project/scr/certificate.gif" (note the
forward slashes!).
> src="C:\Project\src\au\com\aaa\services\certificate.gif"
HTH,
Cheers,
-- Abel Braaksma
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: Help! URI for fo:external-graphic in web service
Posted by Abel Braaksma <ab...@xs4all.nl>.
Jerome Munchenberg wrote:
> Hello,
>
> I am developing a web service which returns a PDF generated by FOP
> (fop-0.94) which must include an image. The web service is deployed as
> an EAR to a WebLogic server, and the image to be inserted into the PDF
> is contained within this EAR.
>
You might try the JAR scheme, but I am not sure whether that scales well
to a EAR. Another option is to use the real filepath (you can get the
real unpacked EAR location through your web application server
interface, I believe), or a relative path (often it is quite easy to get
the WEB-INF directory and go from there).
If all fails, the next easiest thing to do is to use the public URI
which would also be accessible from your website to retrieve that same
file. It is probably best to use localhost as server to prevent an extra
server roundtrip.
If you don't like any of these scenarios because of their lack of
scalability, start using Catalogs (see OASIS website) and use a
URIResolver (possibly with a specific scheme) to resolve the catalogs
unambiguously regardless the platform / system / paths your services are
running on.
> How do I correctly access the image embedded in the EAR? I have been
> able to use a file file path when testing on my own box, but this is
> obviously unsuitable for other environments!
>
You were lucky that it worked, because if a file path is allowed, than
that's a bug in the FOP implementation: XSL-FO prescribes that only a
URI is allowed. To go from a filepath to a URI you should rewrite it
something like "file:///c:/project/scr/certificate.gif" (note the
forward slashes!).
> src="C:\Project\src\au\com\aaa\services\certificate.gif"
HTH,
Cheers,
-- Abel Braaksma
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org