icon

Table of Contents

How to Create a PDF with Zapier and Google Spreadsheet(Using JSON payload)

With CraftMyPDF’s Zapier integration, it’s easy to create PDF templates with a drag-and-drop designer and automate your PDF generation from reusable templates.

There are 2 types of payload for Zapier integration, you can either use a Dictionary(flat-structured JSON, key-value pairs) or JSON data. The JSON payload is for complex hierarchical data.

This tutorial will walk you through the steps of generating a PDF document with Zapier, CraftMyPDF, and Google spreadsheet(Using JSON payload).

Step 1. Google Spreadsheet

Prepare your data and save the data on a Google spreadsheet. The data will be used for generating a PDF invoice.

Step 2. Create a CraftMyPDF PDF template

Create a PDF template on CraftMyPDF

The JSON data

Step 3. Zapier workflow

3.1. Create a Zap and setup a trigger

First, set up your trigger. For demo purposes, we will use the Zapier Chrome extension, you may use any event that starts your Zap.

3.2. Get data from Google Spreadsheet

3.2.1 Set up app & event

(i) Search for Google Sheets on Zapier and select Google Sheets

(ii) Select Get Many Spreadsheet Rows(Advanced, With Line Item Support) for Action Event and click Continue

3.2.2 Choose account

Connect your Google Sheets account to Zapier and click Continue

3.2.3 Set up the action

Now is to configure how you want to get the rows in the Google spreadsheet.

Select your Google drive and fill in all the required fields. In the Google spreadsheet, we enter the value 2 for the First Row, if you don’t have a header just set the value to 1. The max number of rows that can be retrieved is 20.

3.2.4 Test action

Now is the time to run and test the action. We will use raw_rows in the next action.

3.3. Building JSON string

We are going to use Code by Zapier to build the JSON string

3.3.1 Choose app & event

(i) First, search for Code by Zapier, select the option.

(ii) Then, select Run Javascript for the Action Event and press Continue

3.3.2 Set up action

In the Input Data section, provide the keys and values:

google_rows: bind the value to Raw Rows(Click on Get Many Spreadsheet Rows… and Show all options)

invoice_no: Invoice number or a value that you want to display in the PDF.

The following is the Javascript code that generate the JSON string.

let rows = JSON.parse(inputData.google_rows);

// Filter out rows that first cilumn is empty
rows = rows.filter((obj)=>obj[0].length>0); 

// Create items
rows = rows.map((obj)=>{
  return {
    description: obj[0],
    quantity: obj[1],
    unit_price: obj[2],
    total: obj[3]
  }
});

// Serialize the object and return the JSON string
output = [{
  output_json: JSON.stringify({
    invoice_no: inputData.invoice_no,
    items: rows
 })}];

3.3.3 Test the action

Run and test the action, the action will produce a JSON string that can be used for CraftMyPDF.

3.4. Generate PDF with CraftMyPDF

3.4.1 Choose app & event

(i) First, search for CraftMyPDF, select the option.

(ii) Then, select Create PDF for the Action Event and press Continue

3.4.2 Choose account

Connect your CraftMyPDF account to Zapier and click Continue (To get the API Key, visit CraftMyPDF’s API Integration page)

3.4.3 Set up action

Select your PDF template and select JSON for the Payload Type.

In the JSON Payload field, select Output Json

3.4.4 Test the action

Run and test the action, 

Recent Posts
blog

A Guide to Generate Barcodes and QRcodes

In this article, we’ll explore barcodes and QR codes, discussing their applications and how they’re used in various scenarios. I’ll guide you through the steps to create these codes using Python and Node.js. Additionally, we’ll look at how to generate barcodes and QR codes with CraftMyPDF, which supports REST API and integrates seamlessly with no-code platforms like Zapier, Make.com, and Bubble.

Read More »
blog

How to generate PDF documents with PHP

There are various libraries available to generate PDF documents with PHP such as FPDF, TCPDF, or DOMPDF. These libraries provide a wide range of features for creating PDF documents, such as setting page size, margins, fonts, and images.

In this article, I would briefly discuss some of these libraries along with some code snippets and show you how to generate a PDF document using PHP and CraftMyPDF.

Read More »
blog

5 Ways to generate PDFs with C#

In this article, we will cover different options available, including using libraries such as iTextSharp and PdfSharp, cloud-based APIs such as CraftMyPDF, built-in classes in the .NET Framework like the PrintDocument class, and the Microsoft Office Interop library.

Read More »
blog

How to Generate PDF Invoices with Zapier

With PDF invoices, it’s easier to send invoices directly to clients without needing paper copies.

In this article, I would be showing you how to generate PDF invoices with Zapier and also help you understand the benefits of doing this. Let’s get to it!

Read More »
blog

Best-performing Banner Ads Sizes in 2023

Choosing the most appropriate banner for your company isn’t always easy. There are lots of things to consider such as the color, size, type of banner, and so on. This could be a little problematic if you have no knowledge of the different types of banner ads but don’t worry, that’s why I’m here.

Read More »
Copyright ©2024 CraftMyPDF.com

Email us at [email protected] for support