{"id":5048,"date":"2019-02-11T10:56:19","date_gmt":"2019-02-11T10:56:19","guid":{"rendered":"https:\/\/max-drake.cc\/?p=5048"},"modified":"2019-02-11T10:56:19","modified_gmt":"2019-02-11T10:56:19","slug":"first-apps-script-ocr-capture-from-youtube-sheets-to-pdf","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=5048","title":{"rendered":"First Apps Script,  OCR capture from YouTube  &#038; Sheets to PDF"},"content":{"rendered":"<h2>YouTube screen capture convert text<\/h2>\n<p>I watch tutorial videos to learn how to do certain things in coding. Sometimes, in the video, they leave a copy of the code so that you can download it, other times this is not the case.<\/p>\n<p>So you have to write the code out longhand for yourself, which can be a bit tedious.<\/p>\n<p>I have recently started using Google Keep again for notes and lists. A nice feature of Keep is that you can open it in your browser, so while on the computer you can quickly add items to current lists.<\/p>\n<p>Another feature that I saw demonstrated and have been tinkering with is the OCR (Optical character recognition) image to text feature. I have been trying to see if I can use a picture of my shopping receipts to get data for my Spending Tracker Form that I created (see previous blog). I am still working on that.<\/p>\n<p>In an earlier post I used autoCrat Addon to merge a template for \u201cQuotes for Services\u201d\u00a0 from an online Google Form and that generated the pdf files that was an attachment to email. The issue was the saved forms were saved as Google Sheets , not PDF\u2019s (unlike Document Studio add on). I would prefer to have PDF\u2019s as a archive record rather than just the sheets, so you have a non tamperable record.<\/p>\n<p>I found this video:<br \/>\n<iframe data-src=\"https:\/\/www.youtube.com\/embed\/vxy0swbSecQ\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<h2>Using Google Keep OCR feature to capture text<\/h2>\n<p>I thought was an elegant way to resolve this issue, but there was no attached code at the bottom of the video. So I zoomed into the video in the browser &amp; took a screenshot of the text:<\/p>\n<p><img decoding=\"async\" width=\"1753\" height=\"1050\" class=\"wp-image-5072 lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-6.jpeg\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-6.jpeg 1753w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-6-300x180.jpeg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-6-768x460.jpeg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-6-1024x613.jpeg 1024w\" data-sizes=\"(max-width: 1753px) 100vw, 1753px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1753px; --smush-placeholder-aspect-ratio: 1753\/1050;\" \/><\/p>\n<p>I imported that image into google Keep<\/p>\n<p><img decoding=\"async\" width=\"1380\" height=\"1087\" class=\"wp-image-5073 lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-7.jpeg\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-7.jpeg 1380w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-7-300x236.jpeg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-7-768x605.jpeg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/word-image-7-1024x807.jpeg 1024w\" data-sizes=\"(max-width: 1380px) 100vw, 1380px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1380px; --smush-placeholder-aspect-ratio: 1380\/1087;\" \/><\/p>\n<p>Once in Keep in a new note I could use the GRAB IMAGE TEXT feature and it wrote the text in the form below.<\/p>\n<p>There were missing brackets, equal signs, apostrophes,quotes, colons and semicolons that were missed but you are only editing these items rather than writing the whole code out from scratch.<\/p>\n<p>Its nice to have the image directly above to check the text to see its the same.<\/p>\n<p>The code is here:<\/p>\n<p><em>function getDocs(){<\/em><\/p>\n<p><em>var folderId=&#8217;1tqjJHZe_qJuJogy21cGZkjZVr8g3n8fa&#8217;;<\/em><\/p>\n<p><em>var pdfFolder=DriveApp.getFolderById(folderId).createFolder( &#8216;PDFs&#8217;);<\/em><\/p>\n<p><em>var files=DriveApp.getFolderById(folderId).getFiles();<\/em><\/p>\n<p><em>while(files.hasNext()) {<\/em><\/p>\n<p><em>var file =files.next();<\/em><\/p>\n<p><em>var pdf =file.getAs(&#8216;application\/pdf&#8217;);<\/em><\/p>\n<p><em>pdfFolder.createFile(pdf.copyBlob());<\/em><\/p>\n<p><em>}<\/em><em>}<\/em><\/p>\n<h2>Testing the captured code<\/h2>\n<p>So now I have the code to test.I have to figure out how to run an apps script, the video below shows the steps. Note, in the current version it says this is not a google approved app so go into advanced and choose to approve script anyway.<\/p>\n<p><iframe data-src=\"https:\/\/www.youtube.com\/embed\/Pgfbl_o9WvM\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" data-load-mode=\"1\"><\/iframe><\/p>\n<p>So, testing the code, first I went to:<\/p>\n<p><strong>script.google.com<\/strong><\/p>\n<p>Put in the code and saved it, then ran it.<\/p>\n<p>I had to get a link to the folder where the files were located, as per the original video and replace folder name in first line of code below,<\/p>\n<p><img decoding=\"async\" class=\"wp-image-5076 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_34_47-sheets-to-pdfs-300x139.jpg\" alt=\"\" width=\"1852\" height=\"858\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_34_47-sheets-to-pdfs-300x139.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_34_47-sheets-to-pdfs-768x355.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_34_47-sheets-to-pdfs-1024x474.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_34_47-sheets-to-pdfs.jpg 1085w\" data-sizes=\"(max-width: 1852px) 100vw, 1852px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1852px; --smush-placeholder-aspect-ratio: 1852\/858;\" \/><\/p>\n<p>In the folder where all of the spreadsheets were it created a new folder, as per the code:<\/p>\n<p><img decoding=\"async\" class=\"wp-image-5074 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_37-SheetSetQuotes-Google-Drive-300x256.jpg\" alt=\"\" width=\"1747\" height=\"1491\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_37-SheetSetQuotes-Google-Drive-300x256.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_37-SheetSetQuotes-Google-Drive-768x655.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_37-SheetSetQuotes-Google-Drive.jpg 1011w\" data-sizes=\"(max-width: 1747px) 100vw, 1747px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1747px; --smush-placeholder-aspect-ratio: 1747\/1491;\" \/><\/p>\n<p>It also generated the PDF files of all the spreadsheets in the directory above<\/p>\n<p><img decoding=\"async\" class=\"wp-image-5075 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_51-PDFs-Google-Drive-300x253.jpg\" alt=\"\" width=\"1665\" height=\"1404\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_51-PDFs-Google-Drive-300x253.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_51-PDFs-Google-Drive-768x647.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_17_51-PDFs-Google-Drive.jpg 928w\" data-sizes=\"(max-width: 1665px) 100vw, 1665px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1665px; --smush-placeholder-aspect-ratio: 1665\/1404;\" \/><\/p>\n<p>I was worried that, being spreadsheets instead of docs the code may get confused, but as there is only one tab in each spreadsheet the pdf was exactly what I wanted.<\/p>\n<h2><img decoding=\"async\" class=\"wp-image-5077 aligncenter lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_39_24-PDFs-Google-Drive-300x228.jpg\" alt=\"\" width=\"1787\" height=\"1358\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_39_24-PDFs-Google-Drive-300x228.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_39_24-PDFs-Google-Drive-768x584.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-10_39_24-PDFs-Google-Drive-1024x778.jpg 1024w\" data-sizes=\"(max-width: 1787px) 100vw, 1787px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1787px; --smush-placeholder-aspect-ratio: 1787\/1358;\" \/>End comment<\/h2>\n<p>I have been looking at the Apps Scripts and seeing if I can find some pre-made scripts that will help automate some of the things I am working on.\u00a0 I haven&#8217;t found a good repository yet. There seem to be more samples to teaching a process. I am looking for practical ones, like the one above, that will help me automate common processes.<\/p>\n<p>I am pleased with the OCR capture tool in Keep. There are other OCR free tools out there, but Keep is readily available across my devices so at hand for this task. I don&#8217;t think I would have loaded up a specific OCR programme just to do this task for such a small amount of text.<\/p>\n<p>I am also pleased with the code operating. A nice solution for AutoCrat sheets addon. I like it more than the Document Studio as its a bit more flexible. I like the fact that it saves the merged sheets as sheets , rather than PDF&#8217;s as that will allow me to easily go back and adjust the quote in the original spreadsheet quote without having to setup one specifically for adjustments.\u00a0 This code solves that issue nicely.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>YouTube screen capture convert text I watch tutorial videos to learn how to do certain things in coding. Sometimes, in the video, they leave a copy of the code so that you can download it, other times this is not the case. So you have to write the code out longhand for yourself, which can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5078,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[204,265,29],"tags":[283,175,256,48],"class_list":["post-5048","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-automation","category-google-docs","category-web","tag-apps-script","tag-automation","tag-google-keep","tag-productivity"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-11_48_16-Google-Keep.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2019\/02\/2019-02-12-11_48_16-Google-Keep.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/5048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5048"}],"version-history":[{"count":0,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/5048\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/5078"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}