I'm generating a document from a Google form and I want to format a certain text in the document.
This is my code:
//Add first paragraph (greeting)
var para1 = body.appendParagraph('Hi '+ email +', thank you for signing our
Laptop Policy. Here\'s a copy for your records.\n\n');
I get this outcome:
Hi [email protected], thank you for signing our Laptop Policy. Here's a copy for your records.
But I want this outcome (email address only in bold):
Hi [email protected], thank you for signing our Laptop Policy. Here's a copy for your records.
Create Text
objects and you can set the bold property individually on specific runs of text:
var para1 = body.appendParagraph('Hi ');
var emailText = para1.appendText(email);
emailText.setBold(true);
para1.appendText(', thank you for signing our Laptop Policy. Here\'s a copy for your records.\n\n');
If you merely had text in an existing paragraph, you could also just style parts of it (https://developers.google.com/apps-script/reference/document/text#setBold(Integer,Integer,Boolean)):
var text = somePara.editAsText();
text.setBold(5, 15, true);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments