title: Render image from servlet in flyingsaucer generated pdf
body: <p>I'm using flyingsaucer to render an xhtml document to pdf through a servlet which returns the generated pdf document. The xhtml document features an image which is requested from another servlet. The image servlet checks who is logged in before returning the appropriate image. The code below shows how the image is requested:</p>
  
  <pre><code>&lt;img height="140" width="140" src="http://localhost:8080/myapp/servlet/DisplayPic" /&gt;
  </code></pre>
  
  <p>My problem is that the http request for the image is from the pdf renderer and not the logged in user so the image servlet doesn't know who's logged in and therefore the desired image is not returned.</p>
  
  <p>I'm currently using the code below to render the xhtml document:</p>
  
  <pre><code>ITextRenderer renderer = new ITextRenderer();
  renderer.setDocumentFromString(xhtmlDocumentAsString);
  renderer.layout();
  os = response.getOutputStream();
  renderer.createPDF(os);
  </code></pre>
  
  <p>I need to either maintain the user's session when the image servlet is requested or provide the renderer with the image to use for that specific xhtml element. I think the latter can be done using a <code>ReplacedElementFactory</code> but I haven't been able to dig out any example code that can help me.</p>