Yehuda Solomont
Yehuda Solomont

Reputation: 118

Converting html to Google Doc

I have some html like this:

var html = '<h1>heading</h1><p>Lorem ipsum dolor sit amet<br>more text</p><ul><<li>Bulleted text</li></ul>'

And I want to convert this string into rich text in a google Doc. Any way I can do that?

Upvotes: 4

Views: 9031

Answers (1)

Tanaike
Tanaike

Reputation: 201643

For example, from your tag, if you want to achieve it using Google Apps Script, how about this sample script? I think that there are several solutions for your situation. So please think of this as just one of them.

When you use this script, please enable Drive API at Advanced Google Services and API console. You can see about this at here.

Sample script:

var html = '<h1>heading</h1><p>Lorem ipsum dolor sit amet<br>more text</p><ul><<li>Bulleted text</li></ul>';
var blob = HtmlService.createHtmlOutput(html).getBlob();
Drive.Files.insert({title: "fileName", mimeType: MimeType.GOOGLE_DOCS}, blob);

Note:

  • When you run this script after enable Drive API at Advanced Google Services and API console, new Document is created. When you open the Document, you can see the converted rich text from HTML.
  • This is a simple sample script. So please modify it for your situation.

Reference:

If this was not the result you want, I apologize.

Upvotes: 6

Related Questions