---
title: "Forms & signatures — Vue"
description: "Let people fill in and build PDF forms, sign with a drawn, typed or uploaded signature, and check the signatures a document carries."
integration: "Vue"
other_integrations:
  "Vanilla JS": "https://www.embedpdf.com/docs/viewer/vanilla/features/forms-and-signatures.md"
  "React": "https://www.embedpdf.com/docs/viewer/react/features/forms-and-signatures.md"
  "Svelte": "https://www.embedpdf.com/docs/viewer/svelte/features/forms-and-signatures.md"
  "Angular": "https://www.embedpdf.com/docs/viewer/angular/features/forms-and-signatures.md"
source: "https://www.embedpdf.com/docs/viewer/vue/features/forms-and-signatures"
---

# Forms & signatures

A PDF with a form can be filled in as soon as it opens: text fields, checkboxes, radio buttons,
lists, and the form's own checks and calculations. The values are saved in the file when it's
downloaded, so they open the same in Acrobat.

## Read and fill in values from code

`viewer.get('form')` is the form plugin. Fill in what you already know, and read what people
entered:

```js
const form = viewer.get('form');

await form.importValues({
  'customer.name': 'Ada Lovelace',
  'customer.email': 'ada@example.com',
});
const values = await form.exportValues(); // { 'customer.name': 'Ada Lovelace', … }
```

`onValueChanged` fires for every change, from people or from your code. See [Filling
forms](https://www.embedpdf.com/docs/headless/vue/forms.md#methods) for every method.

**`values.vue`**

```vue
<script setup lang="ts">
import { ref } from 'vue';
import { PDFViewer, type Viewer } from '@embedpdf/viewer-vue';

import './values.css';

const forms = 'https://www.embedpdf.com/pdfs/forms.pdf';

const values = ref('{}');

// Once the form is open: show its values as they change, and fill in what the app knows.
function onReady(viewer: Viewer) {
  viewer.documents.onOpened(async () => {
    const form = viewer.get('form');
    form.onValueChanged(() => (values.value = JSON.stringify(form.exportValues())));
    await form.importValues({ name: 'Ada Lovelace', email: 'ada@example.com' });
  });
}
</script>

<template>
  <div class="app">
    <PDFViewer :src="forms" class="viewer" @ready="onReady" />
    <footer class="values">
      <span class="label">exportValues()</span>
      <code class="code">{{ values }}</code>
    </footer>
  </div>
</template>
```

**`values.css`**

```css
/* Colors, for light and dark */
:root {
  --ink: #1a2748;
  --muted: #5a6b92;
  --line: #e6eaf2;
  --surface: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6ecfa;
    --muted: #93a3c7;
    --line: #27365f;
    --surface: #131d3b;
  }
}

/* The viewer, then the form's values under it */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.viewer {
  flex: 1;
  min-height: 0;
}

.values {
  display: flex;
  align-items: baseline;
  gap: 10px;
  max-height: 64px;
  overflow: auto;
  padding: 8px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.label {
  flex: none;
  font-weight: 600;
  color: var(--muted);
}

.code {
  font-family: ui-monospace, monospace;
  color: var(--ink);
  overflow-wrap: anywhere;
}
```

> **Try it:** the name and email came from `importValues()` as the form opened. Pick a plan and
> tick the terms: the values under the viewer follow.

## Take people to a field

Tab and Shift+Tab move through the fields in the document's order, from page to page, and the view
follows. From code, `focus()` brings a field into view and puts the cursor in it, and `focusNext()`
goes on as Tab does:

```js
const { valid, missing } = form.validate();
if (!valid) form.focus(missing[0].ref);

form.focusNext({ empty: true, wrap: true }); // the next field that still needs an answer
```

See [Move between fields](https://www.embedpdf.com/docs/headless/vue/forms.md#move-between-fields).

## Build a form

Building forms starts off: people fill in a form but can't change its fields. Turn it on, and the
**Form** mode joins the tabs:

```js
{ features: { 'forms.building': true } }
```

The Form mode opens for filling in and looking. Its **Form design** button switches design on:
then fields can be selected, moved, resized and deleted, and the form design sidebar opens. Picking
one of the field tools switches design on too: drag a box where the text field, checkbox, radio
button, dropdown, list or signature field goes. Press **Form design** again, or leave the Form mode,
and the fields fill in again.

The form design sidebar holds what a field *is*: with nothing selected it lists the document's
fields by page, and a click on one selects it and scrolls to it; with a field selected, it shows the
field's name, tooltip, options and the rest of its settings. A radio group and a checkbox list
their buttons there, with **Add a button** (or **Add a box**): the new one joins the group, below
the last if they stand in a column or beside it if in a row, at the same size and spacing, and
it's selected so you can drag it. A radio group's new button is a new choice; a checkbox's new box
checks together with the others. How a field looks, its border, background and font, is in the
**Style** sidebar, the toolbar's other button.

On a page that is shown turned, such as a scan saved sideways, a new field is placed the way you
see the page, and what's typed into it reads upright there. A selected field's menu has **Rotate
clockwise**, which turns the field a quarter turn and keeps it on the page: a field near the
page's edge lands against the edge. The Style sidebar has **Orientation**, which turns only what's
in the field and leaves its box where it stands. A field turns by quarter turns, the one turn a
PDF form field can hold, so every PDF app shows it the same way.

**Duplicate** (`Ctrl`/`Cmd`+`D`) copies the selected fields beside the originals and selects the
copies, as one step to undo. What a copy becomes follows from what was selected:

- **A radio button's copy joins its group** as a new choice. Place one button, duplicate it
  twice, and you have a group of three.
- **Any other field's copy is a new field,** named after the original: `email` becomes
  `email_2`. It has the original's settings and no answer.

To copy a whole radio group, select one of its buttons and press **Duplicate group** in the
sidebar: the copy is a new group with the same buttons and the same values.

For a form people fill in and can't otherwise change, use
`{ readOnly: { except: ['forms.filling'] } }`: see [Read-only](https://www.embedpdf.com/docs/viewer/vue/features/turning-off.md#read-only).

## Form settings

```js
{
  plugins: {
    form: { validation: 'none', focus: { color: '#7c3aed' } },
  },
}
```

`validation: 'none'` accepts every value without running the form's own checks. Every setting is
on [Filling forms](https://www.embedpdf.com/docs/headless/vue/forms.md#settings).

## Signatures

In the **Insert** mode, the signature button opens the signatures panel: one row per person, with
their drawn, typed or uploaded signature and, if they want, their initials. People pick a mark and
click a signature field to sign it, or click anywhere else to place it as a stamp. A click on an
unsigned field starts there: the next mark picked goes in.

What signing does depends on whether you give the viewer a key:

```js
{
  plugins: {
    signature: {
      // your key, a signing service, or one kept in the browser
      signingKey: () => mySigningService.signer(),
      // a timestamp with every signature, from your timestamp authority
      timestampAuthority: httpTimestampAuthority({ url: '/api/timestamp' }),
      // keep each signature checkable for years, with no network
      revocation: httpRevocationSource({ url: '/api/revocation' }),
      documentTimestamp: true,
      trust: { anchors: async () => [rootCertificate] },
      mode: 'ask',
      allowCertify: true,
      kinds: ['signature'], // no initials
      fonts: [{ key: 'great-vibes', url: '/fonts/GreatVibes.ttf', label: 'Great Vibes' }],
    },
  },
}
```

| Setting              | What it does                                                                                                             | Default                                   |
| :------------------- | :----------------------------------------------------------------------------------------------------------------------- | :---------------------------------------- |
| `signingKey`         | The signer, or a function that returns one when someone signs                                                            | none: a mark is only drawn into the field |
| `mode`               | `'sign'` seals the document, `'visual'` only draws, `'ask'` shows a dialog first                                         | `'sign'` with a key, else `'visual'`      |
| `timestampAuthority` | The timestamp authority: every signature the viewer seals carries its timestamp                                          | none                                      |
| `revocation`         | Where revocation answers come from: every signature the viewer seals gets its validation data right after. Needs `trust` | none                                      |
| `documentTimestamp`  | Add a document timestamp after the validation data. Needs `timestampAuthority`                                           | `false`                                   |
| `trust`              | The certificates you trust: for checking signatures, and for the timestamps the viewer seals                             | none                                      |
| `allowCertify`       | Let the first signature be a certification, which sets what may still change: comments, form filling only, or nothing    | `false`                                   |
| `kinds`              | Which marks people keep: `'signature'`, `'initials'`                                                                     | both                                      |
| `fonts`              | Fonts for typed signatures                                                                                               | Allura, Great Vibes and Caveat            |

`kinds` and `fonts` are the viewer's; the others are the [signature
plugin's](https://www.embedpdf.com/docs/headless/vue/forms/signatures.md#settings).

## Check signatures

A click on a signed field shows its verdict: whether the document is unchanged since it was
signed, whether the signature is valid, whether you trust the signer, and what changed since. It
offers the signed revision as a download. For a signature with a timestamp, it shows the time the
timestamp authority vouches for and the authority's name, beside the time the signer claims. The
panel also says what a save would do: after an
unsaved annotation, an approval signature reads "valid; unsaved changes will invalidate it", the
way Acrobat warns.

Two more lines say how the signature will hold up:

- **Revocation** says whether the signer's certificate was withdrawn, when the file holds an
  answer: "Not revoked" or "Revoked".
- **Long-term validation** says whether the file holds everything a reader needs to check the
  signature with no network: "Enabled", with the day that proof runs out, or "Not enabled", with
  what is missing. For a signature that isn't enabled, **Add verification information** asks for
  the answers and stores them. It shows when `revocation` and `trust` are set and the person may
  sign.

`viewer.get('signature')` gives you the same from code: see
[Signatures](https://www.embedpdf.com/docs/headless/vue/forms/signatures.md#methods).

## Good to know

### Where keys live

`personalSigner()` keeps one self-signed identity per person in the browser's storage, which is
enough for a signature that proves the document hasn't changed. For a signature people outside
your app trust, use your own key with `webCryptoSigner()` or a signing service with
`remoteSigner()`. All three come from your viewer package.

### Timestamps

A signature says when it was made by the signer's own clock. With `timestampAuthority`, a
timestamp authority vouches for that time, and the signature can still be checked after the
signer's certificate expires. `httpTimestampAuthority()` comes from your viewer package. Most
authorities can't be called from a web page, so its `url` is a route of your own that passes the
request on: see
[Reach the authority from a browser](https://www.embedpdf.com/docs/engine/forms/signatures.md#reach-the-authority-from-a-browser).

A timestamp is never skipped: when the authority can't be reached, the sign dialog says so and
nothing is signed. With `trust` set, the viewer also refuses a timestamp from an authority your
`trust` doesn't cover; list the authority's root under `timestampAnchors`.

### Signatures that last

A certificate can be withdrawn before its end date, and its issuer stops answering questions
about it once it expires. With `revocation`, the viewer asks while the issuer still answers and
keeps the answers in the file, right after each signature it seals. Acrobat shows such a
signature as "LTV enabled". With `documentTimestamp` too, a document timestamp follows, which
proves the answers were in the file by then.

`httpRevocationSource()` comes from your viewer package, and its `url` is a route of your own:
see [Reach the issuers from a browser](https://www.embedpdf.com/docs/engine/forms/signatures.md#reach-the-issuers-from-a-browser).

The signature is sealed before the answers are asked for. When they can't be had, the document
is still signed: the sign dialog says "Signed. The verification information could not be added",
and the signature's details offer to add it later. Opening a document asks nobody: the viewer
checks signatures with what the file holds.

### Forms that run scripts

A form's own JavaScript, for checks and calculations, runs in a sandbox with no access to your
page. It can't open windows, fetch anything or read cookies.
