メインコンテンツにスキップ

PDFApp

This is a Google Apps Script library for managing PDFs.

AI Summary

PDFApp

A Google Apps Script library that wraps pdf-lib to perform various PDF operations—extraction, merging, form editing and more—through a promise-based API.

Target Users

Intermediate Google Apps Script developers automating Workspace workflows who need to edit or generate PDFs programmatically.

Problems Solved

Google Apps Script lacks built-in APIs for editing, merging or handling PDF forms, forcing developers to write complex code or rely on external services.

Tags

Main Features

1
Unified PDF manipulation toolkit

Offers extraction, merging, splitting, reordering, metadata read/write, page numbering and more in a single library.

2
Runs entirely inside GAS

Executes pdf-lib inside the V8 runtime, removing the need for external servers and integrating seamlessly with Drive.

3
Create and fill PDF forms

Supports generating forms from Google Slides templates and getting/setting values in existing PDF forms.

4
Image conversion & object embedding

Provides utilities to convert pages to PNG and embed texts/images at specified coordinates.

Usage Examples

Retrieve PDF metadata

/**
 * Retrieves metadata of a Drive PDF file and logs the result.
 */
function getPdfMetadata() {
  const pdfFileId = '___PDF_FILE_ID___'; // Drive file ID of the target PDF

  // Fetch the PDF as a blob from Drive
  const pdfBlob = DriveApp.getFileById(pdfFileId).getBlob();

  // Call PDFApp and output the metadata
  PDFApp.setPDFBlob(pdfBlob)
    .getMetadata()
    .then(meta => {
      Logger.log(JSON.stringify(meta, null, 2));
    })
    .catch(err => Logger.log(err));
}

Replace ___PDF_FILE_ID___ with an actual Drive file ID and run the function; title, author, page info and other metadata will be printed in the execution log.