Post navigation

84 thoughts on “ Create a PDF from each of the rows in a Google Sheet ”

Hi Andrew,
Thanks for this script. I am having success using it for our local car show. Question:
Is there any way to increase the daily mail sending limit on a free Google account? Request:
I too would be interested to have the ability to send HTML emails rather than plain text ones. Have you had chance to review “Albert’s” June 22,2017 comment/request on the page
https://www.andrewroberts.net/2016/01/google-apps-script-to-create-and-email-a-pdf/ Thanks again for your help. Kind regards, Larry

Hi, There is no way to increase the email quota. To add values into HTML you could simply add them into the HTML string:

var newValue = ‘abcd’;
var html = ‘ ‘ + newValue +
MailApp.sendEmail(
recipient,
EMAIL_SUBJECT,
EMAIL_BODY,
name: ‘your name’,
bcc: “additionalmail@mail.com”,
htmlBody: html,
attachments: [newFile]
>
)

Matheus on Monday, July 17th, 2017 Hello Adam, fisrt of all your script works wonders, would it be possible to use it one row at time?

If you want to be able to select individual rows to make a PDF, take a look at https://www.andrewroberts.net/2016/01/google-apps-script-to-create-and-email-a-pdf/

Hello and thank you very much for this script! One question, some of the column headers from my Google Sheet end in a question mark, so the placeholders for these columns in my template appear like so: %example?% with the closing % directly preceded by a ?. This appears to be causing an issue in my PDFs created using this script, because instead of the placeholders being replaced by the spreadsheet values they represent, I am just seeing the placeholder itself (%example?%). Do you know of a workaround for this issue? Thanks!

Replace the opening and closing %s with <> in your template and the code, as these are less likely to be mistaken for real text. line 121 would be: copyBody.replaceText('>', activeCell) Acauan Matias on Monday, February 5th, 2018

Dear Andrew and Dylan, I tried the solution with << and >> but doesn’t work. the problem is that to search, GAS uses regex, in which ? is a special char. the only way I found to workaround is:
add this before line 121: var h1=(“”+headerValue).replace(/\?/g,’\\?’) and change line 121 with this: copyBody.replaceText(“%” + h1 + “%”,activeCell). NOTE: use h1 any time you need to *search* for the header, but headerValue any time you need to print. If you print h1, it will come with fwd-slashed question marks -> \?. It took me ages to figure out where was the issue and a viable workaround. NOTE 2. Apparently the same Issue is with other regex special characters, like ( ) [ | . * + \ ^ $ so if the Header would include such chars, before line 121 can add var h1=(“”+headerValue).replace(/\?/g,’\\(‘)
var h1=(“”+headerValue).replace(/\?/g,’\\)’)
var h1=(“”+headerValue).replace(/\?/g,’\\[‘)
var h1=(“”+headerValue).replace(/\?/g,’\\|’) …etc for each of the characters.

Great, thanks for the response Andrew! Also, I am using your script that executes this same function on a single row, but I am unable to get it to trigger properly. I have configured the trigger to execute the script on form submission, but it appears the trigger is not working properly. Any ideas? Thanks, Dylan