-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreplaceTextExt
More file actions
18 lines (14 loc) · 847 Bytes
/
replaceTextExt
File metadata and controls
18 lines (14 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function replaceTextExt(fileTag, refGID)
{
var fileId = refGID; //Gets GID for blob being used.
var tag = fileTag; //Tag where item will be appended
var style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.CENTER;
var blob = DriveApp.getFileById(fileId).getBlob(); //Gets image blob
if (newBody.findText(tag) != null) //Makes sure tag exists
{
var replacedParent = newBody.findText(tag).getElement().getParent().asParagraph(); //Identifies tag location
var clearTag = newBody.replaceText(tag, ""); //Removes placeholder tag
replacedParent.appendInlineImage(blob).setAttributes(style); //Adds image at tag location using set "style"
}
}