I’m working with Google Apps Script to add images to my documents. Right now I can insert images just fine, but they always appear as inline images which breaks up my text flow.
function addImageToDocument() {
var document = DocumentApp.openById('my-document-id');
var imageFile = DriveApp.getFileById('my-image-id').getBlob();
document.getBody().insertImage(0, imageFile);
}
This code works but creates an inline image that sits right in the middle of the text. What I really need is to make the text wrap around the image instead. Is there a way to programmatically change the image positioning from inline to wrapped text mode? I’ve been searching through the documentation but can’t find a method to control this setting through code.
totally get u! it’s so annoying that Apps Script can only do inline. after your script runs, just change the image wrap manually in Docs. fingers crossed Google adds this feature soon!
Unfortunately, Google Apps Script doesn’t support changing image wrapping properties. The DocumentApp service only has basic insertImage() functionality, which defaults to inline positioning. I hit this same wall when automating reports at work. My workaround was inserting images at paragraph breaks and adding empty paragraphs around them to fake text wrapping. Not perfect, but way better than images randomly stuck in sentences. You could try the Google Docs API directly instead of Apps Script, though it had similar limitations last I checked.
Been wrestling with this exact problem for months. DocumentApp is really limited for image positioning. Here’s what works: create a table with invisible borders, drop your image in one cell, and leave the next cell empty for text. It’s not real text wrapping but looks similar. I’ve also tried inserting images as drawing objects first, then converting them - but that needs extra steps and won’t automate well. Google really needs to fix this. Image manipulation in Apps Script is way too basic for something this standard.