---
title: "Engine"
description: "Open, read, change and save PDF files from JavaScript, with one typed API."
source: "https://www.embedpdf.com/docs/engine"
---

# The PDF engine

The EmbedPDF engine opens PDF files in the browser and lets you render their pages, read and
search their text, add annotations, fill forms, edit pages and save the result. It runs PDFium,
the PDF library inside Chrome, in a Web Worker, so your page stays responsive. Nothing is
uploaded: the file never leaves the device.

The ready-made viewer and the headless components are built on this engine. Use it directly
when you want PDF features without a viewer: a thumbnail job, a form filler, an export script.

```ts
import { localEngine } from '@embedpdf/engine';

const engine = localEngine();
const doc = await engine.open({ kind: 'bytes', bytes });

const { pages } = await doc.pages.list();
const image = await doc.page(pages[0].ref).render.image();
```

## What you can do

- **[Render pages](https://www.embedpdf.com/docs/engine/documents/rendering)** as images, at any size.
- **[Read](https://www.embedpdf.com/docs/engine/text/extraction), [search](https://www.embedpdf.com/docs/engine/text/search) and
  [select](https://www.embedpdf.com/docs/engine/text/selection-and-geometry)** the text on a page, and find out where
  each character is.
- **[Add and edit annotations](https://www.embedpdf.com/docs/engine/annotations)**: highlights, notes, shapes, stamps,
  measurements. Copy them to another document with
  [import & export](https://www.embedpdf.com/docs/engine/annotations/import-export).
- **[Fill forms](https://www.embedpdf.com/docs/engine/forms)**, create form fields and
  [sign](https://www.embedpdf.com/docs/engine/forms/signatures) documents.
- **[Change pages](https://www.embedpdf.com/docs/engine/documents/pages)**: rotate, reorder, delete, insert, merge and
  split.
- **[Redact](https://www.embedpdf.com/docs/engine/documents/redaction)** content for good, and
  **[save](https://www.embedpdf.com/docs/engine/documents/saving)** the result.
- **[Group edits into changes](https://www.embedpdf.com/docs/engine/documents/changes)** that apply all or none, and undo
  or redo any of them.

Every call is async, can be cancelled, and fails with a typed error you can branch on. The same
code runs on the local engine and on the CloudPDF engine: only how you create the engine and
open a file differs.

A few things exist only on the local engine: its fonts, `warmup()`, raw pixels, and saving a
document's layer or to a file. A document opened with `localEngine()` has them. Code that takes
any engine checks first:

```ts
import { isLocalDocument } from '@embedpdf/engine';

if (isLocalDocument(doc)) {
  const layer = await doc.downloadLayer();
}
```

`isLocalEngine(engine)` does the same for an engine.

## Local or cloud

This engine runs in the browser: no server, no upload, and it works offline. That makes it the
right choice when the user already has the file, or when the file may not leave their device.

> **Keep the file on your server**
>
> When the file lives on your server, the CloudPDF engine runs the same API there and checks every
> call. A user sees the first page as an image, without downloading the whole PDF or the engine
> (about 3 MB compressed), and a user who may not download the file never receives it. Your code
> stays the same: swap `localEngine()` for `cloudEngine()`.
>
> [Read about the CloudPDF engine](https://www.cloudpdf.com/docs/engine)

## Next steps

- [Quick start](https://www.embedpdf.com/docs/engine/quick-start) — Open a PDF, render a page, search it and add a highlight.
- [Setup](https://www.embedpdf.com/docs/engine/setup) — Install the engine and create it once for your app.
- [Annotations](https://www.embedpdf.com/docs/engine/annotations) — Read, add and change annotations of every kind.
