48 lines
1.4 KiB
Plaintext
48 lines
1.4 KiB
Plaintext
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js">
|
|
</script>
|
|
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
|
|
<%= javascript_include_tag "jspdf.min" %>
|
|
<style>
|
|
input[type="button"],button,input[type="submit"] {
|
|
outline: 0;
|
|
border-radius: 1.3em;
|
|
background: #d9e4f7;
|
|
font-weight: bold;
|
|
outline: 0;
|
|
}
|
|
input[type="button"]:hover,button:hover,input[type="submit"]:hover {
|
|
background: #be8a8a;
|
|
}
|
|
.print_text{
|
|
padding: 2em;
|
|
width: 650px;
|
|
margin: auto;
|
|
}
|
|
@media print
|
|
{
|
|
.no-print, .no-print *
|
|
{
|
|
display: none !important;
|
|
}
|
|
}
|
|
</style>
|
|
<script type="text/javascript">
|
|
function save_data(){
|
|
var filename = '<%= @save_name %>.pdf';
|
|
$('div.print_text').find('input[type=button]').hide()
|
|
html2canvas($('div.print_text')[0]).then(canvas => {
|
|
var pdf = new jsPDF('px', 'mm', 'a4');
|
|
var width = pdf.internal.pageSize.getWidth()-3;
|
|
var height = pdf.internal.pageSize.getHeight();
|
|
pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0,width ,height );
|
|
pdf.save(filename);
|
|
});
|
|
$('div.print_text').find('input[type=button]').show()
|
|
}
|
|
</script>
|
|
<div class="no-print" style="text-align: center;">
|
|
<input onclick="save_data()" value="<%= I18n.t('ask.save_data') %>" type="button">
|
|
</div>
|
|
<div class="print_text">
|
|
<%= @print_text.html_safe %>
|
|
</div> |