How to Add Text to PDF using Google Apps Script and PDF.co

Are you looking for an efficient way to add text to your PDF documents? With the help of Google Apps Script and PDF.co integration, you can automate the process of adding text (or any other content) to your PDFs.

In this tutorial, we will show you how to use these powerful tools to edit your PDFs step-by-step. We’ll start by showing you how to set up Google Apps Script and PDF.co, and then we’ll walk you through the process of adding text to your PDFs using code.

Whether you’re a business owner looking to streamline your document workflow or an individual looking to make quick edits to your PDFs, this tutorial will provide you with the information you need to get started. So let’s begin!

In this guide, we will show you how to Add text to PDF using Google Apps Script and PDF.co using 6 steps.

We will use this sample PDF in this tutorial. You may use a PDF of your choice.

Sample PDF Document

Google Sheets App

  • To begin. First, open the Google Sheets app.

Add API Key, Sample PDF, Input Text, and Result Path

  • Next, add the PDF.co API Key, you can get the API Key in your PDF.co dashboard.
  • Then, input the sample PDF URL and the Text you want to add to the PDF.
  • Enter a path where the output link will be added.
  • Finally, click on the Extensions button and select the App Script.
Add API Key, Sample PDF, Input Text, and Result

Google App Script Code

Now, let’s add the code and set up the Google App Script

  • First, add the Google App Script code. You can get the code at this link.
  • In line 20, add the cell where the PDF.co API Key is located.
  • For lines 23 and 25, add the cell where the sample PDF URL, Input text, and Result are located.
  • For line 38, add the coordinates, font style, font name, font size, and font color of the text. You can easily collect the x and y coordinates of the PDF document using the PDF Viewer tools.
Google App Script Code

Run App Script

  • Once you’re done, you may now run the code.
Run App Script

Finish App Script

  • Once the execution is completed, go back to Google Sheets and click PDF.co. Then click Create PDF. You will then be given a temporary link where you can view and download the output PDF.
Finish App Script

Output

  • Here’s what the output PDF looks like.
Add Text to PDF Output

In this tutorial, you learned how to add text to PDF using PDF.co and Google App Script. You also learned how to get specific coordinates of the document using the PDF Viewer tools.

Summing up, adding text to a PDF using Google Apps Script and PDF.co is a straightforward process.

  • First, enable add PDF.co API key in your Google Sheets app.
  • Next, use the provided code examples and set up the function that will add text to the PDF.
  • Once you have set up the function and added the appropriate parameters (such as coordinates, font style, font name, font size, and font color), you may add the desired text to the PDF.
  • Run the script and get your link to download the result.

This approach allows you to automate the process of adding text to PDFs and makes it easy to update multiple documents simultaneously.

Google Apps Script is a scripting platform that allows users to automate tasks and create custom functionality for a variety of Google products and services. It is a JavaScript-based programming language that can be used to create scripts that interact with Google Sheets, Docs, Forms, Gmail, and other Google products.

This script can be used to automate repetitive tasks, create custom formulas and validations in Google Sheets, send automated email responses, and more. Google Apps Script can also be used to create web apps and web-based forms that can be used within and outside of an organization.

Additionally, Google Apps Script can be connected to other services using Google’s built-in connectors and the Google Script Services to read or write data to other APIs, and also can be used to create Add-ons for Google Suite products like Sheets, Docs, and Forms. This makes it a powerful tool for organizations and individuals looking to streamline and automate their workflows.

Video Guide

Related Tutorials

See Related Tutorials