{"id":1292,"date":"2022-06-15T07:20:00","date_gmt":"2022-06-15T00:20:00","guid":{"rendered":"https:\/\/www.bagi2info.com\/?p=1292"},"modified":"2023-03-05T13:52:08","modified_gmt":"2023-03-05T06:52:08","slug":"script-printing-buat-zebra-printer","status":"publish","type":"post","link":"https:\/\/www.bagi2info.com\/en\/zebra-printer-print-script-example-using-zpl\/","title":{"rendered":"Zebra Printer print script example using ZPL"},"content":{"rendered":"There is work in the office that uses the <strong>ZT230<\/strong> and GX430t zebra printers.\r\n\r\nWe can print directly by selecting the zebra printer that has been installed, but if we need a certain format, it is better to use ZPL or Zebra Printing Language.\r\n\r\nBefore printing directly on paper, in the testing process, the author usually uses a preview from the website <a href=\"http:\/\/labelary.com\/viewer.html\" target=\"_blank\" rel=\"noopener\">http:\/\/labelary.com\/viewer.html<\/a>, in this way to save paper because there is no need to print directly to paper many times.\r\n<a href=\"https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"727\" class=\"wp-image-1654\" src=\"https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-1024x727.png\" alt=\"screenshoot testing ZPL website labelary.com\" srcset=\"https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-1024x727.png 1024w, https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-300x213.png 300w, https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-768x545.png 768w, https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image.png 1055w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a>\r\n\r\n\r\n<div class=\"wp-block-spacer\" style=\"height: 100px;\" aria-hidden=\"true\">&nbsp;<\/div>\r\n\r\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.bagi2info.com\/en\/zebra-printer-print-script-example-using-zpl\/#Layout_Paper_Configuration\" >Layout Paper Configuration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.bagi2info.com\/en\/zebra-printer-print-script-example-using-zpl\/#ZPL_Script_Example\" >ZPL Script Example<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.bagi2info.com\/en\/zebra-printer-print-script-example-using-zpl\/#Connection_Type\" >Connection Type<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.bagi2info.com\/en\/zebra-printer-print-script-example-using-zpl\/#Example_Source_Code_printing_with_Zebra\" >Example Source Code printing with Zebra<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Layout_Paper_Configuration\"><\/span>Layout Paper Configuration<span class=\"ez-toc-section-end\"><\/span><\/h3>\r\nSetting the canvas size according to the size of the sticker paper used, for example the paper that the author uses is 10cmx5cm, then the canvas configuration settings are as follows:\r\n\r\n<strong>Print Density<\/strong>: 12 dpm (300 dpi)\r\n\r\n<strong>Label Size<\/strong>: 10 x 5 cm\r\n\r\n<a href=\"https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"253\" class=\"wp-image-1658\" src=\"https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-1.png\" alt=\"\" srcset=\"https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-1.png 585w, https:\/\/www.bagi2info.com\/wp-content\/uploads\/2022\/06\/image-1-300x130.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/a>\r\n\r\n\r\n<div class=\"wp-block-spacer\" style=\"height: 100px;\" aria-hidden=\"true\">&nbsp;<\/div>\r\n\r\n<h3><span class=\"ez-toc-section\" id=\"ZPL_Script_Example\"><\/span>ZPL Script Example<span class=\"ez-toc-section-end\"><\/span><\/h3>\r\nSuppose we want to make a printout with a barcode format according to the following image\r\n\r\nThe following is an example of a ZPL script:\r\n\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-apacheconf line-numbers\" lang=\"apacheconf\">^XA\r\n^CFA,30\r\n^FO50,130^FDName^FS\r\n^FO50,170^FDAlamat:^FS\r\n^FO50,210^FDKTP:^FS\r\n^FO50,250^FDMobile:^FS\r\n^CFA,30\r\n^FO200,130^FDJohn Doe^FS\r\n^FO200,170^FDJln Jend. Sudirman^FS\r\n^FO200,210^FD123456789^FS\r\n^FO200,250^FD12345678^FS\r\n^FO600,170^FDNo^FS\r\n^FO700,170^FDRT^FS\r\n^FO600,270^FDRW^FS\r\n^FO700,270^FDNo^FS\r\n^FO590,310^FD1^FS\r\n^FO710,310^FD2^FS\r\n^FO710,210^FD3^FS\r\n\r\n^FX Third section with barcode.\t\t\t\r\n^A1N,30,22^BY2,2,70\r\n^FO230,20^BC^FD123456789^FS \r\n\r\n^CFB,30\r\n^FO600,210^FD4^FS^XZ<\/code><\/pre>\r\n\r\n\r\nExplanation of the script:\r\n\r\nLines no. 2 &#8211; 6 for setting the font size and placing the labels Name, Address, KTP, and Mobile with coordinates x 50, 130\r\n\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-apacheconf\" lang=\"apacheconf\">^CFA,30\r\n^FO50,130^FDName^FS\r\n^FO50,170^FDAlamat:^FS\r\n^FO50,210^FDKTP:^FS\r\n^FO50,250^FDMobile:^FS<\/code><\/pre>\r\n\r\n\r\nRows 7 &#8211; 18 are the same as rows no. 2 &#8211; 6\r\n\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-apacheconf\" lang=\"apacheconf\">^CFA,30\r\n^FO200,130^FDJohn Doe^FS\r\n^FO200,170^FDJln Jend. Sudirman^FS\r\n^FO200,210^FD123456789^FS\r\n^FO200,250^FD12345678^FS\r\n^FO600,170^FDNo^FS\r\n^FO700,170^FDRT^FS\r\n^FO600,270^FDRW^FS\r\n^FO700,270^FDNo^FS\r\n^FO590,310^FD1^FS\r\n^FO710,310^FD2^FS\r\n^FO710,210^FD3^FS<\/code><\/pre>\r\n\r\n\r\nLine 21 is for setting the barcode\r\n\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-apacheconf\" lang=\"apacheconf\">^A1N,30,22^BY2,2,70<\/code><\/pre>\r\n\r\n\r\nwhile line 22 is a barcode printer with position coordinates of position 230.20 and data 123456789\r\n\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-apacheconf\" lang=\"apacheconf\">^FO230,20^BC^FD123456789^FS <\/code><\/pre>\r\n\r\n\r\nLines 24-25 are for setting the font size to be bigger and bold\r\n\r\n\r\n<pre class=\"wp-block-code\"><code class=\"language-apacheconf\" lang=\"apacheconf\">^CFB,30\r\n^FO600,210^FD4^FS^XZ<\/code><\/pre>\r\n\r\n\r\n\r\n<div class=\"wp-block-spacer\" style=\"height: 100px;\" aria-hidden=\"true\">&nbsp;<\/div>\r\n\r\n<h3><span class=\"ez-toc-section\" id=\"Connection_Type\"><\/span>Connection Type<span class=\"ez-toc-section-end\"><\/span><\/h3>\r\nThere are 2 type connection to print\r\n<ol>\r\n \t<li>USB connection &#8211; We have to install the zebra printer driver, then if we print from the web we must also install the Browser Printer tools software<\/li>\r\n \t<li>Network connection &#8211; for this connection we do not need to install the driver, the zebra printer is built in its own local server.<\/li>\r\n<\/ol>\r\n\r\n\r\n<div class=\"wp-block-spacer\" style=\"height: 100px;\" aria-hidden=\"true\">&nbsp;<\/div>\r\n\r\n<h3><span class=\"ez-toc-section\" id=\"Example_Source_Code_printing_with_Zebra\"><\/span>Example Source Code printing with Zebra<span class=\"ez-toc-section-end\"><\/span><\/h3>\r\nThe following is a sample source code \/ printing script for the zebra printer, which can be downloaded at the link below\r\n\r\n<a href=\"https:\/\/github.com\/rudiahmad\/zebra-printer.git\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/rudiahmad\/zebra-printer.git<\/a>\r\n\r\nThere are 3 folders, namely:\r\n<ol>\r\n \t<li><a href=\"https:\/\/github.com\/rudiahmad\/zebra-printer\/tree\/master\/print-lwt-php\" target=\"_blank\" rel=\"noreferrer noopener\">print-lwt-php<\/a> -&gt; Script print via PHP<\/li>\r\n \t<li><a href=\"https:\/\/github.com\/rudiahmad\/zebra-printer\/tree\/master\/print-using-direct-ip\" target=\"_blank\" rel=\"noreferrer noopener\">print-using-direct-ip<\/a> -&gt; Script print via direct ip with javascript<\/li>\r\n \t<li><a href=\"https:\/\/github.com\/rudiahmad\/zebra-printer\/tree\/master\/zebra-browser-print-js-v30216\" target=\"_blank\" rel=\"noreferrer noopener\">zebra-browser-print-js-v30216<\/a> -&gt; Script library from zebra using browser print tools<\/li>\r\n<\/ol>","protected":false},"excerpt":{"rendered":"<p>There is work in the office that uses the ZT230 and GX430t zebra printers. We can print directly by selecting the zebra printer that has been installed, but if we need a certain format,&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1705,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,2],"tags":[62,145],"class_list":["post-1292","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-featured","category-komputer","tag-php","tag-source-code"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/posts\/1292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/comments?post=1292"}],"version-history":[{"count":3,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/posts\/1292\/revisions"}],"predecessor-version":[{"id":3865,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/posts\/1292\/revisions\/3865"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/media\/1705"}],"wp:attachment":[{"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/media?parent=1292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/categories?post=1292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bagi2info.com\/en\/wp-json\/wp\/v2\/tags?post=1292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}