iText image in java servlet

后端 未结 6 694
逝去的感伤
逝去的感伤 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条回答
  •  旧时难觅i
    2021-01-13 14:19

    Following piece of code may help you...

    String path = request.getContextPath();
    String split_path[] = path.split("/");
    path = request.getRealPath(split_path[0]);
    String imagePath="\\resources\\images\\letterHead.jpg";
    Image image = Image.getInstance(path+imagePath);
    

提交回复
热议问题