Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make in-line images vertically aligned with text?

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: Vertically aligned images

like image 664
John Targaryen Avatar asked Oct 20 '16 22:10

John Targaryen


1 Answers

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)
like image 182
Spencer Easton Avatar answered Nov 18 '22 18:11

Spencer Easton