> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromiumly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Forms

> List, fill, and flatten PDF form fields.

## List the fields

`PDF.form()` lists a form's fields, with the values each takes, in the shape `set-form` fills. Pass `pages` to keep the fields on some pages only.

```typescript theme={null}
import { PDF } from "chromiumly";

const fields = await PDF.form({ files: ["path/to/application.pdf"], pages: "1" });
// {
//   "application.pdf": [
//     { name: "agree", type: "checkbox", value: "Off", pages: [1], states: ["Yes"] },
//     { name: "color", type: "combo", value: "Red", pages: [1], options: ["Red", "Green"] }
//   ]
// }
```

Each field has its fully qualified `name`, its `type` (`text`, `checkbox`, `radio`, `button`, `combo`, `list` or `signature`), its `value`, and the `pages` it sits on. `states` lists what a checkbox or radio group takes besides `Off`, and `options` what a choice field takes. `readOnly`, `required`, `multiSelect`, `editable` and `maxLength` show when they apply. A PDF without a form answers `[]`.

## Fill

`set-form` fills fields by their fully qualified names: a string, or an array of strings for a list that selects several.

```typescript theme={null}
const filled = await PDF.setForm({
  files: ["path/to/application.pdf"],
  fields: { name: "Jane Doe", agree: "Yes", color: "Green" },
});
```

A name the PDF doesn't have is refused with a 400.

## Flatten

`flatten-form` burns the form fields into the pages, which can then no longer be edited. Fill and flatten in one request:

```typescript theme={null}
const final = await PDF.pipe({
  files: ["path/to/application.pdf"],
  stages: [
    { op: "set-form", fields: { name: "Jane Doe" } },
    { op: "flatten-form" },
  ],
});
```

Or flatten on its own with `PDF.flattenForm({ files })`.

LibreOffice exports fillable fields by default (`exportFormFields`), so a converted form can go straight to `set-form`.

See [Reference — PDF](https://docs.chromiumly.dev/reference/pdf.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.