Print documents using Javascript. RRS feed

  • Question

  • User870584148 posted


           Are there any way to print office document(unstructured document), PDF, images using java script or any other design approach could print documents, except any ActiveX and vb-script.


    Wednesday, February 28, 2018 9:13 AM

All replies

  • User-492460945 posted


    For printing using javascript, I think below one is useful for you.

    Wednesday, February 28, 2018 2:19 PM
  • User1400794712 posted

    Hi dexononforum,

    Window.print() is a javascript metnod to print the document.

    When we use window.print() directly, it will print the whole page.

    If you just want to print the specify part of body, you can use the following code:

    <div class="hello">
    <div class="hi">
    <input type="button" value="print" onclick="printDiv('hello')" />
        function printDiv(divClass) {
            var printContents = document.getElementsByClassName(divClass)[0].innerHTML;
            var originalContents = document.body.innerHTML;
            document.body.innerHTML = printContents;
            document.body.innerHTML = originalContents;

    Best Regards,


    Thursday, March 1, 2018 6:00 AM
  • User-183374066 posted

    Not sure about office documents but you can print pdf, images and html through printjs

    Thursday, March 1, 2018 8:01 AM