2

Is there any way to obtain a HTML content by HttpServletResponse or HttpServletRequest?

I need to print a PDF based on HTML object.

Cichy
  • 1,319
  • 3
  • 20
  • 36
  • possible duplicate of [Capture generated dynamic content at server side](http://stackoverflow.com/questions/1963158/capture-generated-dynamic-content-at-server-side) and [How to capture current dynamic output of JSP and email it?](http://stackoverflow.com/questions/7400408/how-to-capture-current-dynamic-output-of-jsp-and-email-it). – BalusC Oct 06 '11 at 13:32

2 Answers2

3

In this scenerio i would use a filter. You can access content which wanted to be output and redirect the output stream to your PDF generator which can convert HTML to PDF.

More about Filters : http://www.oracle.com/technetwork/java/filters-137243.html

common way is to create PDFs from model objects. Then use iText. http://itextpdf.com/

Erhan Bagdemir
  • 5,231
  • 6
  • 34
  • 40
0

You can create a PDF from the HTTP request data and whatever other information you need from the server side by merging it into a Velocity template containing the FO defining your PDF.

duffymo
  • 305,152
  • 44
  • 369
  • 561