1

I'm trying to create an index page of a Google document using Google Docs API. The index is a list of chapters and the page number of the chapter.

For example:

  • Chapter 1: A Long-expected Party ... 1
  • Chapter 2: The Shadow of the Past ... 21
  • Chapter 3: Three is Company ... 54 (Whereas 1, 21, 54 are page numbers)

I got the content of the document so far, however, the page number seems to be not included. Is there any workaround?

Thanks

Reference: Google Docs API: https://developers.google.com/docs/api/reference/rest/v1/documents#Document

  • Unfortunately, as commented on related post at https://stackoverflow.com/q/66948920/15384825, "you can only get manual page breaks & not the number of pages, from the API." Thus, it is not possible by using just the API. Only if applicable, perhaps you can check and try the alternative way by using Apps Script from https://stackoverflow.com/questions/36432487/how-to-get-the-number-of-pages-in-google-docs-via-google-script – SputnikDrunk2 Aug 10 '21 at 23:14
  • Thanks! save as pdf -> PyPDF2 may be another alternative (https://pythonhosted.org/PyPDF2/) – Maria Shuvelle Aug 10 '21 at 23:21

0 Answers0