1

i have to read 20-25 image for a page, and have to write into pdf

i tried to read the image using image.getInstance(url) it is taking much amount of time, and writing that image to PDF is also taking much time.

images size's vary from 10kb - 300 kb, reading images and writing into pdf is taking Average 60 seconds

How can i reduce this time.. i tried with BufferReader to read the images but there not much impact

sasi
  • 4,192
  • 4
  • 28
  • 47
  • Are the images on your system? You're making HTTP requests apparently right now so you've got to deal with that lag. Unless you've parallelized things those requests each wait until the previous one finishes, too. So finding a way to perform multiple requests at once would speed things up, too. – Chris Haas Jul 08 '14 at 20:09
  • Thanks for Replying Chris,not in my system, have to make multiple HTTP Request as you said.. How can i make multiple requests at a time.. – sasi Jul 08 '14 at 20:16
  • Unfortunately I can't help you with that part, I'm not a Java guy. Maybe this? http://stackoverflow.com/a/7502993/231316 – Chris Haas Jul 08 '14 at 20:19
  • Also: depending on the nature of the images, iText needs to open the stream more than once. Pre-loading the images into a `byte[]` (as Chris suggest in different threads) will gain you speed. However: making the connection, getting the bytes will always depend on external factors such as the speed of the server where you fetch the images, the bandwidth, etc... – Bruno Lowagie Jul 09 '14 at 05:45
  • @ChrisHaas your link helped me, and learned new concept thanks.. – sasi Jul 12 '14 at 08:09
  • @BrunoLowagie yes Bruno, i had preloaded all the images and then written to the pdf.. thanks for your suggestion – sasi Jul 12 '14 at 08:10

0 Answers0