# PDF Templates

Use this page when you need a PDF and want to choose the right format fast.

A standard **PDF Template** is the most flexible PDF format in S-Docs.

Use it when you want to build the document layout in the template itself and generate a dynamic PDF from Salesforce data.

If you already have a finished PDF form, use [Upload Existing PDFs](/sdocs/template-architecture/document-formats/pdf-upload-format.md) instead.

{% hint style="info" %}
Pick **PDF Templates** when dynamic layout matters most.

Pick **Upload Existing PDFs** when exact field placement on a fixed form matters most.
{% endhint %}

### Tell me which one to pick

| Pick this format         | Use it when you need                     | Best for                                                                             | Not ideal when                                                              |
| ------------------------ | ---------------------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| **PDF Templates**        | Full layout control in the template body | Quotes, invoices, contracts, reports, multi-page packets                             | You already have a final PDF that only needs overlay fields                 |
| **Upload Existing PDFs** | Exact placement on top of a fixed PDF    | Government forms, pre-approved legal forms, static brochures, drag-and-drop overlays | You need related lists, flexible tables, headers, footers, or page settings |

#### Use PDF Templates if you need

* related lists and data tables
* conditional logic
* components
* headers and footers
* page settings and margin control
* multi-page output with reusable layout

#### Use Upload Existing PDFs if you need

* a fixed background document
* drag-and-drop field placement
* simple overlays on an existing PDF
* quick setup for non-technical builders

Keep in mind:

* Upload Existing PDFs are portrait-only.
* Related lists are not supported there.
* Traditional headers, footers, and page settings are not available there.

### Show me what it looks like

These examples show the same idea in three views:

* raw Salesforce data
* template structure
* generated PDF result

{% tabs %}
{% tab title="Quote / invoice" %}
**Best fit:** customer-facing quotes, invoices, and order summaries

**Raw data**

```
Quote.Name: ACME Renewal
Quote.Account.Name: Acme Corp
Quote.Owner.CompanyName: S-Docs, Inc.
Quote.TotalPrice: 25000

QuoteLineItems:
- Premier Support | Qty 2 | Unit 12500 | Total 25000
```

**Generated PDF**

```
PROJECT: ACME Renewal
CLIENT: Acme Corp
DATE: March 24, 2026

SERVICE            QTY    PRICE      TOTAL
Premier Support      2    $12,500    $25,000

GRAND TOTAL                        $25,000
```

**Template snippet**

{% code title="quote-template.html" %}

```html
<table border="0" cellpadding="2" cellspacing="0" style="width:100%;">
  <tr>
    <td>PROJECT: {{!Quote.Name}}</td>
    <td style="text-align:right">{{!Quote.Owner.CompanyName}}</td>
  </tr>
  <tr>
    <td>CLIENT: {{!Quote.Account.Name}}</td>
    <td style="text-align:right">DATE: {{!DocumentDateTime MMMMM d, yyyy}}</td>
  </tr>
</table>

<!--{{!
<lineitemsSOQL>
  <listname>quotelineitem</listname>
  <column>description</column>
  <column format-number="#,###">quantity</column>
  <column prefix="$" format-number="#,###.##">listprice</column>
  <column prefix="$" format-number="#,###.##">totalprice</column>
</lineitemsSOQL>
}}-->
```

{% endcode %}

For a fuller real example, see [Quote Template on the Quote Object](broken://spaces/WKNnJmhJBQwhdk5WBFsi/pages/2056868cec5aee11ab9a7d9590e6418e3733f21d).
{% endtab %}

{% tab title="Multi-page report" %}
**Best fit:** work orders, summaries, audit reports, and packet-style output

**Raw data**

```
Opportunity.Name: Q2 Expansion
Opportunity.Account.Name: Northern Trail
Opportunity.Amount: 4222300.8
Opportunity.CloseDate: 2026-03-24

OpportunityLineItems:
- Consulting
- Implementation
- Training
```

**Generated PDF**

```
Q2 Expansion Summary

Account: Northern Trail
Close Date: March 24, 2026
Amount: $4,222,300.80

Section 1: Executive summary
Section 2: Line items table
Section 3: Terms and conditions
```

**Template snippet**

{% code title="report-template.html" %}

```html
<h1>{{!Opportunity.Name}} Summary</h1>
<p>Account: {{!Opportunity.Account.Name}}</p>
<p>Close Date: {{!Opportunity.CloseDate format-date="MMMM dd, yyyy"}}</p>
<p>Amount: ${{!Opportunity.Amount format-number="#,###.##"}}</p>

<h2>Line Items</h2>
<!--{{!
<lineitemsSOQL>
  <listname>opportunitylineitems</listname>
  <column>PricebookEntry.Product2.Name</column>
  <column format-number="#,###">Quantity</column>
  <column prefix="$" format-number="#,###.##">UnitPrice</column>
  <column prefix="$" format-number="#,###.##">TotalPrice</column>
</lineitemsSOQL>
}}-->
```

{% endcode %}

This is the common pattern for document-style PDFs that need dynamic sections and tables.
{% endtab %}

{% tab title="Fixed form" %}
**Best fit:** exact overlays on an existing form

If your goal is:

* keep a pre-approved PDF exactly as designed
* drag fields onto a fixed background
* avoid rebuilding the layout in markup

then use [Upload Existing PDFs](/sdocs/template-architecture/document-formats/pdf-upload-format.md), not a standard PDF Template.

That format supports drag-and-drop fields on top of an uploaded PDF background.
{% endtab %}
{% endtabs %}

### Give me the raw materials

Use this starter when you want a clean PDF template with:

* a title block
* key record fields
* a line item table
* number and date formatting

{% code title="pdf-template-starter.html" %}

```html
<style type="text/css">
  body {
    font-family: Arial, sans-serif;
    font-size: 10pt;
    color: #222;
  }

  h1, h2 {
    margin-bottom: 8px;
  }

  table.layout {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
  }

  table.layout td,
  table.layout th {
    padding: 6px;
    border-bottom: 1px solid #d9d9d9;
    text-align: left;
  }

  .label {
    width: 28%;
    font-weight: bold;
  }
</style>

<h1>Document Title</h1>

<table class="layout">
  <tr>
    <td class="label">Record</td>
    <td>{{!Opportunity.Name}}</td>
  </tr>
  <tr>
    <td class="label">Account</td>
    <td>{{!Opportunity.Account.Name}}</td>
  </tr>
  <tr>
    <td class="label">Close Date</td>
    <td>{{!Opportunity.CloseDate format-date="MMMM dd, yyyy"}}</td>
  </tr>
  <tr>
    <td class="label">Amount</td>
    <td>${{!Opportunity.Amount format-number="#,###.##"}}</td>
  </tr>
</table>

<h2>Line Items</h2>

<table class="layout">
  <thead>
    <tr>
      <th>Product</th>
      <th>Qty</th>
      <th>Unit Price</th>
      <th>Total</th>
    </tr>
  </thead>
  <tbody>
<!--{{!
<lineitemsSOQL>
  <class>none</class>
  <listname>opportunitylineitems</listname>
  <column>PricebookEntry.Product2.Name</column>
  <column format-number="#,###">Quantity</column>
  <column prefix="$" format-number="#,###.##">UnitPrice</column>
  <column prefix="$" format-number="#,###.##">TotalPrice</column>
</lineitemsSOQL>
}}-->
  </tbody>
</table>
```

{% endcode %}

If you need an easier drag-and-drop starting point, use [Upload Existing PDFs](/sdocs/template-architecture/document-formats/pdf-upload-format.md).

### What are the rules?

#### Anatomy of a standard PDF Template

**Required to create the template record**

* template name
* `Related To Type`
* template format set to `PDF`

**Required for useful output**

* document body content

Without body content, the generated PDF will be blank.

**Common optional parts**

* merge fields
* related lists with `lineitems` or `lineitemsSOQL`
* conditional logic
* components
* headers and footers
* page settings
* CSS styling

#### Common data types

* **Text**: names, addresses, IDs, freeform content
* **Number and currency**: totals, quantities, prices, percentages
* **Date and datetime**: close dates, invoice dates, timestamps
* **Boolean**: checkbox-style output
* **Related data**: child records shown as tables or repeated sections

Use template attributes when values need display formatting.

For broader formatting help, see [Format Data with Template Attributes](/sdocs/advanced-template-logic/template-attributes.md).

#### Constraints and rendering rules

* PDF output uses Salesforce PDF rendering.
* JavaScript-rendered content is not supported.
* Modern web layouts are less reliable than table-based layout.
* Basic HTML and CSS patterns are safest for print-style output.
* Unicode and international text need extra testing.
* `Arial Unicode MS` is the documented multibyte font for extended character sets.

{% hint style="warning" %}
Rich text fields can introduce extra paragraph tags, font fallback, and formatting differences.

If your output depends on rich text, test with real sample data early.
{% endhint %}

#### Quick decision checklist

Choose **PDF Templates** when you answer **yes** to one or more of these:

* Do I need related lists or dynamic tables?
* Do I need headers, footers, or page settings?
* Do I need conditional sections or reusable components?
* Am I building a document, not filling a fixed form?

Choose [Upload Existing PDFs](/sdocs/template-architecture/document-formats/pdf-upload-format.md) when you answer **yes** to this:

* Do I already have the final PDF and only need to place data on top of it?

### Next reads by goal

* Need exact overlay placement on a finished PDF? Start with [Upload Existing PDFs](/sdocs/template-architecture/document-formats/pdf-upload-format.md).
* Need styling guidance? Read [Style Templates](/sdocs/template-architecture/template-authoring.md).
* Need table and child-record data? Read [Insert Data Tables](/sdocs/advanced-template-logic/related-lists.md).
* Need PDF-specific limitations? Read [PDF Render Limitations](broken://spaces/WKNnJmhJBQwhdk5WBFsi/pages/3ccb810031f9ead1d614975ed1c05651aa01130d).
* Need font guidance for multilingual output? Read [Supported Fonts in PDF Format](/sdocs/template-architecture/document-formats/pdf-templates/supported-fonts-in-pdf-format.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/template-architecture/document-formats/pdf-templates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
