What I am trying to do is:
- On page 1, insert table 1
- Move to page 2, insert table 2
I am able to insert two tables one after the other but unable to break to a new page before inserting table 2.
docId = "YOUR_DOC_ID";
var doc = DocumentApp.openById(docId);
var body = doc.getBody();
var table1 = body.insertTable(2, data[0]);
formatTable(table1);
// insert page break here
var table2 = body.insertTable(3, data[1]);
formatTable(table2);
doc.saveAndClose();
The insertPageBreak() is what I am struggling with.
What I have tried till now:
- The only
appendPageBreak
I could find is onbody
. So I triedbody.appendPageBreak()
. This inserts a new page at the "very" end. BUT I require it right after table 1. - I read THIS documentation but could not implement it due to lack of examples I guess.
- For THIS answer, I get NULL for
getCursor()
command. AlsotheElement.insertPageBreak(0)
failed for me since element did not show anyinsertPageBreak()
method. - For THIS answer, as mentioned above, appends at the end.
Any help will be appreciated.