【发布时间】:2021-12-15 02:55:02
【问题描述】:
我正在尝试将整个文档从一个复制到另一个。
我只是想将 INLINE_DRAWING 从一个谷歌文档复制到另一个,但我不断收到此错误。如果我删除了附加图纸的尝试,那么就没有错误,但是在我完成的文档中没有图纸。如何正确地将内联图从一个文档复制到另一个文档?
// fromFile & toFile are objects after calling .getBody()
function copyFileContentsFromTo(fromFile,toFile){
for(var i=0; i<fromFile.getNumChildren();i++){ //run through the elements of the template doc's Body.
var child = fromFile.getChild(i);
switch (fromFile.getChild(i).getType()) { //Deal with the various types of Elements we will encounter and append.
case DocumentApp.ElementType.PARAGRAPH:
// Look for child elements within the paragraph. Inline Drawings are children.
if(child.asParagraph().getNumChildren() !=0 && child.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) {
console.log("Found an Inline Drawing");
var drawing = child.asParagraph();
toFile.append(drawing.copy()); // This causes the error!
}else{
toFile.appendParagraph(child.copy());
}
break;
case DocumentApp.ElementType.TABLE:
toFile.appendTable(child.copy());
break;
default:
console.log("Whoops. Did not handle this Element Type when Copy Data from Template to Main: " + fromFile.getChild(i).getType());
break;
}
}
}
我已经到处搜索了,找不到任何资源,这是最接近的,但在我的屏幕截图中仍然产生错误:Google script InlineDrawing class
【问题讨论】:
标签: google-apps-script google-docs