简体   繁体   English

使用 Google Apps Script 将 HTML 注入 Google Docs

[英]Inject HTML into Google Docs using Google Apps Script

I am using Apps Script to create Google Docs.我正在使用 Apps 脚本来创建 Google 文档。 The Apps Script has been deployed as an API Executable. Apps 脚本已部署为 API 可执行文件。 The Apps Script receives the request json, which it writes to the Google Doc. Apps 脚本接收请求 json,并将其写入 Google Doc。 I am able to create and print the values from input JSON as String in Google Doc.我能够在 Google Doc 中创建和打印输入 JSON 中的值作为字符串。

The input JSON has some of the properties whose value is HTML.输入 JSON 具有一些值为 HTML 的属性。 How can I render the HTML in Google Doc using Apps Script?如何使用 Apps Script 在 Google Doc 中呈现 HTML?

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. Google Apps Script 和 Google Docs API 不是直接呈现 HMTL 并将结果显示添加到 Google 文档的内置方式。

The answer to Render HTML to a Google Doc using app script?使用应用程序脚本HTML 渲染到 Google Doc答案 offer a workaround: convert an HTML doc to a Google Document by using the Google Drive Advanced Service.提供一种解决方法:使用 Google Drive Advanced Service 将 HTML 文档转换为 Google 文档。

  1. Create an HTML and upload it to Google Drive创建 HTML 并将其上传到 Google Drive
  2. Convert the HTML file to a Google Document format将 HTML 文件转换为 Google 文档格式
  3. Get the content of the above Google Document and insert / append it to the document target.获取上述 Google 文档的内容并将其插入/附加到文档目标。

Another option could be to use a third party service or a JavaScript library that does the HTML rendering.另一种选择是使用第三方服务或执行 HTML 呈现的 JavaScript 库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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