Connect with us


javascript-Generate PDF from Google Forms using Doc template with script




I’m using this script to create a PDF from Google using a Google Docs template.

The script I’m using is:

function afterFormSubmit (e) {const info = e.namedValues; const pdfFile = createPDF (info); const entryRow = e.range.getRow (); const ws = SpreadsheetApp.getActiveSpreadsheet (). getSheetByName (“Sheet2”) ws.getRange (entryRow, 63) .setValue (pdfFile.getUrl ()); ws.getRange (entryRow, 64) .setValue (pdfFile.getName ()); sendEmail (e.namedValues) [‘Email address’][0], PdfFile);} function sendEmail (email, pdfFile) {GmailApp.sendEmail (email, “Daily Transation Summary Report”, “Find the attached DTR”, {Attachment: [pdfFile], Name:’My company’});} function createPDF (info) {const pdfFolder = DriveApp.getFolderById (“1ebglel6vwMGXByeG4wHBBvJu9u0zJeMJ”); const tempFolder = DriveApp.getFolderById (“1ebglel6vwMGXBye”) 1kyFimRMdHQZV85F5P6JyCHv1DQ3KJFv1hx5o7lIcNZo “); const newTempFile = templateDoc.makeCopy (tempFolder); const openDoc = DocumentApp.openById (newTempFile.getId ()); const body = openDoc.getBody ()”[‘Name of Person’][0]); body.replaceText (“{report date}”, info[‘Date of Report’][0]); Body.replaceText (“{Outlet name}”, info[‘Name of Outlet’][0]); Body.replaceText (“{Opening Petty Cash Balance}”, info[‘Opening Petty Cash Balance’][0]); body.replaceText (“{Total petty cash received}”, info[‘Total Petty Cash Received’][0]); Body.replaceText (“{Closing Petty Cash Balance}”, info[‘Closing Petty Cash Balance’][0]); Body.replaceText (“{Total Petty Cash Paid}”, info[‘Total Petty Cash Paid’][0]); Body.replaceText (“{Available Float Cash Balance}”, info[‘Available Float Cash Balance’][0]); Body.replaceText (“{Milk For Outlet}”, info[‘Milk For Outlet’][0]); body.replaceText (“{Staff milk / toast etc.}”, info[‘Staff Milk/Toast etc.’][0]); Body.replaceText (“{Petrol Expenses}”, info[‘Petrol Expenses’][0]); Body.replaceText (“{water tank charge}”, information[‘Water Tank Charges’][0]); Body.replaceText (“{Repair and Maintenance}”, info[‘Repair And Maintenance’][0]); Body.replaceText (“{Freight Paid}”, info[‘Freight Paid’][0]); Body.replaceText (“{Purchase soybean chap}”, info[‘Purchase of Soya Chaap’][0]); Body.replaceText (“{Purchase Lumari Roti}”, info[‘Purchase of Rumali Roti’][0]); Body.replaceText (“{Purchase egg tray}”, info[‘Purchase of Egg Tray’][0]); Body.replaceText (“{Other Expenses}”, info[‘Other Expenses’][0]); Body.replaceText (“{Total Tip Amount (PAYTM & CARD)}”, info[‘Total Tip Amount (PAYTM & CARD)’][0]); Body.replaceText (“{Cash Sales-Outlet}”, info[‘Cash Sales – Outlet’][0]); Body.replaceText (“{Cash Sales-KCCO App}”, info[‘Cash Sales – KCCO App’][0]); Body.replaceText (“{Card Sales}”, info[‘Card Sales’][0]); body.replaceText (“{Credit (Udhar) Sales}”, info[‘Credit (Udhar) Sales’][0]); Body.replaceText (“{Paytm Sales}”, info[‘Paytm Sales’][0]); Body.replaceText (“{KCCO App Sales Razor Pay}”, info[‘KCCO App Sales Razor Pay’][0]); Body.replaceText (“{Swiggy Sales}”, info[‘Swiggy Sales’][0]); body.replaceText (“{Zomato Sales}”, info[‘Zomato Sales’][0]); Body.replaceText (“{Dunzo Sales}”, info[‘Dunzo Sales’][0]); body.replaceText (“{Zomato Gold Sales}”, info[‘Zomato Gold Sales’][0]); Body.replaceText (“{Dine Out Sales}”, info[‘Dine Out Sales’][0]); body.replaceText (“{Total canceled charges}”, info[‘Total Cancelled Bill Amount’][0]); body.replaceText (“{Today’s total sales (total above)}”, info[‘Total Sales of the Day (Total of Above)’][0]); body.replaceText (“{Today’s total sales (according to PetPooja)}”, info[‘Total Sales of the Day (As Per PetPooja)’][0]); Body.replaceText (“{Old Due Receipts-Cash}”, info[‘Old Due Receipts – Cash’][0]); Body.replaceText (“{Old Due Receipts-Other Modes}”, info[‘Old Due Receipts – Other Modes’][0]); Body.replaceText (“{Tip Receipts-Card}”, info[‘Tip Receipts – Card’][0]); Body.replaceText (“{Tip Receipts-Paytm}”, info[‘Tip Receipts – Paytm’][0]); Body.replaceText (“{INR 2000 Currency Note}”, info[‘Currency Note of INR 2000’][0]); body.replaceText (“{500 Indian Rupee Currency Banknotes}”, info[‘Currency Note of INR 500’][0]); body.replaceText (“{200 Indian Rupee Banknote}”, info[‘ Currency Note of INR 200’][0]); body.replaceText (“{100 Indian Rupee Currency Banknote}”, info[‘Currency Note of INR 100’][0]); Body.replaceText (“{INR 50 currency banknotes}”, info[‘Currency Note of INR 50’][0]); Body.replaceText (“{INR 20 currency banknotes}”, info[‘Currency Note of INR 20’][0]); Body.replaceText (“{INR 10 Currency Note}”, info[‘Currency Note of INR 10’][0]); Body.replaceText (“{Other banknotes / coins}”, info[‘Other Currency Note/Coins’][0]); body.replaceText (“{Total cash available for delivery}”, info[‘Total Available Cash to Handover’][0]); Body.replaceText (“{S.No .// Name of Person // Mobile No // Credit Approval By // Bill No // Total Amount of Credit”, info[‘S.No.//Name of Person// Mobile No// Credit Approval By// Bill No// Total Amount of Credit’][0]); body.replaceText (“{Total number of bills of credit collections}”, info[‘Total No. of Bills of Credit Recovery’][0]); Body.replaceText (“{S.No. // Person’s name // Mobile number // Payment method // Invoice number // Total amount received}”, info[‘S.No.//Name of Person// Mobile No// Mode of Payment// Bill No// Total Amount Received’][0]); body.replaceText (“{Total number of supplementary invoices during the day}”, info[‘Total No. of Complementary Bills During the Day’][0]); Body.replaceText (“{S.No .// Name of Person // Mobile No // Reason // Bill No // Amount Settled}”, info[‘S.No.//Name of Person// Mobile No//Reason// Bill No//Amount Settled’][0]); body.replaceText (“{Total number of invoices canceled during the day}”, info[‘Total No. of Cancelled Bills During the Day’][0]); Body.replaceText (“{S.No .// Name of Person // Mobile No // Bill No // Bill Amount}”, info[‘S.No.//Name of Person// Mobile No// Bill No// Bill Amount’][0]); Body.replaceText (“{S.No. // Invoice number // Payment method // Tip amount received}”, info[‘S.No.// Bill No// Mode of Payment//Tip Amount Received’][0]); body.replaceText (“{Number of cylinders received at outlet}”, info[‘No. of Cylinders Received at Outlet’][0]); openDoc.saveAndClose (); const blobPDF = newTempFile.getAs (MimeType.PDF); const pdfFile = pdfFolder.createFile (blobPDF) .setName (info)[‘Name of Outlet’][0]+ “” + Information[‘Date of Report’][0]); tempFolder.removeFile (newTempFile); Returns a pdfFile. }

This script has not generated a PDF and no PDF has been mailed.

The spreadsheet links are below

Please guide me.




The mention sources can contact us to remove/changing this article

What Are The Main Benefits Of Comparing Car Insurance Quotes Online

LOS ANGELES, CA / ACCESSWIRE / June 24, 2020, / Compare-autoinsurance.Org has launched a new blog post that presents the main benefits of comparing multiple car insurance quotes. For more info and free online quotes, please visit https://compare-autoinsurance.Org/the-advantages-of-comparing-prices-with-car-insurance-quotes-online/ The modern society has numerous technological advantages. One important advantage is the speed at which information is sent and received. With the help of the internet, the shopping habits of many persons have drastically changed. The car insurance industry hasn't remained untouched by these changes. On the internet, drivers can compare insurance prices and find out which sellers have the best offers. View photos The advantages of comparing online car insurance quotes are the following: Online quotes can be obtained from anywhere and at any time. Unlike physical insurance agencies, websites don't have a specific schedule and they are available at any time. Drivers that have busy working schedules, can compare quotes from anywhere and at any time, even at midnight. Multiple choices. Almost all insurance providers, no matter if they are well-known brands or just local insurers, have an online presence. Online quotes will allow policyholders the chance to discover multiple insurance companies and check their prices. Drivers are no longer required to get quotes from just a few known insurance companies. Also, local and regional insurers can provide lower insurance rates for the same services. Accurate insurance estimates. Online quotes can only be accurate if the customers provide accurate and real info about their car models and driving history. Lying about past driving incidents can make the price estimates to be lower, but when dealing with an insurance company lying to them is useless. Usually, insurance companies will do research about a potential customer before granting him coverage. Online quotes can be sorted easily. Although drivers are recommended to not choose a policy just based on its price, drivers can easily sort quotes by insurance price. Using brokerage websites will allow drivers to get quotes from multiple insurers, thus making the comparison faster and easier. For additional info, money-saving tips, and free car insurance quotes, visit https://compare-autoinsurance.Org/ Compare-autoinsurance.Org is an online provider of life, home, health, and auto insurance quotes. This website is unique because it does not simply stick to one kind of insurance provider, but brings the clients the best deals from many different online insurance carriers. In this way, clients have access to offers from multiple carriers all in one place: this website. On this site, customers have access to quotes for insurance plans from various agencies, such as local or nationwide agencies, brand names insurance companies, etc. "Online quotes can easily help drivers obtain better car insurance deals. All they have to do is to complete an online form with accurate and real info, then compare prices", said Russell Rabichev, Marketing Director of Internet Marketing Company. CONTACT: Company Name: Internet Marketing CompanyPerson for contact Name: Gurgu CPhone Number: (818) 359-3898Email: [email protected]: https://compare-autoinsurance.Org/ SOURCE: Compare-autoinsurance.Org View source version on accesswire.Com:https://www.Accesswire.Com/595055/What-Are-The-Main-Benefits-Of-Comparing-Car-Insurance-Quotes-Online View photos


to request, modification Contact us at Here or [email protected]