tanaike

The Thinker

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.

Retrieving Access Token using Service Account for Node.js without using googleapis

Gists This is a sample Node.js script to retrieve access token from Service Account of Google without using googleapis. const cryptor = require('crypto'); const request = require('request'); const privateKey = "###"; // private_key of JSON file retrieved by creating Service Account const clientEmail = "###"; // client_email of JSON file retrieved by creating Service Account const scopes = ["https://www.googleapis.com/auth/drive.readonly"]; // Sample scope const url = "https://www.googleapis.com/oauth2/v4/token"; const header = { alg: "RS256", typ: "JWT", }; const now = Math.

Creating New Google Docs and Overwriting Existing Google Docs by Text with Node.js without using googleapis

Gists There are 2 sample scripts. Create new Spreadsheet using a text value as CSV data. Overwrite the existing Google Document using a text value. When you use these script, please enable Drive API and retrieve your access token. Create New Spreadsheet using Text Value const request = require('request'); const textData = "a1, b1, c1, d1, e1"; // This is used as CSV data. const orgMimeType = "text/csv"; const orgFileName = "sample.

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.