Document

Retrieving Glyph Value from List Items of Google Document using Google Apps Script

Gists This is a sample script for retrieving the glyph value from the list items of Google Document using Google Apps Script. In the current stage, when the list is put to the Google Document, the count of glyph is automatically calculated. When the glyph values of the list items are tried to be retrieved using the manual operation and the script, unfortunately, the glyph values cannot be retrieved. Only the values of the list are retrieved.

Replacing Template Texts with Array in Google Document using Google Apps Script

Gists This is a sample script for replacing the template texts with an array in Google Document using Google Apps Script. This is for Google Apps Script of this report. The sample input and output situations are as follows. In the current stage, when replaceAllText of Docs API is used with the sample value of ["updated text 1", "updated text 2", "updated text 3"], all values of {{oldText}} are replaced with the 1st value of updated text 1 in one batch request.

Replacing Template Texts with Array in Google Document using Docs API with Python

Gists This is a sample script for replacing the template texts with an array in Google Document using Docs API with Python. The sample input and output situations are as follows. In the current stage, when replaceAllText of Docs API is used with the sample value of ["updated text 1", "updated text 2", "updated text 3"], all values of {{oldText}} are replaced with the 1st value of updated text 1 in one batch request.

Changing Font of Selected Text to 'Google Sans' on Google Document using Google Apps Script

Gists This is a sample script for changing the font of selected text to Google Sans on Google Document using Google Apps Script. Sample script Please copy and paste the following script to the script editor of Google Document And, when you use this script, please select a text in Google Document and run the script. By this, the font of selected text is changed to Google Sans. function myFunction() { const selection = DocumentApp.

GAS Library - DocsServiceApp

Overview This is a Google Apps Script library for supporting Document service, Docs API, Spreadsheet service, Sheets API, Slides service and Slides API. The aim of this library is to compensate the processes that they services cannot achieve. Description The Google services, which are Document service, Docs API, Spreadsheet service, Sheets API, Slides service and Slides API, are growing now. But, unfortunately, there are still the processes that they cannot done.

Retrieving All URLs in Google Document using Google Apps Script

Gists This is a sample script for retrieving All URLs in Google Document using Google Apps Script. In this sample script, the method of “documents.get” in Google Docs API is used. By this, the URL can be retrieve using JSON.parse(). Sample script Before you use this script, please enable Google Docs API at Advanced Google Services. const documentId = "###"; // Please set the Google Document ID. const content = Docs.

Modifying 1st-Page Header in Google Document using Google Apps Script

Gists These are sample scripts for modifying the 1st-page header in Google Document using Google Apps Script. Unfortunately, in the current stage, the 1st-page header cannot be modified by Document service. In this case, it is required to use Google Docs API. Here, I would like to introduce 2 sample scripts for modifying the 1st page header using Docs API. When you use this, please enable Google Docs API at Advanced Google services.

Libraries of gdoctableapp for golang, Node.js and python were updated to v110

Libraries of gdoctableapp for golang, Node.js and python were updated to v1.1.0 go-gdoctableapp v1.1.0 (January 22, 2020) 2 new methods were added. From this version, the texts can be replaced by images. The direct link and local file can be used as the image. node-gdoctableapp v1.1.0 (January 22, 2020) New method was added. From this version, the texts can be replaced by images.

Libraries of gdoctableapp for golang, Node.js and python were updated to v105

Libraries of gdoctableapp for golang, Node.js and python were updated to v1.0.5 go-gdoctableapp node-gdoctableapp gdoctableapppy Update History v1.0.5 (January 21, 2020) When the inline objects and tables are put in the table. An error occurred. This bug was removed by this update. I got the pull request at here.

Deleting Last Empty Page of Google Document using Google Apps Script

Gists Overview This is a sample script for deleting the last empty page which has only one paragraph including no values which is "" in the Google Document using Google Apps Script. Description As a sample situation, it supposes that there is the following Google Document. In this sample, the last page of Google Document has only one paragraph including no values which is "". When I try to delete only last page without modifying the previous page, I noticed that this cannot be achieved with only Google Document service.

Creating a Table to Google Document by Retrieving Values from Google Spreadsheet for Python

Gists This is a sample script for creating a table to Google Document by retrieving values from Google Spreadsheet for Python. Before you use this script, please install python library of gdoctableapppy. $ pip install gdoctableapppy Sample script: This sample script uses Service Account. In this sample script, the values are retrieved from Sheet1!A1:C5 of Spreadsheet, and new table is created to the Document using the values. from google.oauth2 import service_account from gdoctableapppy import gdoctableapp from googleapiclient.

Creating a Table to Google Document by Retrieving Values from Google Spreadsheet for Node.js

Gists This is a sample script for creating a table to Google Document by retrieving values from Google Spreadsheet for Node.js. Before you use this script, please install Node.js module of node-gdoctableapp. $ npm install --save-dev gdoctableapp or $ npm install --global gdoctableapp Sample script: This sample script uses Service Account. In this sample script, the values are retrieved from Sheet1!A1:C5 of Spreadsheet, and new table is created to the Document using the values.

Creating a Table to Google Document by Retrieving Values from Google Spreadsheet for Golang

Gists This is a sample script for creating a table to Google Document by retrieving values from Google Spreadsheet for Golang. Before you use this script, please install go library of go-gdoctableapp. $ go get -v -u github.com/tanaikech/go-gdoctableapp Sample script: This sample script uses Service Account. In this sample script, the values are retrieved from Sheet1!A1:C5 of Spreadsheet, and new table is created to the Document using the values. package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" gdoctableapp "github.

python library - gdoctableapppy

Overview This is a python library to manage the tables on Google Document using Google Docs API. Description Google Docs API has been released. When I used this API, I found that it is very difficult for me to manage the tables on Google Document using Google Docs API. Although I checked the official document, unfortunately, I thought that it’s very difficult for me. So in order to easily manage the tables on Google Document, I created this library.

node module - node-gdoctableapp

Overview This is a Node.js module to manage the tables on Google Document using Google Docs API. Description Google Docs API has been released. When I used this API, I found that it is very difficult for me to manage the tables on Google Document using Google Docs API. Although I checked the official document, unfortunately, I thought that it’s very difficult for me. So in order to easily manage the tables on Google Document, I created this library.

Go Library - go-gdoctableapp

Overview This is a Golang library for managing tables on Google Document using Google Docs API. Description Google Docs API has been released. When I used this API, I found that it is very difficult for me to manage the tables on Google Document using Google Docs API. Although I checked the official document, unfortunately, I thought that it’s very difficult for me. So in order to easily manage the tables on Google Document, I created this library.

Creating New Table and Putting Values to Cells using Google Docs API with Google Apps Script

Gists This is a sample script for creating new table and putting values to cells using Google Docs API with Google Apps Script. Unfortunately, in the current stage, although I had been looking for the method for creating a table and putting the values in each cell at the official document, I couldn’t find. Google Docs API is growing now. So such documents might be not prepared yet. By this situation, I investigated about the method for achieving this method.

Deleting Pages of Google Document using Google Apps Script

Gists This is a sample script for deleting pages of Google Document from the last page using Google Apps Script. There are no methods for directly deleting pages of Google Document. This is one of several workarounds. In this workaround, the following flow is used. Flow Retrieve paragraphs in the body of Document. Retrieve elements in each paragraph. The page break is included in the paragraph. Delete elements from last page in order.

Retrieving Total Page of Google Document using Google Apps Script

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.

Limitations for Inserting Images to Google Docs

Gists When an image is inserted to Google Docs (Spreadsheet, Document and Slides) using the method of insertImage using Google Apps Script, there is the case that the error occurs. The error messages are “server error” and “invalid image data”. Here, I would like to introduce the limitations for inserting images to Google Docs. As the result, it was found that the limitation is due to both the mimeTypes and the area of image rather than the file size.

Deleting Positioned Images on Google Document using Google Apps Script

Gists This is a sample script for deleting the positioned images on Google Document using Google Apps Script. In the current stage, unfortunately, there are no methods for deleting the positioned images in Class PositionedImage, yet. But when Google Docs API is used, the positioned images can be deleted. When you use this script, please enable Google Docs API at Advanced Google Services and API console. You can see how to enable them at here

Modify Searched Text to Small Capital Letters using Google Apps Script

Gists This is a sample script for modifying the searched text to the small capital letters using Google Apps Script. Unfortunately, in the current stage, there are no methods for modifying the part of texts to the small capital letters in Document Service, yet. But when Google Docs API is used, this can be achieved. When you use this script, please enable Google Docs API at Advanced Google Services and API console.

Modify Shading Color of Paragraph on Google Document using Google Apps Script

Gists This is a script for modifying the shading color of paragraph on Google Document using Google Apps Script. Recently, by releasing Google Docs API, the shading color got to be able to be modified using the script. Here, I would like to introduce a sample script for modifying the shading color of the paragraph on Google Document. At the current Document Service, the shading color cannot be modified yet. I think that this will be achieved in the future update.

Replacing Text to Image for Google Document using Google Apps Script

Gists This is a sample script for replacing text to image for Google Document using Google Apps Script (GAS). There is a method for replacing text to text at Class Text of DocumentApp. But there are not methods for replacing text to image. So I created this sample script. Demo : This sample image was created by k3-studio. Usage : replaceTextToImage(body, replaceText, image, width); body : body of document. You can set by DocumentApp.

Retrieving Number of Lines of Google Document

Gists There are no prepared methods for retrieving the number of lines in the Google Document. So I thought this workaround. If the end of each line can be detected, the number of lines can be retrieved. So I tried to add the end markers of each line using OCR. At Google Documents, when a sentence is over the page width, the sentence automatically has the line break. But the line break has no \r\n or \n.