wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes iText pdf image conversion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "iText pdf image conversion" Watch "iText pdf image conversion" New topic
Author

iText pdf image conversion

Neil Chatfield
Greenhorn

Joined: Jul 02, 2007
Posts: 2
Hello All,
I am trying to convert images(jpg, tif) to pdf using iText. I have had some success in this by creating a simple jsp which perform the conversion, eventually the whole thing will be included in a servlet but the jsp makes early development simpler.

The problem I have is that I don't have a direct url/uri to an actual image. The images are stored in a third party EDM system and at present use their servlet to display them(in browser). I also only have their class file, no source.

I have put my jsp code below, I need to do something like

instead of

but all I get is a 'No such file or directory' error. However an 'a href' returns the image. Can anyone help me get the results from the servlet and create the pdf?



Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Welcome to JavaRanch.

The Image.getInstance(String) method expects a filename as parameter. Try the getInstance(URL) method instead; maybe something like " Image.getInstance(new URL("http://www.server.com/servlet/MyImageServlet") ".

There's also a "getInstance(byte[] imgb)" variant, to which you can pass the bytes that make up the image directly (if your code has access to those bytes, that is).


Ping & DNS - my free Android networking tools app
Neil Chatfield
Greenhorn

Joined: Jul 02, 2007
Posts: 2
I have been at the possibility of using the URL of the servlet, but no real luck so far. It is a step forwards though as now I can actually find the servlet, but just get more errors.

I have however managed to take a look at source of the servlet I'm trying to call. I think my errors are because the servlet is actually outputting the image to the browser.



Does that sound right?

Also, before this thread was moved there were 2 replies, now there is only one. Why was it removed?

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
I think my errors are because the servlet is actually outputting the image to the browser.

I wouldn't think so. If you use Image.getInstance(URL), then that opens it own HTTP connection to the servlet, and reads its output. But you might want to verify that what it receives from the servlet is really the complete image.

Also, before this thread was moved there were 2 replies, now there is only one. Why was it removed?

I haven't seen any other answer, but whoever posted it might have had second thoughts, and deleted it himself.
[ July 04, 2007: Message edited by: Ulf Dittmer ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: iText pdf image conversion
 
Similar Threads
how to convert jsp form to pdf file
Find know image in a bigger image
Scroll bar missing on Windows PC's?
IOException : logo.png is not a recognized imageformat
TIFF. DOC, EXCEL to PDF Converter