Created
November 30, 2019 20:29
-
-
Save michaelos02/ba2ecb9d50c4a4a6019351856dde3018 to your computer and use it in GitHub Desktop.
Counting Pages in Google Doc - can't be done BUT if you make it a PDF you can. Here is link: https://stackoverflow.com/questions/36432487/how-to-get-the-number-of-pages-in-google-docs-via-google-script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getNumPages() { | |
var blob = DocumentApp.getActiveDocument().getAs("application/pdf"); | |
var data = blob.getDataAsString(); | |
var pages = parseInt(data.match(/ \/N (\d+) /)[1], 10); | |
Logger.log("pages = " + pages); | |
return pages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment