• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

iText pdf image conversion

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Neil Chatfield
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic