Design and generate pixel-perfect PDF Documents and images in minutes with CraftMyPDF.
CraftMyPDF's advanced drag & drop editor lets you design PDF templates in any browser and generate pixel-perfect PDF documents from reusable templates and data with no-code platforms or REST API.
You can create various documents such as contracts, payslips, invoices, shipping labels, certificates, and more with just a click.
2. The steps to generate PDFs and upload them to Coda.
Step 1: Create the files: Country(Text), PDF File(Text)
Step 2: Create a Button. In the “Button Options”
(i) Choose the action: Action → Packs → CraftMyPDF → Create PDF
(ii) Copy and paste the Template ID from CraftMyPDF
(iii) JSON Payload: Use BuildData formula to build the JSON payload
(iv) Select PDF File for the Result Column
Step 3: Change the Column Type for PDF File columnto File(Images and Files). The generated PDFs are short-lived(The URL will be expired 5 minutes), this lets Coda to upload the PDF as an attachment for the field.
Table 2
Name
Country
Button
PDF File
Notes
Name
Country
Button
PDF File
Notes
1
Jacky
US
Generate PDF
Open
2
Jenny
UK
Generate PDF
Open
3
John
SG
Generate PDF
Open
There are no rows in this table
3. Advanced: How to send items or an array to CraftMyPDF
The formula BuildData only accepts string type key-value pairs. The workaround is to use a delimiter and concatenate all the items for an array into a string in your data, then split the string data in CraftMyPDF.
The following section will guide you through the process of creating a JSON string(for items) then generate a PDF with the click of a button.
Create a Button type column first and label it Generate and Download
The followings are the steps to build the action:
i. In the action field, use a Lookup formula to query data from another table.
ii. Next, concatenate all the items with a delimiter “|” using the Join formula.
iii. Then, use the BuildData formula to build a JSON, BuildData accepts key-value pairs, so named the fields accordingly and use Lookup in the values.
iv. Then assign the generated PDF URL to a field(”PDFURL”). Lastly, download the URL with OpenWindow action.
The following is the complete formula:
Step 2: Prepare the template on CraftMyPDF
i. Configure the sample data
First, prepare the JSON data and paste it into the "Data" tab.
The values in the array fields should be delimited with a "|" symbol.
For the next step, you can either use method 1 or 2. We recommend to use method 1
Method 1
Step 3. Convert the delimited strings into an array of objects
It's easier to work with an array of objects. There is a built-in function called 'fieldsToRows' that extracts values from the object for each field and splits them based on the delimiter. The function then returns an array of objects.
The following are the steps to use the built-in function 'fieldsToRows'.
i. Configure the repeating section
Then in the Designer tab, select a normal section and enable data-binding for the section.
In the Data Source field paste the following expression: