{"id":1119,"date":"2023-02-06T16:16:16","date_gmt":"2023-02-06T10:31:16","guid":{"rendered":"https:\/\/dearpdf.com\/?post_type=docs&#038;p=1119"},"modified":"2023-02-12T09:42:33","modified_gmt":"2023-02-12T03:57:33","password":"","slug":"add-print-button","status":"publish","type":"docs","link":"https:\/\/dearpdf.com\/docs\/add-print-button\/","title":{"rendered":"Add Print button"},"content":{"rendered":"\n<pre class=\"wp-block-verse has-medium-font-size\">Experimental customizations are not included by default and are extended to the plugin. Please use with caution and proper consent.<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-default\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Case:<\/h2>\n\n\n\n<p>Trigger custom function or action when viewer has finished loading the document and required files for displaying the PDF.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demo:<\/h2>\n\n\n\n<script src=\"https:\/\/printjs-4de6.kxcdn.com\/print.min.js\"><\/script>\n<script>\n    var customButtonFunction = function () {\n        \/\/Custom button code goes here\n        var app = this;\n        printJS({ printable: app.options.source, type: 'pdf', showModal: true })\n    };\n\n    jQuery(function () {\n        DEARPDF.defaults.onReady = function (app) {\n\n            \/\/if needed you can use app.options.showDownloadControl to add or hide print button. Normally a pdf that cannot be downloaded should not be printed.\n            if (app.options.showDownloadControl == true) {\n                var customButton = jQuery('<div class=\"df-ui-btn df-icon-print df-ui-custom-print-button\" title=\"Print\"><\/div>');\n                customButton.on(\"click\", customButtonFunction.bind(app));\n                \/\/if you want to insert in some other place.. find the button and then insert before that button\n                app.ui.controls.share.after(customButton);\n            };\n            \n        };\n    });\n<\/script>\n\n<link rel=\"stylesheet\" type=\"text\/css\" href=\"https:\/\/printjs-4de6.kxcdn.com\/print.min.css\">\n\n\n\n<div class=\"df-element dvcss dvcss_e_eyJzb3VyY2UiOiJodHRwczpcL1wvZGVhcnBkZi5jb21cL3dwLWNvbnRlbnRcL3VwbG9hZHNcLzIwMjFcLzA3XC9mb2VlX2hiZl9tZWF0YXRsYXNfamFuMjAxNC5wZGYiLCJwZGZUaHVtYiI6Imh0dHBzOlwvXC9kZWFycGRmLmNvbVwvd3AtY29udGVudFwvdXBsb2Fkc1wvZGVhcnBkZi10aHVtYnNcLzE4OS5qcGVnIiwidmlld2VyVHlwZSI6ImZsaXBib29rIiwiaXMzRCI6dHJ1ZSwiY29sb3IzRENvdmVyIjoiIzliYjYxOSIsImJhY2tncm91bmRDb2xvciI6IiNkMWUyYjUiLCJzaG93RG93bmxvYWRDb250cm9sIjp0cnVlLCJhdXRvT3Blbk91dGxpbmUiOmZhbHNlLCJhdXRvT3BlblRodW1ibmFpbCI6ZmFsc2UsInNsdWciOiJtZWF0LWF0bGFzIiwiaWQiOjE4OSwibGlnaHRib3giOiJub25lIn0=  \"><\/div><script class=\"df-shortcode-script\" type=\"application\/javascript\">if(window.DEARPDF && window.DEARPDF.parseElements){window.DEARPDF.parseElements();}<\/script>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Process:<\/h2>\n\n\n\n<p>We use&nbsp;<code>onReady<\/code> function to detect the viewer has UI initialized and add the required print button. <\/p>\n\n\n\n<p>If needed you can use <code>app.options.showDownloadControl<\/code> to add or hide print button. Normally a pdf that cannot be downloaded should not be printed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script src=\"https:\/\/printjs-4de6.kxcdn.com\/print.min.js\">&lt;\/script>\n&lt;script>\n    var customButtonFunction = function () {\n        \/\/Custom button code goes here\n        var app = this;\n        printJS({ printable: app.options.source, type: 'pdf', showModal: true })\n    };\n\n    jQuery(function () {\n        DEARPDF.defaults.onReady = function (app) {\n\n            \/\/if needed you can use app.options.showDownloadControl to add or hide print button. Normally a pdf that cannot be downloaded should not be printed.\n            if (app.options.showDownloadControl == true) {\n                var customButton = jQuery('&lt;div class=\"df-ui-btn df-icon-print df-ui-custom-print-button\" title=\"Print\">&lt;\/div>');\n                customButton.on(\"click\", customButtonFunction.bind(app));\n                \/\/if you want to insert in some other place.. find the button and then insert before that button\n                app.ui.controls.share.after(customButton);\n            };\n            \n        };\n    });\n&lt;\/script>\n\n&lt;link rel=\"stylesheet\" type=\"text\/css\" href=\"https:\/\/printjs-4de6.kxcdn.com\/print.min.css\"><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-verse\">For WordPress, please read on \n<a href=\"https:\/\/dearflip.com\/how-to-add-custom-code-to-wordpress-pages\/\" data-type=\"post\" data-id=\"3009\">How to add Custom Code to WordPress Pages<\/a><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Experimental customizations are not included by default and are extended to the plugin. Please use with caution and proper consent. Case: Trigger custom function or action when viewer has finished loading the document and required files for displaying the PDF. Demo: Process: We use&nbsp;onReady function to detect the viewer has UI initialized and add the&hellip;&nbsp;<a href=\"https:\/\/dearpdf.com\/docs\/add-print-button\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Add Print button<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"doc_category":[10],"doc_tag":[],"class_list":["post-1119","docs","type-docs","status-publish","hentry","doc_category-advanced"],"year_month":"2026-05","word_count":327,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"admin","author_nicename":"admin_l5enayeh","author_url":"https:\/\/dearpdf.com\/author\/admin_l5enayeh\/"},"doc_category_info":[{"term_name":"Advanced","term_url":"https:\/\/dearpdf.com\/docs-category\/advanced\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/docs\/1119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/comments?post=1119"}],"version-history":[{"count":14,"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/docs\/1119\/revisions"}],"predecessor-version":[{"id":1143,"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/docs\/1119\/revisions\/1143"}],"wp:attachment":[{"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/media?parent=1119"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/doc_category?post=1119"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/dearpdf.com\/wp-json\/wp\/v2\/doc_tag?post=1119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}