Also don't forget Image.getInstance(fileObject.toURL());

If you have a file, just pass it as a URL.

-Bill Ensley
www.bearprinting.com 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Arif Abbasi
> Sent: Monday, February 05, 2007 1:58 PM
> To: 'Post all your questions about iText here'
> Subject: Re: [iText-questions] loading images
> 
> Hi
> 
> Thanks for replying back. Sorry if I am making it confusing, 
> I thought I was very explicit.
> 
> We have all the images in our webapps (I was UI for this in 
> my last e-mails). The webapps are deployed as independent war 
> files. Our iText PDF report code(the middle tier) is in jar 
> files (deployed separately). The webapps (or UI code) calls 
> the middle tier iText code (in jar file) passing all 
> necessary information. As I stated before with previous 
> approach we have to load images in our Jar file and use 
> classloader to load them for iText code.
> 
> The reason that solution is undesirable, because we have some 
> 50 customers, and we don't want to package 50 images in 
> webapp and the same 50 images in jar file. We rather have 
> them reside in webapp (in war file), and have it load the 
> appropriate customer image, and pass that image to iText code 
> one customer at a time.
> 
> That's why I asked the question that if there was a call like 
> Image.getInstance(File fileObject) that takes an image file 
> as parameter (that we pass from webapp to jared code), we can 
> achieve this  ..
> 
> It looks like from Paul and Bruno e-mail that there isn't any 
> api. The alternatives are to load the image in webapp:
> 
>  as Java.awt.Image and pass this Image object to itext jarred 
> code as param.
> 
> OR
> Load the image in a byte[] array and pass the byte array to 
> Image.getInstance(byte[]).
> 
> After looking at JAVA API DOCS it does not look like that 
> pretty -- as Image is an abstract class - I was able to do 
> the following:
> 
> public java.awt.Image loadImage(String fileName) 
>       throws IOException {
>               Toolkit toolkit = Toolkit.getDefaultToolkit();
>               return toolkit.getImage(fileName);
>       }
> 
> And calling this as: 
>         com.logie.text.Image myGif=
> Image.getInstance(loadImage("./webapp/finium/shared/images/vbl
> ogowhite.gif",
> null);
>         document.add(myGif);
> 
> 
> Am I clear and if this is what you're suggesting?
> 
> Thanks
> Arif
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Bruno Lowagie
> Sent: Saturday, February 03, 2007 4:58 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] loading images
> 
> Arif Abbasi wrote:
> > The problem with the above approach is that we have to 
> package those 
> > images in our jar file, which is not desirable.
> 
> OK, I thought this was your original requirement, the fact 
> that you are now saying this in not desirable confused me.
> 
> > We want to avoid this
> > (exploded is not an option either).
> 
> The word 'exploded' also confuses me. What does it mean?
> 
> > Since number and type of images can change depending upon 
> reports and 
> > customers, we want to load images in UI
> 
> In UI? Do you mean User Interface?
> How do I have to interpret this?
> Are you showing the images in an AWT or Swing object?
> 
> > 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.
> 
> The iText Image object can deal with images in all kinds of 
> forms, including java.awt.Image and byte[].
> 
> > This would have advantage of not jarring the images in the jar file 
> > (they could reside in their place in webapps)
> 
> In their place in webapps is very vague.
> I have no idea what you mean by this.
> Are we still talking about undesired jars?
> 
> > as well as allowing users
> > to load different images for different stuff.
> 
> How would they do that? With a FileSelector object?
> You are not being clear at all.
> 
> > I looked at iText api for
> > images and there is no method like:
> > Image.getInstance (File file).
> 
> I don't think your understanding of class java.io.File is correct.
> 
> > 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.
> 
> I think you are basing your conclusion on wrong assumptions.
> 
> > 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?
> 
> I agree with Paulo. Your question isn't going anywhere.
> You have me all confused; probably because I fail to what 
> this has to do with iText and because you have some serious 
> misconceptions about webapps.
> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
> 
> 
> --------------------------------------------------------------
> -----------
> 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@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/


-------------------------------------------------------------------------
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@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to