cancel
Showing results for 
Search instead for 
Did you mean: 

[Help Plz]Image URL in PDF

Former Member
0 Kudos

Hello,

We have a report to produce using IText API

Everything is fine in test phase but few days ago we tryied to test the report using the server name ALIAS and we get error 😕

Server returned HTTP error code 503, I search in the net and I found that it's due to a temporary inavailability of the server but It still not working so we tried to find another solution :

I used the code below :


//url is the dynamically generated url of the image.
java.awt.Image awtImg = java.awt.Toolkit.getDefaultToolkit().createImage(url);
//I get error here
com.lowagie.text.Image image2 = com.lowagie.text.Image.getInstance(awtImg, null);
document.add(image2);

but I get the following error : java.awt.Image fetch aborted or errored

I search in the internet, too many people asking the same question but no one seems to have the answer

(people facing the same problem say that the problem is due to the fact that we have an url in parameter).

When I try to access the image on the server using the generated url (copy paste to the browser), it works, I can see the image.

Any ideas? Any suggestions?

It's really important.

Thanks in advance for your help.

Edited by: ImaneA on Jul 12, 2011 5:46 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ImaneA,

I think the problem is due to load balancer, the server might have mutiple server nodes(instances).

When you are trying to access the image on the server using URL, the request might have gone and hit the server which is not avialable(inactive) so you are getting the error message "HTTP error code 503".

Its not advised to read the image through URL, if the server has mutileple server instances.

Instead of this you can read the image from a KM repository, which is very effective in performance wise and cache problem will not be there.

Otherwise you have to store the image in the database as a BLOB oject and read the image from Databse

Just check wether this 2 options will be a feasible solution or not.

Regards,

Saleem Mohammad

Former Member
0 Kudos

Hello Saleem Mohammed,

Thanks a lot for your reply.

For the storage of image in database, I'm not sure that we can do that but for using the image from KM, I'll try it on a server which have a unique node.

When you say "read image from KM", you mean hardcode the KM image url, is that right?

For the http code error 503, I got it when using the code below :


com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(url);
document.add(image);

The code I've mentionned in my previous post returned the error : java.awt.Image fetch aborted or errored

Again, thanks a lot for your help.

PS : I've assigned points

Edited by: ImaneA on Jul 13, 2011 9:48 AM

Former Member
0 Kudos

hi ImaneA,

While reading the file from KM repository means, you have to keep the image in root directory and its not a hardcoded URL.

I don't think you will face any problems with this approach.

//Reading the image from root directory 

RID pathRID = RID.getRID("/documents/SDN"); //Root Directory

Go through this link if you want to read the image from KM...

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a099a3bd-17ef-2b10-e6ac-9c1ea42af...

Hope this helps you.

Regards,

Saleem Mohammad

Former Member
0 Kudos

Hello Saleem Mohammed,

Our problem is solved thanks to you

For the example you give me in your last post, I'm not using WDJ, I'm using a portal component, it's full java.

You were right about the instances, I added a condition in my method ( the one which build the url path) to change the name of the server alias with the servername.

The names are hardcoded, this is the best solution we could get and it's working.

Thanks a lot for your valuable help

Best regards,

Imane.

Answers (0)