【发布时间】:2015-06-01 14:34:34
【问题描述】:
我正在尝试创建一个邮件合并功能来创建一个基于简单模板的文档。 我尝试使用以下函数复制模板元素,但我遇到了(内联)图像问题,它们始终显示为 PARAGRAPH 而不是 INLINE_IMAGE,并且出现以下图标而不是图像:
代码如下:
function appendToDoc(src, dst) {
// iterate accross the elements in the source adding to the destination
for (var i = 0; i < src.getNumChildren(); i++) {
appendElementToDoc(dst, src.getChild(i));
}
}
function appendElementToDoc(doc, object)
{
var element = object.copy();
var type = object.getType();
if (type == DocumentApp.ElementType.PARAGRAPH) {
doc.appendParagraph(element);
} else if (type == DocumentApp.ElementType.TABLE) {
doc.appendTable(element);
} else if (type== DocumentApp.ElementType.INLINE_IMAGE) { // This is never called :(
var blob = element.asInlineImage().getBlob();
doc.appendImage(blob);
}
}
关于如何解决这个问题的任何想法?提前致谢!
【问题讨论】:
标签: google-apps-script google-docs