# PDF Export - Currency and number formatting

**URL:** <https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800>\
**Category:** Get Help\
**Created:** [February 4, 2024, 8:50pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800 "2024-02-04T20:50:25Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![roblineker](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/roblineker/32/8757_2.png) [@roblineker](https://community.fibery.io/u/roblineker)\
**Post date:** [February 4, 2024, 8:50pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/1 "2024-02-04T20:50:25Z")

</div>

Hi team!

Has anyone been able to export a pdf with a number field using a currency format or been able to add any formatting to a number to include thousands separator?

Eg: 4,560.99

I can’t get this to work and speaking with the Fibery team they can’t either… so hoping the brains trust can help!

Context: I am planning to use fibery to issue invoices. Ironically, the template that is provided appears to work because the values are less than $1,000.

Thanks

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 5, 2024, 11:12am UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/2 "2024-02-05T11:12:48Z")

</div>

Try this:

```auto
{!Amount!}
<%= parseFloat(Entity.Amount).toLocaleString('en',{style:'currency',currency:'USD'}) %>

```

(assuming the field name is `Amount` and that you want it to be shown as dollars)

---

<div class="post-metadata">

**Author:** ![cssrctech](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/cssrctech/32/5154_2.png) [@cssrctech](https://community.fibery.io/u/cssrctech)\
**Post date:** [February 5, 2024, 4:10pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/3 "2024-02-05T16:10:23Z")

</div>

Dang Chris, I should have waited a week to do this, would have saved me a lot of time with your response. 😄

---

<div class="post-metadata">

**Author:** ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)\
**Post date:** [February 7, 2024, 9:57am UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/4 "2024-02-07T09:57:19Z")

</div>

> [@Chr1sG](#):
>
> Try this:
> 
> ```auto
> {!Amount!}
> <%= parseFloat(Entity.Amount).toLocaleString('en',{style:'currency',currency:'USD'}) %>
> 
> ```
> 
> (assuming the field name is `Amount` and that you want it to be shown as dollars)

That’s awesome! In Fibery formulas where I use ToText(number) I also don’t get a thousand separator. Therefor the text show as 122987. Is there also a hack for that?

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 7, 2024, 11:12am UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/5 "2024-02-07T11:12:10Z")

</div>

> [@YvetteLans](#):
>
> In Fibery formulas where I use ToText(number) I also don’t get a thousand separator. Therefor the text show as 122987. Is there also a hack for that?

Try this:

```auto
ReplaceRegex(ToText(Num), "(?<![.$])[0-9](?=(?:[0-9]{3})+(?![0-9]))", "\&,")

```

---

<div class="post-metadata">

**Author:** ![roblineker](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/roblineker/32/8757_2.png) [@roblineker](https://community.fibery.io/u/roblineker)\
**Post date:** [February 7, 2024, 11:49am UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/6 "2024-02-07T11:49:20Z")

</div>

Hi Chris, the code you just posted drops off the 2nd decimal anything we can do for that?

![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/f/f67bca4e07fb868aa369db0ad8ad43bf07bb4ef7.png)

Also I had trouble implementing the solution you posted for the html I will try again in the morning when less tired 😃

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 7, 2024, 12:13pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/7 "2024-02-07T12:13:43Z")

</div>

> [@roblineker](#):
>
> Hi Chris, the code you just posted drops off the 2nd decimal anything we can do for that?
> 
> ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/f/f67bca4e07fb868aa369db0ad8ad43bf07bb4ef7.png)

Can you post what your automation looks like and how the relevant db fields are configured.  
The code I posted works fine for me with a currency field as follows:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/6/61af766cd855f0c1749f58b05f81ad3a5498cd25.png)

---

<div class="post-metadata">

**Author:** ![YvetteLans](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/yvettelans/32/6101_2.png) [@YvetteLans](https://community.fibery.io/u/YvetteLans)\
**Post date:** [February 7, 2024, 1:07pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/8 "2024-02-07T13:07:06Z")

</div>

> [@Chr1sG](#):
>
> Try this:
> 
> ```auto
> ReplaceRegex(ToText(Num), "(?<![.$])[0-9](?=(?:[0-9]{3})+(?![0-9]))", "\&,")
> 
> ```

This works! Awesome 🤩

---

<div class="post-metadata">

**Author:** ![cssrctech](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/cssrctech/32/5154_2.png) [@cssrctech](https://community.fibery.io/u/cssrctech)\
**Post date:** [February 7, 2024, 4:01pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/9 "2024-02-07T16:01:19Z")

</div>

I’m not sure if this is helpful but here is my customization on the invoice template provided by Fibery. Chris will have to attest to whether this aspect of the currency formatting is an acceptable solution:

```auto
$<%= parseFloat(details['Amount']).toFixed(2) %>

```

```auto
<!DOCTYPE html>
{! Invoice Details:Service Date, Service, Hours, Amount !}

<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title></title>
  <!-- Invoice styling -->
<style>
        .invoice-box {
            max-width: 800px;
            margin: auto;
            padding: 30px;
            font-size: 16px;
            line-height: 24px;
            color: #555;
        }

        .invoice-box table {
            width: 100%;
            line-height: inherit;
            text-align: left;
            border-collapse: collapse;
        }

        .invoice-box table td {
            padding: 5px;
            vertical-align: top;
        }

        .invoice-box table tr td:nth-child(1) {
            text-align: left;
        }
        .invoice-box table tr td:nth-child(2) {
            text-align: left;
        }

        .invoice-box table tr td:nth-child(3) {
            text-align: right;
        }

        .invoice-box table tr td:nth-child(4) {
            text-align: right;
        }
        .invoice-box table tr.top table td {
            padding-bottom: 20px;
        }

        .invoice-box table tr.top table td.title {
            font-size: 45px;
            line-height: 45px;
            color: #364357;
        }

        .note {
            font-size: 16px;
            color: #364357;
        }

      .rendered {
            font-size: 18px;
            color: #364357;
        }

        .invoice-box table tr.information table td {
            padding-bottom: 20px;
        }

        .invoice-box table tr.heading td {
            background: #eee;
            border-bottom: 1px solid #ddd;
            font-weight: bold;
        }

        .invoice-box table tr.details td {
            padding-bottom: 30px;
        }

        .invoice-box table tr.item td {
            border-bottom: 2px solid #eee;
        }

        .invoice-box table tr.item.last td {
            border-bottom: none;
        }

        .invoice-box table tr.subtotal td {
            padding-top: 20px;
            font-weight: normal;
            font-size: large;
            text-align: right;
        }      
       
        .invoice-box table tr.tax td{
            padding-top: 5px;
            font-weight: normal;
            font-size: large;
            text-align: right;
        }
       
        .invoice-box table tr.total td{
            padding-top: 5px;
            padding-bottom: 20px;
            font-weight: bold;
            color: #364357;
            font-size: larger;
            text-align: right;
        }

        @media only screen and (max-width: 600px) {
            .invoice-box table tr.top table td {
                width: 100%;
                display: block;
                text-align: center;
            }

            .invoice-box table tr.information table td {
                width: 100%;
                display: block;
                text-align: center;
            }
        }
    </style>
</head>

<body>
  <div class="invoice-box">
    <table>
      <tr class="top">
        <td colspan="4">
          <table>
            <tr>
              <td class="title">
                Invoice
              </td>
              <td />
              <td />
              <td>
                <div class="note">
                  Invoice #: <b>{{Invoice Number}}</b><br />
                  Date: <b>{{Invoice Date}}</b><br />
                  Due: <b>{{Due Date}}</b>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr class="information">
        <td colspan="4">
          <table>
            <tr>
              <td>
                Jim John<br />
                ###-###-####<br />
                test@test.com
              </td>
              <td />
              <td />
              <td>
               123 Jolly Lane
                <br />
                Somewhere, AA 88888
              </td>
            </tr>
          </table>
        </td>
      </tr>

      <tr>
        <td colspan="4">
          <table>
            <tr class="heading">
              <td colspan="4">Bill to</td>
            </tr>
            <tr class="details">
              <td class="note">
                <b>{{Customer.Name}}</b><br />
                 Attn: {{Customer.Billing Contact}}<br />
                 {{Customer.Billing Email}}
              </td>
              <td></td>
              <td></td>
              <td>
                {{Customer.Billing Address}}
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="4">
          <table>
            <tr class="heading">
              <td>Date</td>
              <td>Services</td>
              <td>Hours</td>
              <td>Amount</td>
            </tr>
            <% for(let details of Entity['Invoice Details']) {%>
            <tr class="item">
              <td><%= details['Service Date'] %></td>
              <td><%= details['Service'] %></td>
              <td><%= details['Hours'] %></td>
              <td>$<%= parseFloat(details['Amount']).toFixed(2) %></td>
            </tr>
      <%}%>
          </table>
        </td>
      </tr>

<%
    const fibery = context.getService('fibery');
    const entityDeets = await fibery.getEntityById(Entity.Type, Entity.Id, ['Invoice Subtotal', 'Invoice Tax', 'Invoice Total']);

    
let subtotal = entityDeets['Invoice Subtotal'];
let tax = entityDeets['Invoice Tax'];
let total = entityDeets['Invoice Total'];

let subtotalr = parseFloat(subtotal).toFixed(2);
let taxr = parseFloat(tax).toFixed(2);
let totalr = parseFloat(total).toFixed(2);

%>

        <tr class="subtotal">
        <td> Subtotal: $<%= subtotalr %></td>
        </tr>

	<tr class="tax">
       <td> Tax: $<%= taxr %></td>
        </tr>

	<tr class="total">
        <td>Total: $<%= totalr %></td>
        </tr>
		
        <tr>
	<td class="rendered"><b>Services Rendered</b></td>
	</tr>
	
	<tr>
	<td>{{Description}}</td>
	</tr>
    </table>
</div>
</body>
</html>

```

Comes out looking something like this.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/5/5f8e3140561aedece0c72609f4ca0cd92446367c.png)

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [February 7, 2024, 4:07pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/10 "2024-02-07T16:07:39Z")

</div>

Nice work @cssrctech !

---

<div class="post-metadata">

**Author:** ![ccollins](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@ccollins](https://community.fibery.io/u/ccollins)\
**Post date:** [July 11, 2024, 6:15pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/11 "2024-07-11T18:15:05Z")

</div>

> [@Chr1sG](#):
>
> Try this:
> 
> ```auto
> {!Amount!}
> <%= parseFloat(Entity.Amount).toLocaleString('en',{style:'currency',currency:'USD'}) %>
> 
> ```
> 
> (assuming the field name is `Amount` and that you want it to be shown as dollars)

Is there a trick for this when your field name is multiple words? For example ‘Total Amount’. I’ve tried various options, but it keeps getting rejected.

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [July 11, 2024, 8:03pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/12 "2024-07-11T20:03:07Z")

</div>

Try replacing `Entity.Amount` with `Entity['Total Amount']`

---

<div class="post-metadata">

**Author:** ![ccollins](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@ccollins](https://community.fibery.io/u/ccollins)\
**Post date:** [July 11, 2024, 8:54pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/13 "2024-07-11T20:54:59Z")

</div>

Perfect! Thank you Chris!

---

<div class="post-metadata">

**Author:** ![helloitse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/helloitse/32/498_2.png) [@helloitse](https://community.fibery.io/u/helloitse)\
**Post date:** [August 26, 2024, 4:32pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/14 "2024-08-26T16:32:07Z")

</div>

I was looking into this last week. When aggregating data from a relation within a formula, there is no way to set the number of decimals. So the second decimal gets truncated, but only when both decimals would be 0. See example:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/d/d7285b7e4e8dd7386b74074f15cf7a4e2dca2a3d.png)

In the absence of number formatting formulas, you can either set up a field and calculate the currency and then another field to output the text OR adopt a different formula to output a number with thousands delimiters. I needed commas for 5 digit numbers with two decimal places. So far this is working, but .00 still returns as .0:

```auto
Left(
    ToText(Num),
    Length(ToText(Num)) -
      Find(ToText(Num), ".")
  ) +
  "," +
  Right(ToText(Num), Find(ToText(Num), "."))

```

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [August 26, 2024, 4:34pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/15 "2024-08-26T16:34:36Z")

</div>

You can append ‘0’ to the end of the string and then use LEFT() to truncate based on the position of the decimal point + 2 characters.

---

<div class="post-metadata">

**Author:** ![helloitse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/helloitse/32/498_2.png) [@helloitse](https://community.fibery.io/u/helloitse)\
**Post date:** [December 24, 2024, 2:48am UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/16 "2024-12-24T02:48:44Z")

</div>

I cannot seem to use parseFloat with fields on the original entity. It works fine in a relationship table.  
Even when inserting

```auto
{! Items:Name,Cost,Qty,Discount !}
{!Subtotal!}

```

at the top of the pdf.  
I get a Unexpected token, expected “,” error.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/d/d4f5cf30901ca560c64d0552d236519987fd2dd6.png)

---

<div class="post-metadata">

**Author:** ![Eva\_Folch](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/eva_folch/32/11814_2.png) [@Eva\_Folch](https://community.fibery.io/u/Eva_Folch)\
**Post date:** [August 8, 2025, 11:15am UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/17 "2025-08-08T11:15:20Z")

</div>

I have the same problem! Helloitse, could you let me know if you found a solution? I need the total ( which is a formula) To be to decimals. 🙏

---

<div class="post-metadata">

**Author:** ![Eva\_Folch](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/eva_folch/32/11814_2.png) [@Eva\_Folch](https://community.fibery.io/u/Eva_Folch)\
**Post date:** [August 8, 2025, 1:23pm UTC](https://community.fibery.io/t/pdf-export-currency-and-number-formatting/5800/18 "2025-08-08T13:23:38Z")

</div>

after some chatgpt back and forth I got this to work:

  
 \<% let totalSum = 0; if (Entity['Line Items']) { for (const item of Entity['Line Items']) { const itemTotal = parseFloat(item["Item Total"]) || 0; totalSum += itemTotal; %\> \<% } } %\> 

```auto
				<!-- Total -->
				<tr class="total">
					<td></td>
					<td colspan="3" style="text-align: right;">
						Total: 
						<%= totalSum.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) %>
						{{Currency.name}}
					</td>
				</tr>
			</table>

```

In case it can help someone else!

|
| |
| Description | Price | Qty | Item Total |
| \<%= item.Description %\> | \<%= parseFloat(item.Price).toFixed(2) %\> {{Currency.name}} | \<%= item.Qty %\> | \<%= itemTotal.toFixed(2) %\> {{Currency.name}} |
