Gists

This is a sample script for retrieving total page of Google Document using Google Apps Script. There are no methods for directly retrieving the total page of Google Document. This is one of several workarounds. In this workaround, the total page is retrieved by converting to PDF format.

var n =
DriveApp.getFileById(id)
.getBlob()
.getDataAsString()
.split("/Contents").length - 1;
Logger.log("totalPages: %s", n);

• When you use this, please set the Google Document ID as id.