- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-06-2019 11:08 PM
Hi team,
Please suggest me how to add print option in UI page, i have my HTMl code and I need to add button down of ui page once they click that button it should give us the windows option to print please suggest
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2019 01:41 AM
Hi,
Can you try once with the below button in your html code. Just the below code any where and you don't need to define this function in your client script.
<button onclick="print()">Print
</button>
Note: Please mark this as correct or helpful if it helps!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2019 06:00 AM
I am trying to print a UI Page that is being rendered in a dialog box. When I try this print script it is trying to print just a section of the form and not my dialog box - then redirects to the UI page but without any of the scoped information.
Do you have any suggestions for being able to print the dialog box only?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2019 04:58 AM
Hi lsilvaroli,
You can put the contents of your html inside a div with an id, then pass that id to the print function.
You can refer the below UI page's HTML code to get your code working.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
<h2>HTML Table</h2>
<div id="custom">
<table id="tableCustom">
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
<button onclick="printDiv('custom')"/>Print
</div>
<script>
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>
</j:jelly>
This first sets the document body to the content of your div then shows the printable page then once that is done, it replaces with the original contents. Let me know if this works.
NOTE : Mark this as correct if it works!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2021 07:55 AM
Hi
Your answer for pdf generation works good!!
I used Bootstrap table layout, your solution generates pdf but it is not as per bootstrap design.
Also, there's no CSS included, any possibility on including CSS for pdf generation.
Could you please let me know the possibility for inclusion of CSS/Bootstrap?
Hope you would be helpful for me.
Thanks,
Priyatham.