On Thu, 2003-11-13 at 18:35, Paulo Soares wrote:

Actually, there's a bug in iText when trying to create an Image using
getInstance( String )!

The method toURL in Image.java starts with the following rows:

public static URL toURL(String filename) throws MalformedURLException {
 if (filename.startsWith("file:/") || filename.startsWith("http://";)) {
  return new URL(filename);
 }

You'll need to add an 'filename.startsWith("https://";)' in the if
statement to support loading images through a secure link. I fixed this
in my servlet by creating my own URL instance and feeding getInstance()
with that instead!

 / Malte


> You need JSSE to support HTTPS. That support already exists in java 1.4.
> 
> Best Regards,
> Paulo Soares
> 
> > -----Original Message-----
> > From:       Wegley, Harry L [SMTP:[EMAIL PROTECTED]
> > Sent:       Wednesday, November 12, 2003 17:30
> > To: [EMAIL PROTECTED]
> > Subject:    [iText-questions] Problems adding images to PDF from an URL
> > 
> > I have not been able to successfully embed a jpeg obtained from an URL
> > into the PDF created by iText. We have had 2 programmers looking at this
> > problem for a couple of weeks and can trace the problem back to iText or
> > something that iText is passing to java.net.URL.
> > 
> > Here's basically what we are doing and what we see:
> >  1. Create a string that contains the URL to produce out chart (code at
> > the URL uses Jfreechart)
> >  2. Use the string to create an URL which is passed to Image.getInstance()
> >  3. Image.getInstance() throws an exception
> > 
> > Here's some example code:
> > String imageUrl = new StringBuffer(128).append(myinfoUrl)
> >                   .append("/paysummary/DisplayBarChart.jsp")
> >                   .append("?userid=").append(userid_)
> >                   .toString();
> > Image barChart = Image.getInstance( new URL(imageUrl);
> > 
> > 
> > Note that URL string stored in "imageUrl" both looks correct and works
> > when typed in a browser window -- the URLs look like:
> > https://server03.ne.boe.com:8094/paysummary/DisplayBarChart.jsp?userid=122
> > 34
> > 
> > The URL returns a jpeg image of a chart (produced by Jfreechart). I can
> > run the code using Jbuilder from my desktop machine (which uses http, not
> > https) -- it works fine and the chart is put into the PDF. 
> > But, if I put my java code on our server (which uses https), the
> > getInstance method throws an exception. I have seen 2 different errors: 1)
> > stating that the URL does not look like a jpeg and 2) a Malformed URL
> > exception is thrown in java.net.URL.
> > 
> > I work on a fairly large development project within Boeing. At this point
> > we are frustrated to the point of giving up on iText completely unless we
> > can get this problem resolved.
> > 
> > Has anyone seen similar problems with putting images obtained from an Url
> > into an iText-produced PDF file? Do you have any recommendations of things
> > to try -- we have exhausted our known options. By the way, putting the
> > image in the file system and opening it from there works, but that is not
> > an option for the production version of our application -- we need to get
> > the image from an URL.
> > 
> > --Harry Wegley
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email sponsored by: ApacheCon 2003,
> > 16-19 November in Las Vegas. Learn firsthand the latest
> > developments in Apache, PHP, Perl, XML, Java, MySQL,
> > WebDAV, and more! http://www.apachecon.com/
> > _______________________________________________
> > iText-questions mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: ApacheCon 2003,
> 16-19 November in Las Vegas. Learn firsthand the latest
> developments in Apache, PHP, Perl, XML, Java, MySQL,
> WebDAV, and more! http://www.apachecon.com/
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
-- 
 / Malte



-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to