Created
December 12, 2015 03:30
-
-
Save mogsdad/e65826da9974650e2abc to your computer and use it in GitHub Desktop.
Google Apps Script demo of new PositionedImages. See https://mogsdad.wordpress.com.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Demo of PositionedImages. | |
* From: gist.github.com/mogsdad/e65826da9974650e2abc | |
* See: stackoverflow.com/a/20661113/1677912 | |
**/ | |
function DemoPositionedImage() { | |
// Get handle on active document | |
var doc = DocumentApp.getActiveDocument(); | |
// Find desired image file | |
var matchedFiles = DriveApp.getFilesByName('apple-touch-icon.png'); | |
if (matchedFiles.hasNext()) { | |
// Get image object from file | |
var image = matchedFiles.next().getBlob(); | |
// Add image as a PositionedImage. | |
var positionedImage = doc.getBody().getParagraphs()[0].addPositionedImage(image); | |
// Adjust layout, etc. here | |
// Log the ID of the new image | |
Logger.log( positionedImage.getId() ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment