I am looking for a way to make in-line images vertically aligned so that the center of the in-line image vertically is aligned with the center of the text vertically. Currently, the bottom edge of the in-line images is flush with the bottom of the text. As a result, it seems like the images are much higher than they should be. Does anyone know if there's a way to control this from inside Google apps script, or any plans for development?
For instance, I want the in-line image on the 1st line in this Google Docs to look like the wrapped image on the 2nd line:
You would use the PositionedImage class to do this. WRAP_TEXT format should put your image inline, but you can still further fine tune using the various offset methods. https://developers.google.com/apps-script/reference/document/positioned-image
//EXAMPLE Modified from Apps Script Documentation
var body = DocumentApp.getActiveDocument().getBody();
// Append a new paragraph.
var paragraph = body.appendParagraph("New paragraph to anchor the image to.");
// Get an image in Drive from its ID.
var image = DriveApp.getFileById('ENTER_IMAGE_FILE_ID_HERE').getBlob();
// Add the PositionedImage with WRAP_TEXT Layout
var posImage = paragraph.addPositionedImage(image)
.setLayout(DocumentApp.PositionedLayout.WRAP_TEXT)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With