Using a script to insert an image into a document

A complete example including every method would be very long, so I'll show a simplified layout to show how it works, but that only identifies every type of element and replaces a paragraph with an image if a predefined placeholder =='###', is found in the paragraph.

You should easily be able to implement a more universal version yourself that adds or modifies elements based on certain conditions. Test the following code in a text document, such as the one we just created with our recipes.

function findMarkAndReplace() { var Doc = DocumentApp.getActiveDocument(); var image = DocsList.getFileById('0B3qSFd3iikE3UmpjelRQdlZmQXc'); // this is an image from the recipe's example stored on my drive and shared ...

Get Google Apps Script for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.