{"id":2071,"date":"2022-07-06T12:39:05","date_gmt":"2022-07-06T07:39:05","guid":{"rendered":"https:\/\/www.edopedia.com\/blog\/?p=2071"},"modified":"2022-07-06T12:39:08","modified_gmt":"2022-07-06T07:39:08","slug":"jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document","status":"publish","type":"post","link":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/","title":{"rendered":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document"},"content":{"rendered":"\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text\/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JavaScript&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;js&quot;}\">const doc = new jsPDF('p', 'pt', 'a4');\ndoc.autoTable({\n                        head: headerdata, \/\/ array of arrays\n                        theme: 'grid',\n                        body: bodydata, \/\/ arry of arrays\n                        startY: doc.autoTable.previous.finalY,\n                        Padding: { top: 20, right: 15, bottom: 20, left: 25, },\n                        styles: {\n                            lineColor: [220, 220, 220],\n                            lineWidth: 0.5,\n                            overflow: 'linebreak',\n                        },\n                        willDrawCell: (data) =&gt; {\n                            if (data.section === 'body' &amp;&amp; data.column.dataKey === 2) {\n                                doc.setFillColor(239, 154, 154);\n                                doc.roundedRect(data.cell.textPos.x + 3, data.cell.textPos.y + 3, data.cell.width, data.cell.height, 5, 5, 'FD');\n                            }\n                        },\n                        headStyles: { fillColor: [249, 249, 251], textColor: [34, 34, 34], },\n                        });\n    doc.save('test.pdf');<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":2073,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[112],"tags":[],"class_list":["post-2071","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document<\/title>\n<meta name=\"description\" content=\"const doc = new jsPDF(&#039;p&#039;, &#039;pt&#039;, &#039;a4&#039;); doc.autoTable({ head: headerdata, \/\/ array of arrays theme: &#039;grid&#039;, body: bodydata, \/\/ arry of arrays startY:\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document\" \/>\n<meta property=\"og:description\" content=\"const doc = new jsPDF(&#039;p&#039;, &#039;pt&#039;, &#039;a4&#039;); doc.autoTable({ head: headerdata, \/\/ array of arrays theme: &#039;grid&#039;, body: bodydata, \/\/ arry of arrays startY:\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/\" \/>\n<meta property=\"og:site_name\" content=\"Edopedia\" \/>\n<meta property=\"article:author\" content=\"trulyfurqan\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-06T07:39:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-06T07:39:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/jspdf_autotable_rounder_rectangle_in_table_cell.png\" \/>\n\t<meta property=\"og:image:width\" content=\"857\" \/>\n\t<meta property=\"og:image:height\" content=\"495\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Furqan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Furqan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document","description":"const doc = new jsPDF('p', 'pt', 'a4'); doc.autoTable({ head: headerdata, \/\/ array of arrays theme: 'grid', body: bodydata, \/\/ arry of arrays startY:","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/","og_locale":"en_US","og_type":"article","og_title":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document","og_description":"const doc = new jsPDF('p', 'pt', 'a4'); doc.autoTable({ head: headerdata, \/\/ array of arrays theme: 'grid', body: bodydata, \/\/ arry of arrays startY:","og_url":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/","og_site_name":"Edopedia","article_author":"trulyfurqan","article_published_time":"2022-07-06T07:39:05+00:00","article_modified_time":"2022-07-06T07:39:08+00:00","og_image":[{"width":857,"height":495,"url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/jspdf_autotable_rounder_rectangle_in_table_cell.png","type":"image\/png"}],"author":"Furqan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Furqan","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#article","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/"},"author":{"name":"Furqan","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339"},"headline":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document","datePublished":"2022-07-06T07:39:05+00:00","dateModified":"2022-07-06T07:39:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/"},"wordCount":15,"commentCount":0,"publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/jspdf_autotable_rounder_rectangle_in_table_cell.png","articleSection":["Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/","url":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/","name":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document","isPartOf":{"@id":"https:\/\/www.edopedia.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#primaryimage"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#primaryimage"},"thumbnailUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/jspdf_autotable_rounder_rectangle_in_table_cell.png","datePublished":"2022-07-06T07:39:05+00:00","dateModified":"2022-07-06T07:39:08+00:00","description":"const doc = new jsPDF('p', 'pt', 'a4'); doc.autoTable({ head: headerdata, \/\/ array of arrays theme: 'grid', body: bodydata, \/\/ arry of arrays startY:","breadcrumb":{"@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#primaryimage","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/jspdf_autotable_rounder_rectangle_in_table_cell.png","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2022\/07\/jspdf_autotable_rounder_rectangle_in_table_cell.png","width":857,"height":495,"caption":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document"},{"@type":"BreadcrumbList","@id":"https:\/\/www.edopedia.com\/blog\/jspdf-autotable-tutorial-draw-colorful-rounded-rectangle-in-a-cell-of-table-inside-pdf-document\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.edopedia.com\/blog\/"},{"@type":"ListItem","position":2,"name":"jsPDF Autotable Tutorial: Draw Colorful Rounded Rectangle in a Cell of Table inside PDF Document"}]},{"@type":"WebSite","@id":"https:\/\/www.edopedia.com\/blog\/#website","url":"https:\/\/www.edopedia.com\/blog\/","name":"Edopedia","description":"Coding\/Programming Blog","publisher":{"@id":"https:\/\/www.edopedia.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.edopedia.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.edopedia.com\/blog\/#organization","name":"Edopedia","url":"https:\/\/www.edopedia.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","contentUrl":"https:\/\/www.edopedia.com\/blog\/wp-content\/uploads\/2017\/10\/edopedia_icon_text_10.jpg","width":400,"height":100,"caption":"Edopedia"},"image":{"@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.edopedia.com\/blog\/#\/schema\/person\/3951cb19e3aa56df09e408c98aa02339","name":"Furqan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e5e68aef3ad8f0b83d56f4953c512c8e57bd2e6dc64daec33b5d0495d9058f51?s=96&d=mm&r=g","caption":"Furqan"},"description":"Well. I've been working for the past three years as a web designer and developer. I have successfully created websites for small to medium sized companies as part of my freelance career. During that time I've also completed my bachelor's in Information Technology.","sameAs":["http:\/\/www.edopedia.com\/blog\/","trulyfurqan"],"url":"https:\/\/www.edopedia.com\/blog\/author\/furqan\/"}]}},"_links":{"self":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/comments?post=2071"}],"version-history":[{"count":0,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/posts\/2071\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media\/2073"}],"wp:attachment":[{"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/media?parent=2071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/categories?post=2071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.edopedia.com\/blog\/wp-json\/wp\/v2\/tags?post=2071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}