Keeping image and text together on one page in Google Docs using Google Apps Script

25 Views Asked by At

I am adding data from a Google Forms form to a Google doc.

Part of the form are a couple of images. I am successfully adding them to a Google doc and want to add a text label to describe the image. I am using this code snippet in a loop:

body.insertParagraph(indexOfStartElement++, value[0] + ": ");
body.insertImage(indexOfStartElement++, getImage(info[value[0]][0]));

Sometimes, the image and the label are not kept together on one page, like shown here:

enter image description here

How can I keep them together?

0

There are 0 best solutions below