Mail merge: can't append images from template

后端 未结 1 618
轻奢々
轻奢々 2021-01-26 15:31

I\'m trying to create a mail merge function to create a document based on a simple template. I tried to use the following function to copy the template elements but I\'m having

相关标签:
1条回答
  • 2021-01-26 16:22

    As per my knowledge, inline images are included in a paragraph so we have to check for Image type in the Paragraph.

    So the code for checking that would be this way:

    if (type == DocumentApp.ElementType.PARAGRAPH) {
          if (element.asParagraph().getNumChildren() != 0 && element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_IMAGE) {
            var blob = element.asParagraph().getChild(0).asInlineImage().getBlob();
            doc.appendImage(blob);
          }
          else doc.appendParagraph(element.asParagraph());
        }
    

    Hope that helps!

    0 讨论(0)
提交回复
热议问题