{"id":1232,"date":"2020-06-14T15:50:22","date_gmt":"2020-06-14T15:50:22","guid":{"rendered":"https:\/\/sp2hari.com\/?p=1232"},"modified":"2020-06-14T15:50:22","modified_gmt":"2020-06-14T15:50:22","slug":"mail-merge-to-pdf-files-v2","status":"publish","type":"post","link":"https:\/\/sp2hari.com\/index.php\/2020\/06\/14\/mail-merge-to-pdf-files-v2\/","title":{"rendered":"Mail Merge to PDF Files &#8211; V2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>This is a follow up of the post I&#8217;ve shared earlier to create files earlier at <a href=\"https:\/\/sp2hari.com\/mail-merge-to-pdf-files\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/sp2hari.com\/mail-merge-to-pdf-files\/<\/a><\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While the first version of the post I made for creating multiple PDF files from Google Doc and Google Sheets still works, it is a lot <em>hackerish<\/em>. Copying the ID from the document, and managing the &#8216;Config&#8217; in the sheet is a lot of work. One can easily make a lot of mistakes while copy-pasting. Also, the user (I have only one so far) I had testing this script was very reluctant to run the script because of the overhead involved in managing these difficult document id and folder id. I realized I had to make the process much easier for someone to run the script. Hence the v2 with the settings option. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Create a new Google Sheet<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Open the sheet\u00a0<a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1ltQ0eQcmK_pztv0Bb8diJIzIr3YSMGU3soF-i6Bcmo4\/edit?usp=sharing\">https:\/\/docs.google.com\/spreadsheets\/d\/1ltQ0eQcmK_pztv0Bb8diJIzIr3YSMGU3soF-i6Bcmo4\/edit?usp=sharing<\/a>\u00a0and create a copy of the sheet using \u2018File -> Make a copy\u2019 option.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2: Create the template Google Doc<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Open the document&nbsp;<a href=\"https:\/\/docs.google.com\/document\/d\/1yAk0C5I-ycHxMB8jA3Anpu8LNLLKzxtu8N6PM5FG8H8\/edit?usp=sharing\">https:\/\/docs.google.com\/document\/d\/1yAk0C5I-ycHxMB8jA3Anpu8LNLLKzxtu8N6PM5FG8H8\/edit?usp=sharing<\/a>&nbsp;and create a copy of the doc using \u2018File -&gt; Make a copy\u2019 option. Copy the entire URL of this Google Document. We will need this later (to be used as &#8216;Template Link&#8217;)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3: Create the output Google folder<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Create a new empty folder in your Google Drive. This will be the folder where we generate the files. Copy the URL of this folder as well. We will need this later too (to be used as &#8216;Output Folder&#8217;)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 4: Create Google Apps Script<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">When you make a copy of the Google Sheets file, it automatically clones the script along with it. So you can avoid this step if you cloned the Google Sheet in Step 1. If you want to find the code powering this script, you can find it by following the option \u2018Tools -&gt; Script Editor\u2019. The latest version of the code will be also be maintained at <a href=\"https:\/\/gist.github.com\/sp2hari\/75334431913719f204030753da4eef2d\">https:\/\/gist.github.com\/sp2hari\/75334431913719f204030753da4eef2d<\/a>. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 5: Run the script<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"478\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-1024x478.png\" alt=\"\" class=\"wp-image-1244\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-1024x478.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-300x140.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-768x359.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-1536x718.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-2048x957.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.24-AM-642x300.png 642w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Settings option under the Jetpack menu<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"478\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-1024x478.png\" alt=\"\" class=\"wp-image-1243\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-1024x478.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-300x140.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-768x359.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-1536x718.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-2048x957.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.16.48-AM-642x300.png 642w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Authorization needed to run script &#8211; Need to do this first time only.<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"478\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-1024x478.png\" alt=\"\" class=\"wp-image-1242\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-1024x478.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-300x140.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-768x359.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-1536x718.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-2048x957.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.11-AM-642x300.png 642w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Again, need to do this first time only.<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"549\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-1024x549.png\" alt=\"\" class=\"wp-image-1241\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-1024x549.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-300x161.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-768x412.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-1536x824.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-2048x1098.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.18.27-AM-559x300.png 559w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Again, need to do this first time only.<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"331\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-1024x331.png\" alt=\"\" class=\"wp-image-1240\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-1024x331.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-300x97.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-768x249.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-1536x497.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-2048x663.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.19.40-AM-927x300.png 927w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Setting options with no details updated<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"331\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-1024x331.png\" alt=\"\" class=\"wp-image-1239\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-1024x331.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-300x97.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-768x249.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-1536x497.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-2048x663.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.20.52-AM-927x300.png 927w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Settings option with template link, output folder and file name filled in.<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"462\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-1024x462.png\" alt=\"\" class=\"wp-image-1238\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-1024x462.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-300x135.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-768x347.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-1536x694.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-2048x925.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.13-AM-664x300.png 664w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Success message after settings is published.<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"462\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-1024x462.png\" alt=\"\" class=\"wp-image-1248\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-1024x462.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-300x135.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-768x347.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-1536x694.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-2048x925.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.31.57-AM-664x300.png 664w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Sample Data<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"462\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-1024x462.png\" alt=\"\" class=\"wp-image-1237\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-1024x462.png 1024w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-300x135.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-768x347.png 768w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-1536x694.png 1536w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-2048x925.png 2048w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Screenshot-2020-06-14-at-1.21.48-AM-664x300.png 664w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>The final bliss message!<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">There is one interesting image on how to build an MVP that comes back to my mind looking at the v1 and v2 post. The earlier version had the hackish &#8216;Config&#8217; sheet with which you had to manage the settings. It still works, but not easy to work with. You had to do a lot of hard work to make it happen.  The v2 has this much better looking &#8216;Settings&#8217; option to manage the Config details. It makes the job easier and has a bunch of error handling added to the settings page. Looking forward to the v3, v4, and v5. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"411\" src=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Making-sense-of-MVP-.png\" alt=\"\" class=\"wp-image-1253\" srcset=\"https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Making-sense-of-MVP-.png 609w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Making-sense-of-MVP--300x202.png 300w, https:\/\/sp2hari.com\/wp-content\/uploads\/2020\/06\/Making-sense-of-MVP--445x300.png 445w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><figcaption>How to build an MVP.<\/figcaption><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a follow up of the post I&#8217;ve shared earlier to create files earlier at https:\/\/sp2hari.com\/mail-merge-to-pdf-files\/ While the first version of the post I made for creating multiple PDF files from Google Doc and Google Sheets still works, it is a lot hackerish. Copying the ID from the document, &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1232","post","type-post","status-publish","format-standard","hentry","category-code"],"_links":{"self":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/1232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/comments?post=1232"}],"version-history":[{"count":16,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/1232\/revisions"}],"predecessor-version":[{"id":1260,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/posts\/1232\/revisions\/1260"}],"wp:attachment":[{"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/media?parent=1232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/categories?post=1232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sp2hari.com\/index.php\/wp-json\/wp\/v2\/tags?post=1232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}