iText image in java servlet

后端 未结 6 696
逝去的感伤
逝去的感伤 2021-01-13 13:45

I\'m doing the letter generation with iText (pdf/rtf) in java servlet and got a problem with accessing images. The images are in the WebContent/images folder. When I run it

6条回答
  •  难免孤独
    2021-01-13 14:07

    Following code can be used to access image path inside a java class.

    URL imageUrl = getClass().getProtectionDomain().getCodeSource().getLocation();
    Image img=Image.getInstance(imageurl+"../../../some/images/pic.gif");    
    

提交回复
热议问题