0

I am able to create a simple pdf using iText api inside a struts action class.
The data that should be passed into the pdf is generated on screen based on user search parameters.
What I am wondering is how I can pass the data into the struts action so it can be displayed in the pdf?

Thanks in advance.

db83
  • 169
  • 1
  • 4
  • 13

1 Answers1

0

Similar question is already here. You just need to transfer everything that is on the page to struts action. I would do it like so:

JSP:

<div id="content">
  wrap everything generated in here
</div>
<html:hidden styleId="hiddenHtml" name="hiddenHtml"/>
<html:submit onclick="setContentAsParam();">Export PDF</html:submit>

JS:

function setContentAsParam() {
    document.getElementById('hiddenHtml').value = document.getElementById('content').innerHTML
}

This will set all the HTML to a action class property hiddenHtml. Get back if anything won't work, I wrote this out of my head without a test :)

Community
  • 1
  • 1
Trick
  • 3,779
  • 12
  • 49
  • 76