I use Google Script to create a Google Docs file and want to get the page number of this document as soon as I have finished creating the content of the document. I used the following code at the end of my program:
var data = doc.getAs("application/pdf").getDataAsString();
var pages = data.match(/\/Contents/g).length;
Logger.log(pages);
No matter how many pages the newly created document has, the result I get is always pages = 1.0
. Actually I used the existing code, so I don't understand it well. I really need help. Thank you.