0

I have an existing PDF template, and I want to add some text over the top of it in a specific location on a specific page. For example, an invoice template or a scanned document.

How would I go about this? I'm using Sheets if that narrows my options.

There is a lot of documentation on how to create PDFs from documents, but nothing that will take a particular PDF and put text over it.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Nigel Johnson
  • 522
  • 1
  • 5
  • 21
  • Possible duplicate of [How to replace text within a pdf file?](https://stackoverflow.com/questions/13332817/how-to-replace-text-within-a-pdf-file) – Kos Dec 28 '17 at 22:43
  • I don't want to replace any text, I want to add a text box so far from a margin, that requires manipulation of the PDF structure, not the binary form. – Nigel Johnson Dec 28 '17 at 23:17
  • If you can see accepted answer on that question, it says it's not possible to change pdf programmatically via Apps Script – Kos Dec 29 '17 at 07:04
  • PDF files can be overwritten with advanced drive service. Technically, I don't think you can replace anything in a PDF file. – Alan Wells Dec 29 '17 at 17:13

2 Answers2

0

A bit of blue sky thinking from my side. What if you were to do the following?

Manually:

  • Export the PDF as an image
  • Resize a Google slide to be the same shape as the image
  • Add the image to the google slide as a background image

In Code:

  • Make a copy of the google slide as needed
  • Add your Google sheets data to the slide positioned as needed on the slide
  • Export the Google slide as a pdf

I mention google slides, because Google docs to not have allow background images.

Another possibility with using Google docs is to build a document that looks like your invoice, then add to it tags. In your code search for the tags and replace them with data from your sheet. Even you could use a mail merge addon to do this if you didn't fancy writing any code.

Jason Allshorn
  • 1,625
  • 1
  • 18
  • 27
0

In your Google Drive right-click on your PDF;

Open With > Connect More Apps > Search docusign > Left-click blue connect button and this should take you to Docusign.

Your PDF will then open with Docusign where you can manually add a signature or text to specific places.

Alternatively... You can use App Script.

Example, Constructing a document using HTML and replacing the specific value with a variable which is collect from a Sheet or particular location. Writing the function to do this will allow you to interpret the HTML and replace the variable with the text or possibly an image. Then it would create this as a PDF.

There are many alternative ways to do this.

Here is one example on github; Convert Google Doc to PDF using App Script

Haytch
  • 977
  • 7
  • 6