简体   繁体   中英

Inject HTML into Google Docs using Google Apps Script

I am using Apps Script to create Google Docs. The Apps Script has been deployed as an API Executable. The Apps Script receives the request json, which it writes to the Google Doc. I am able to create and print the values from input JSON as String in Google Doc.

The input JSON has some of the properties whose value is HTML. How can I render the HTML in Google Doc using Apps Script?

Google Apps Script and the Google Docs API doesn't a built-in way to directly render HMTL and add the resuling display to the Google document.

The answer to Render HTML to a Google Doc using app script? offer a workaround: convert an HTML doc to a Google Document by using the Google Drive Advanced Service.

  1. Create an HTML and upload it to Google Drive
  2. Convert the HTML file to a Google Document format
  3. Get the content of the above Google Document and insert / append it to the document target.

Another option could be to use a third party service or a JavaScript library that does the HTML rendering.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM