0
votes

I have jsp page where is "Print" button. I want to create link on this button which will open new popup window with my printable page (jsp file) with the same model as parent page. I can do some onClick action. But I don't know how to render my printable jsp. I use Spring MVC portlet

1

1 Answers

1
votes

Maybe you can just use jquery with jquery-printArea to print your page or the div you want in this page. This is an example below :

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://github.com/RitsC/PrintArea/blob/master/js/jquery.printarea.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
    $(".print").click(function(){
        $("#content_to_print").printArea();
    });
});
</script>

<div id="content_to_print">
  <h2>Title</h2>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
    in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<button class="print" id="print-button" type="button">Print</button>