Can we add Print button to document viewer.

Shivani5
Tera Contributor

Instead of download i want to print the document.
We need to add a print button to the document viewer instead of downloading the attachment

Please find the attachment.

Thank you!

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Shivani5 

you will have to customize the OOB ui page or widget.

Please discuss this with your customer.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Shivani5 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ravi Gaurav
Giga Sage
Giga Sage

Hi @Shivani5 

 

To add a print button to a document viewer in ServiceNow instead of a download option, you can follow these general steps. The exact implementation may vary based on your specific ServiceNow instance and the way your document viewer is set up. Here’s a basic outline of how you can achieve this:

 

Steps to Add a Print Button in ServiceNow Document Viewer

  1. Identify the Document Viewer: Determine where the document viewer is located in your ServiceNow instance. This could be a UI page, a widget, or a specific form.

  2. Modify the UI Page or Widget:

    • If you are using a UI page, navigate to System UI > UI Pages and find the relevant page.
    • If you are using a widget, go to Service Portal > Widgets and locate the widget that contains the document viewer.
  3. Add a Print Button:

    • In the HTML section of the UI page or widget, add a button element for printing. For example:
    • <button id="printButton" onclick="printDocument()">Print Document</button>
  4. Implement the Print Functionality:

    • You will need to create a JavaScript function that handles the print action. This function can be added in the script section of the UI page or widget. Here’s a simple example:
    • function printDocument() {
      // Assuming the document viewer is in an iframe or a specific div
      var printContent = document.getElementById('documentViewerId'); // Replace with your document viewer's ID
      var WinPrint = window.open('', '', 'width=900,height=650');
      WinPrint.document.write('<html><head><title>Print Document</title>');
      WinPrint.document.write('</head><body >');
      WinPrint.document.write(printContent.innerHTML); // Get the content to print
      WinPrint.document.write('</body></html>');
      WinPrint.document.close();
      WinPrint.print();
      }
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/