Analyzing, duplicating, and modifying document elements
In the first section of this chapter, we have built a document from scratch using various methods, but we could also try the reverse process; in other words, we can analyze a document to see its content.
In doing so, we will be able to copy a part of the document, modify the document's content, and even insert new elements in the document or simply assemble multiple documents in one (see, for example, my last answer on this post at http://stackoverflow.com/questions/10939031/how-to-delete-blank-pages-in-a-multipage-).
Just about every method set in DocumentApp
has a symmetric get
method that returns precise information on every element. Elements can be built hierarchically with parents and children (I used that hierarchy when inserting the image in our example; the image was a child of the paragraph : body.appendParagraph('good apetite').appendInlineImage(image)
and a good analyze script will have to examine elements at every level.