# Custom Print

> Here is an option to use the Ctrl+P function with some JavaScript to create a custom print function.

Source: https://tadabase.com/docs/snippets/custom-print  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

![Screenshot for “Custom Print”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664593278599.png)

Here is an option to use the Ctrl+P function with some JavaScript to create a custom print function.

**Step 1**

**Add an HTML Component to your page and add the following source code.**

```
<p><button id="printBtn" class="btn-primary btn.btn-primary btn-lg"> ?? Print </button></p>
```

> **Note:** Feel free to remove "btn-lg" if you want a smaller button.

![Screenshot for “Custom Print”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664593886614.png)

**Step 2**

**Save the HTML component and hover over the info icon to get the component ID.**

![Screenshot for “Custom Print”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664594117639.png)

**Step 3**

**Add the following code to the JavaScript tab of your page.**

```
$(function() {
    (function() {
        var beforePrint = function() {
            // $(’.table-actions’).css(‘display’,‘none’);
            $(’#printBtn’).css(‘display’, ‘none’);
        };

        var afterPrint = function() {
            //$('.table-actions').css('display','block');
            $('#printBtn').css('display', 'block');
        };

        if (window.matchMedia) {
            var mediaQueryList = window.matchMedia('print');
            mediaQueryList.addListener(function(mql) {
                if (mql.matches) {
                    beforePrint();
                } else {
                    afterPrint();
                }
            });
        }

        window.onbeforeprint = beforePrint;
        window.onafterprint = afterPrint;
    }());
});

TB.render(‘component_11’, function(data) {
    data.ele.find(’#printBtn’).on(‘click’, function() {
        // alert(“printing”);
        window.print();
    });
});
```

![Screenshot for “Custom Print”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664594525389.png)

**Original Community Post:**

[Error 500 with PDF's - Community Discussions / How Do I - Tadabase Community](https://community.tadabase.io/t/error-500-with-pdfs/1934/2)
