# Using arrays in the pdfmonkey integration

**URL:** <https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371>\
**Category:** Ask for Help\
**Tags:** actions\
**Created:** [April 10, 2023, 7:33pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371 "2023-04-10T19:33:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 10, 2023, 7:33pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/1 "2023-04-10T19:33:22Z")

</div>

Need help with sending an array of items to pdfmonkey using the integration. How should the data be presented. It seems to only accept a joined list but when I run it the data does not get entered into the pdf. Onlythe integers and text do and not the arrays.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 11, 2023, 12:27am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/2 "2023-04-11T00:27:39Z")

</div>

At the moment I don’t think the PDF integration allows arrays. I believe they plan to introduce a “line items” thing at some point, since that is one of the best features in PDFMonkey in my opinion.

> **[Iteration (dealing with lists)](https://docs.pdfmonkey.io/references/liquid/loops)**

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 11, 2023, 12:28am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/3 "2023-04-11T00:28:37Z")

</div>

For the moment, I think the best thing you can do is to create the HTML part in advance in Glide, then pass that as a variable to your PDFMonkey generation flow.

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 11, 2023, 1:11pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/4 "2023-04-11T13:11:32Z")

</div>

You would regenerate the entire HTML using a Template column? Or can I just recreate the Table portion of the HTML?  
Also not sure ho to turn 2 array columns (Timecard Date and Timecard Pay) into the correct fields.  
Ideas?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 12, 2023, 12:00am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/5 "2023-04-12T00:00:51Z")

</div>

> [@GrumpyRick](#):
>
> Or can I just recreate the Table portion of the HTML?

This part. How do you plan to show it in your PDF?

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 12, 2023, 4:49pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/6 "2023-04-12T16:49:11Z")

</div>

as a table. Here is the HTML currently…

```auto
<!DOCTYPE html>
<html>
<head>
	<title>Job PDF Template</title>
	<style>
		body {
			font-family: Arial, sans-serif;
			font-size: 12px;
		}

		h1 {
			font-size: 24px;
			margin-bottom: 10px;
		}

		table {
			border-collapse: collapse;
			width: 100%;
			margin-bottom: 20px;
		}

		th, td {
			border: 1px solid black;
			padding: 5px;
			text-align: center;
		}

		.total {
			font-weight: bold;
			text-align: left;
			margin-top: 20px;
		}
	</style>
</head>
<body>
	<h1>Job Name: {{jobName}}</h1>
	<p><strong>Job Description:</strong> {{jobDescription}}</p>
	<p><strong>Date:</strong> {{jobDate}}</p>

	<table>
			<tr>
				<th>Timecard Date</th>
				<th>Timecard Pay</th>
			</tr>
		
			<!-- Loop through the timecard arrays and create a row for each item -->
			{% for item in lineItems %}
				<tr>
				  <td>{{item.timecardDate}}</td>
				  <td>{{item.timecardPay}}</td>
				</tr>
		{% endfor %}
	</table>

	<p class="total">Total Pay: {{allTotal}}</p>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 13, 2023, 12:41am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/7 "2023-04-13T00:41:04Z")

</div>

I believe this is the only part you need a loop?

```auto
{% for item in lineItems %}
				<tr>
				  <td>{{item.timecardDate}}</td>
				  <td>{{item.timecardPay}}</td>
				</tr>
		{% endfor %}

```

In Glide, you can have a relation of “timecards”, on the “timecards” table, create a template for each row like this:

```auto
<tr>
<td>{{item.timecardDate}}</td>
<td>{{item.timecardPay}}</td>
</tr>

```

And replace the timecardDate and timecardPay accordingly.

Back to the job table where I assume you would have the timecard relation, create a joined list column to join all the templates over the timecard relation, separate by a newline character.

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 13, 2023, 2:42am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/8 "2023-04-13T02:42:35Z")

</div>

That worked…Thank you.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 13, 2023, 11:51pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/9 "2023-04-13T23:51:55Z")

</div>

Great to hear it worked!

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 14, 2023, 7:26pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/10 "2023-04-14T19:26:48Z")

</div>

Have a new issue with a new template. Here is the HTML. Not sure where to put the line items for this.

 {% for job\_index in (0..jobs.size) %} {% assign job = jobs[job\_index] %} {% assign names\_for\_job = names[job\_index] %} {% assign hours\_for\_job = hours[job\_index] %} 

## {{ job }}
 {% for names\_index in (0..names\_for\_job.size) %} {% endfor %} 

| Timecard Name | Timecard Hours |
| --- | --- |
| {{ names\_for\_job[names\_index] }} | {{ hours\_for\_job[names\_index] }} |
| Total | {{ totals[job\_index] }} |

 {% endfor %}

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 14, 2023, 11:16pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/11 "2023-04-14T23:16:26Z")

</div>

Can you show me some samples of how you want it to look like?

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 15, 2023, 10:41am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/12 "2023-04-15T10:41:00Z")

</div>

Thank you. Here is the test data I used.  
{  
“jobs”: [“Job A”, “Job B”, “Job C”],  
“names”: [[“Joe S”, “Jane B”, “Mike S”],  
[“Joe S”, “Jane B”, “Mike S”, “Sue B”],  
[“Joe S”, “Jane B”, “Mike S”]  
],  
“hours”: [[10.50, 8.25, 12.00],  
[9.00, 11.75, 8.50, 10.25],  
[7.75, 6.50, 9.00]  
],  
“totals”: [[30.75],  
[39],  
[23.25]  
]  
}

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 15, 2023, 11:52pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/13 "2023-04-15T23:52:58Z")

</div>

So would the result for an “item” look like:

Job A  
Joe S, Jane B, Mike S

| Timecard Name | Timecard Hours |
| --- | --- |
| Joe S | 10.50 |
| Jane B | 8.25 |
| Mike S | 12.00 |
| Total | 30.75 |

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 17, 2023, 3:48am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/14 "2023-04-17T03:48:37Z")

</div>

No need for the names below the Job. Just the list items. Thanks.

Job A

| Timecard Name | Timecard Hours |
| --- | --- |
| Joe S | 10.50 |
| Jane B | 8.25 |
| Mike S | 12.00 |
| Total | 30.75 |

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 19, 2023, 9:55pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/15 "2023-04-19T21:55:09Z")

</div>

Just making sure you got my last reply.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 20, 2023, 12:56am UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/16 "2023-04-20T00:56:09Z")

</div>

Sorry I haven’t had much time to work on this. What I think you can do is have a joined list for the individual timecards, then create a rollup for the total, make a template for the “total” line, and combine them all together with another template column (joined list first, then total last).

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 20, 2023, 6:11pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/17 "2023-04-20T18:11:38Z")

</div>

no problem…Thanks!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 20, 2023, 11:49pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/18 "2023-04-20T23:49:06Z")

</div>

Can you try the method above and let me know if it works? Basically my idea is to separate the single items, which you already have as rows, and then use a rollup + template column to construct the “total” row.

---

<div class="post-metadata">

**Author:** ![GrumpyRick](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/grumpyrick/32/18079_2.png) [@GrumpyRick](https://community.glideapps.com/u/GrumpyRick)\
**Post date:** [April 21, 2023, 8:38pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/19 "2023-04-21T20:38:31Z")

</div>

My issue is where in the pdf code to put the Glide templates.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 21, 2023, 11:27pm UTC](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371/20 "2023-04-21T23:27:15Z")

</div>

Wouldn’t you have to combine the templates of each “job” together first before putting it wherever you like in PDFMonkey?

[Next page](https://community.glideapps.com/t/using-arrays-in-the-pdfmonkey-integration/60371.md?page=2)
