How to bold only a part of a paragraph?

Federico Joly

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.

dtanabe

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.

edited at
0

Comments

0 comments
Login to comment

Related

Tkinter: How do I Bold 'small part' of a text within a paragraph?

How Do I Bold only part of a string in an excel cell with python

How to bold part of label?

How to BOLD certain words within an NSString paragraph

How to bold a modified paragraph in python docx

How to set part of string bold?

Make only one part of a string bold in vuejs

How do you bold only one part of a sentence using google apps scripts?

How to partially bold a Paragraph in Apache POI? (Word Documents)

How do I bold (or format) a piece of text within a paragraph?

How to convert some text in paragraph into bold xsl fo?

Python - How to make a paragraph bold and red while writing into MS Word?

how to bold a part of text Android String

How to make a part of text bold in resource dictionary

How to make part of a string bold in iOS?

How to print a part of an item in bold with JList

How to write part of a string bold in Android programmatically?

How to Bold certain text part of a string

How can I make part of the text bold?

How to make a part of string variable bold

How to make some part of the string bold?

python, how to cut a part of information in a paragraph

Only select bold & underline text in current paragraph (VBA macro, word 2016)

Beautifulsoup how to extract paragraph from this page perfectly? only paragraph

How to bold searched content using only javascript?

How to display bold text in only parts of JTextArea?

WPF DataGrid How to bold only first row

JSoup - How to extract only the href in paragraph

How to show only paragraph when cursor is on the heading