Skip to content

Instantly share code, notes, and snippets.

@tanaikech tanaikech/submit.md
Last active May 17, 2019

Embed
What would you like to do?
Retrieving Total Page of Google Document using Google Apps Script

Retrieving Total Page of Google Document using Google Apps Script

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.