ResumableUploadForGoogleDrive_js was updated to v2.0.2.
-
v2.0.2 (May 23, 2024)
- From this version, the files could be also uploaded to the shared drive.
CDN
Class ResumableUploadToGoogleDrive
This Class can achieve the resumable upload of a file by reading the file to the memory.
<script src="https://cdn.jsdelivr.net/gh/tanaikech/ResumableUploadForGoogleDrive_js@2.0.2/resumableupload_js.min.js"></script>
Class ResumableUploadToGoogleDrive2
This Class can achieve the resumable upload of a file by directly reading partially the file from the local Disk. By this, the large file which is over the memory of the local PC can be uploaded.
Gists

Abstract
The Gemini API traditionally required specific prompts for desired output formats. This report explores two new GenerationConfig properties: “response_mime_type” and “response_schema”. These allow developers to directly specify formats like JSON, enhancing control and predictability. We analyze and compare the effectiveness of both properties for controlling Gemini API output formats.
Introduction
One of the key challenges when working with the Gemini API is ensuring the output data is delivered in the format your application requires. Traditionally, the response format heavily relied on the specific prompt you provided. For example, retrieving data as a structured JSON object necessitated including a “Return JSON” prompt within your input text. This approach could be cumbersome and error-prone if the desired format wasn’t explicitly requested.
GeminiWithFiles was updated to v1.0.3.
-
v1.0.3 (May 17, 2024)
- Bugs were removed.
You can see the detail information here https://github.com/tanaikech/GeminiWithFiles
ImgApp was updated to v1.3.3.
- v1.3.3 (May 16, 2024)
In SlidesAppp.gs, added a script for checking whether Drive API and Slides API are enabled. Ref
You can see the detail information here https://github.com/tanaikech/ImgApp
Gists

Overview
This script checks if the desired API is enabled or disabled in the Advanced Google Services section of Google Apps Script.
Introduction
As of December 11, 2023, Drive API v3 became available for use in Advanced Google Services. Ref This means you can now choose between v2 and v3 in your scripts. However, when Drive API is enabled, version 3 is automatically selected. This caused compatibility issues with previously published libraries that relied on v2.
PDFApp was updated to v1.0.7.
-
v1.0.7 (May 15, 2024)
- The method of “addPageNumbers” was updated. Ref When a number is used to the property
x instead of “left”, “center”, and “right”, the inputted number is directly used.
You can see the detail information here https://github.com/tanaikech/PDFApp
PDFApp was updated to v1.0.6.
-
v1.0.6 (May 15, 2024)
- A new method of “addPageNumbers” was added. Ref This method adds the page numbers to each page of the PDF.
You can see the detail information here https://github.com/tanaikech/PDFApp
Gists

Description
This is a simple sample script for adding the page numbers to PDF data using Google Apps Script.
When you use this script, please copy and paste the following script to the script editor of Google Apps Script. And, please set the file ID of the PDF file.
Sample script
In this script, pdf-lib is used.
/**
* ### Description
* Add page numbers to PDF.
*
* @param {Object} blob PDF blob.
* @param {Object} pageFormat Format of page number.
* @returns {Blob} Updated PDF blob.
*/
async function addPageNumbers_(blob, pageFormat) {
if (blob.getContentType() != MimeType.PDF) {
throw new Error("Blob is not PDF.");
}
// Load pdf-lib
const cdnjs = "https://cdn.jsdelivr.net/npm/pdf-lib/dist/pdf-lib.min.js";
eval(
UrlFetchApp.fetch(cdnjs)
.getContentText()
.replace(
/setTimeout\(.*?,.*?(\d*?)\)/g,
"Utilities.sleep($1);return t();"
)
);
const data = new Uint8Array(blob.getBytes());
const pdfData = await PDFLib.PDFDocument.load(data);
const pdfDoc = await PDFLib.PDFDocument.create();
(await pdfDoc.copyPages(pdfData, pdfData.getPageIndices())).forEach(
(page, i) => {
const { width } = page.getSize();
const obj = { center: width / 2, left: 20, right: width - 20 };
const pageFormatObj = { ...pageFormat };
pageFormatObj.x = obj[pageFormat.x];
page.drawText(`${i + 1}`, pageFormatObj);
pdfDoc.addPage(page);
}
);
const bytes = await pdfDoc.save();
return Utilities.newBlob(
[...new Int8Array(bytes)],
MimeType.PDF,
`new_${blob.getName()}`
);
}
// Please run this function.
function sample1() {
const fileId = "###"; // Please set the file ID of the PDF file.
const pdfBlob = DriveApp.getFileById(fileId).getBlob(); // Of course, you can directly give the PDF blob.
const pageFormat = { size: 10, x: "center", y: 10 };
addPageNumbers_(pdfBlob, pageFormat).then((newBlob) =>
DriveApp.createFile(newBlob)
);
}
// This function is a simple demonstration script.
function sample2() {
// Create a sample Google Document.
const tempDoc = DocumentApp.create("tempDoc");
const body = tempDoc.getBody();
for (let p = 0; p < 5; p++) {
body.appendParagraph(`sample text ${p + 1}`).appendPageBreak();
}
tempDoc.saveAndClose();
const pdfBlob = tempDoc.getBlob();
// Add page numbers.
const pageFormat = { size: 10, x: "center", y: 10 };
addPageNumbers_(pdfBlob, pageFormat).then((newBlob) =>
DriveApp.createFile(newBlob)
);
}
- When you run the function
sample1, the page numbers are added to the center of each page.
- When you run the function
sample2, a new Google Document is created including 5 pages. And, the page numbers are added to the center of each page.
- In this sample, a simple format like
{ size: 10, x: "center", y: 10 } is used for the page numbers. Here, the page numbers are put to only “left”, “center”, and “right” of the bottom of the page. But, there are various parameters in DrawTextOptions. Ref So, when you want to customize more, please modify the script.
Gists

Abstract
This report examines leveraging Gemini 1.5 API with Google Apps Script to automate sample input creation during script reverse engineering. Traditionally, this process is manual and time-consuming, especially for functions with numerous test cases. Gemini 1.5 API’s potential to streamline development by automating input generation is explored through applying reverse engineering techniques to Google Apps Script samples.
Introduction
With the release of Gemini 1.5 API, users gained the ability to process more complex data, opening doors for various application developments. This report explores the potential of using Gemini 1.5 API in conjunction with Google Apps Script to achieve reverse engineering for script development and improvement.
Gists
Overview
These are sample scripts in Python and Node.js for controlling the output format of the Gemini API using JSON schemas.
Description
In a previous report, “Taming the Wild Output: Effective Control of Gemini API Response Formats with response_mime_type,” I presented sample scripts created with Google Apps Script. Ref Following its publication, I received requests for sample scripts using Python and Node.js. This report addresses those requests by providing sample scripts in both languages.