title: iText Add Image to PDF in a web application
body: <p>I'm posting this for a friend. He is not able to access Stackoverflow from work (Third Party Cookies Appear To Be Disabled) :)</p>
  
  <p>Ok here goes:</p>
  
  <p>They have a Web application (JSP/Servlets/Custom Framework) and he is trying to generate a PDF on the fly. Now he wants to add images to that PDF. But it ain't working. Here is the piece of code:</p>
  
  <pre><code>Image image = Image.getInstance("../graphics/caution_sign.gif");
  </code></pre>
  
  <p>The graphics folder is on the parent project (webcontent/graphics/) and this is how they access the images from that folder in all other places (in the JSPs). </p>
  
  <p>Now I read on another post that we need to use the real absolute path to access the Images. But the problem here is this is a POJO and there is no access to the servletContext in this class.</p>
  
  <p>The PDF is generated fine, but the Image does not show and the error is:</p>
  
  <pre><code>C:\Program Files\IBM\SDP\runtimes\base_v7\profiles\was70profile1\..\graphics\caution_sign.gif (The system cannot find the path specified.)
  </code></pre>
  
  <p>It is trying to look for the "Graphics" folder in a different location instead of looking within the webcontent folder.</p>
  
  <p>Hope my question is clear and would appreciate a lot if someone can help with this and help in resolving this issue</p>
  
  <p>Thanks so much</p>
  
  <p>Harish</p>