{"id":190,"date":"2009-12-21T10:02:37","date_gmt":"2009-12-21T18:02:37","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=190"},"modified":"2025-05-19T14:55:56","modified_gmt":"2025-05-19T11:55:56","slug":"printing-grid-content","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/printing-grid-content\/","title":{"rendered":"Printing Grid Content"},"content":{"rendered":"<p><strong>UPD: Download the most recent <a href=\"https:\/\/dhtmlx.com\/docs\/products\/goodies\/\">Grid-to-PDF packages for PHP, ASP.NET, and Java<\/a>.<\/strong><\/p>\n<p>If you&#8217;ve ever faced the problem of printing data from <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxGrid\/\">JavaScript datagrid<\/a>, then this news will please you. At last we offer a solution for printing <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxGrid\/\">dhtmlxGrid<\/a> content. Currently it works for PHP, but even if you develop in Java or Cold Fusion, or Ruby, or whatever, you still can use it from a PHP server through remote request.<\/p>\n<p><strong>How to print<\/strong><\/p>\n<p>The extension consists of two parts (<a href=\"https:\/\/dhtmlx.com\/x\/download\/regular\/grid-pdf-php.zip\">dhtmlxgrid-to-pdf.zip<\/a>):<\/p>\n<ul>\n<li>A dhtmlxGrid extension JavaScript file (dhtmlxgrid_pdf.js),<\/li>\n<li>A PHP background which creates a PDF file from grid content.<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\nYou can keep them both on the same computer as your application, or (which is really nice!) you can use a remote server for this. I.e., you can add the line of code below to your page with the grid and start creating PDFs right away:<\/p>\n<div style=\"overflow:auto; padding-left:5px;background-color: #f8f8f8;padding-top:5px;\">\n<pre class=\"html\">&lt;script src=\"https:\/\/dhtmlx.com\/docs\/products\/devExchange\/grid-to-pdf\/dhtmlxgrid_pdf.js\"&gt;&lt;\/script&gt;<\/pre>\n<\/div>\n<p>&nbsp;<br \/>\nTo start creating PDF from your grid, use the following JavaScript command (assign it to the button or something):<\/p>\n<div style=\"overflow:auto; padding-left:5px;background-color: #f8f8f8;padding-top:5px;\">\n<pre class=\"js\">grid.toPDF('https:\/\/dhtmlx.com\/docs\/products\/devExchange\/grid-to-pdf\/generate.php');<\/pre>\n<\/div>\n<p>&nbsp;<br \/>\nInstead of using files from dhtmlx.com you can use their local copies, of course.<\/p>\n<p><!--more--><strong>What you get<\/strong><\/p>\n<p>It is extremely easy to start using the extension, so you can try it right away with your application.<\/p>\n<p>While creating PDF, you can choose a color scheme for it. There is a dropdown on the toolbar with three options: color, gray and black&amp;white. Here is what you get in color:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-229\" title=\"color\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2009\/12\/color.gif\" alt=\"color\" width=\"548\" height=\"361\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2009\/12\/color.gif 548w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2009\/12\/color-300x197.gif 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/p>\n<p><strong>Current version options are:<\/strong><\/p>\n<p>&sdot; The color scheme can be chosen from: color, gray, black&amp;white. To set it in the script method, use one of the following values as a second argument of the <em>toPDF <\/em>method: &#8220;color&#8221;, &#8220;gray&#8221;, &#8220;bw&#8221;.<\/p>\n<p>&sdot; You can use images as a header and footer for the PDF page. These images should be named header.[gif\/jpg\/png] and footer.[gif\/jpg\/png]. Put them in the <em>imgs <\/em>folder under <em>grid-to-pdf<\/em>.<\/p>\n<p>To enable Header, set the third argument of the <em>toPDF<\/em> method to <em>true<\/em>. To enable Footer, set the forth argument of the <em>toPDF <\/em>method to <em>true<\/em>.<\/p>\n<p>&sdot; Orientation of the page will be automatically chosen based on column width.<\/p>\n<p><strong>dhtmlxScheduler-to-PDF is coming&#8230;<\/strong><\/p>\n<p>I must say that the same solution will be available for <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxScheduler\/\">dhtmlxScheduler<\/a> in a few days. I&#8217;ll describe it and show it in action in the next post.<\/p>\n<p><small>Posted by Inga Kravtsova<\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPD: Download the most recent Grid-to-PDF packages for PHP, ASP.NET, and Java. If you&#8217;ve ever faced the problem of printing data from JavaScript datagrid, then this news will please &#8230;<\/p>\n","protected":false},"author":1,"featured_media":3439,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,1],"tags":[33,18,6,30,14],"class_list":["post-190","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-uncategorized","tag-all-posts","tag-labs","tag-dhtmlxgrid","tag-grid-to-pdf","tag-tips"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":3,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":13930,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions\/13930"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3439"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}