That did it thanks! We ended up subclasing SAXiTextHandler to parse a new
"resource" attribute in the image tag - we mapped this to the tomcat file
url of our exploded war using the getResource method you mention below and
filled in the url attribute before passing the tag to super. Now the only
ugliness is that our image files have to sit with the class files in the
WEB-INF/classes directory, but we can live with that :)
Thanks again,
Ossie
I have some images that are used within one of our PDFs. I use the
Class.getResource() method to get the URL of the image. If the String
passed to getResource() begins with a '/' it starts looking from the
root of the app server otherwise it starts looking in the directory of
the class. I have a subdirectory in the directory where I store my PDF
generating java file that contains the images. (I hope that made sense).
Here is a small code snippet.
String coveredIconLocation = "images/circlecheck.png";
coveredIcon =
Image.getInstance(getClass().getResource(coveredIconLocation));
OR
coveredIcon =
Image.getInstance(getClass().getResource("images/circlecheck.png"));
I hope this helps.
Doug
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ossie
Guy
Sent: Tuesday, June 28, 2005 11:14 PM
To: [email protected]
Subject: [iText-questions] resolving image from within a war file
Hi All,
We are using iText with success in our web application, but now need to
include an image in the resulting PDF.
We are using XML to create the report to allow division of labour, but
have hit a snag - to include the image it seem straightfoward enough to
use the image tag, but how can we resolve the image file from within our
war file?
For example, if we say:
<image url="/path/to/foo.jpg"/>
it will resolve this path from the working directory of the application
server (Tomcat in our case). Since the war is exploded in a
randomly-named temp directory, there's no way we can know this path in
advance.
I suppose we could use an http link? But this would need a full path as
well, and it would be nice not to have to put the server name in there
(it could be dev, staging, production, etc.). Plus it just seems wrong
to pull the image back through HTTP...
Is there any way to resolve the image in our servlet using
Image.getInstance() and then pass that in to iText somehow, with some
sort of image tag in the XML that acts as the placeholder for where it
should be positioned? Also seems a bit kludgy though..
Sorry if this is has been covered, but I can't find a reference to this
problem in the documentation nor mailing-list archives. I don't really
believe we are the first to encounter this problem?
Thanks in advance for all help and/or tips...
Cheers,
Ossie
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's
FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
****************************************************************************************
BENEFITFOCUS.COM CONFIDENTIALITY NOTICE: This electronic message is
intended only for the individual or entity to which it is addressed and may
contain information that is confidential and protected by law. Unauthorized
review, use, disclosure, or dissemination of this communication or its
contents in any way is prohibited and may be unlawful. If you are not the
intended recipient or a person responsible for delivering this message to
an intended recipient, please notify the original sender immediately by
e-mail or telephone, return the original message to the original sender or
to [EMAIL PROTECTED], and destroy all copies or derivations of
the original message. Thank you. (BFeComNote Rev. 07/29/2003)
***************************************************************************************
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions