| By Date: | <-- --> |
| By Thread: | <-- --> |
|
Hi Previously, I asked this question in which my images in the jar file
were not loading when using: Image.getInstance("images/vblogowhite.gif"); Then Bruno and someone helped me and asked to use classloader, and it
worked (see below) – so thanks ClassLoader cl = this.getClass().getClassLoader(); URL vImgURL = cl.getResource("images/vblogowhite.gif"); Image verizGif= Image.getInstance(vImgURL); The problem with the above approach is that we have to package those
images in our jar file, which is not desirable. We want to avoid this (exploded
is not an option either). Our webapp is packaged in separate war and it has to
access the iText pdf report generation code (that also puts images on the
document that is in jar file). The code in jar file is common and can be called
from stand-alone and webapps. Since number and type of images can change depending upon reports and
customers, we want to load images in UI and pass to iText code (in jar) file as
a File object as a parameter – like a file object and then create image
out of it. This would have advantage of not jarring the images in the jar file
(they could reside in their place in webapps) as well as allowing users to load
different images for different stuff. I looked at iText api for images and there
is no method like: Image.getInstance (File file). A method like Image.getInstance (File fileObject) could prevent all the
above, since UI will load image as file and pass to back-end code the file. The back-end iText code can either do Image img = Image.getInstance(File file) and do Document.add(img) There is Image.getInstance(String filename) and Image.getInstance(URL
url) in API, but they would require class loader to load the images as well as
packaging them in the jar file We want to load the images as file from UI and pass to back-end as file
object and then want to use something like Image.getInstance (File file) to create images. Kindly tell me if its possible and if there is a sample? Thanks arif -----Original Message----- From: itext-questions-bounces (at) lists.sourceforge.net
[mailto:itext-questions-bounces (at) lists.sourceforge.net] On Behalf Of Bruno
Lowagie Sent: Friday, February 02, 2007 2:19 PM To: Post all your questions about iText here Subject: Re: [iText-questions] loading images Arif Abbasi wrote: > This is what we want. Can you please post the question again WITHOUT referring to previous answers and missing mails. Phrase it as simple as possible, because I don't understand what you want (and I doubt if anyone on the list does). The way I interpret it, you have an Image shown in a Java UI (therefore it's probably a java.awt.Image) and now you want this java.awt.Image to be in a PDF file, for instance using Image.getInstance(java.awt.Image); If that is the case, I don't understand why you are asking. If that is not the case, you will have to be more clear, because you are mostly telling what you don't want, and that confuses me because I don't always remember previous mail conversations. Start anew with your question without all the irrelevant history. br, Bruno |
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ iText-questions mailing list iText-questions (at) lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/