The PDF engine
The CloudPDF engine gives your app a full PDF engine over HTTPS. Your files stay on your CloudPDF server. The engine renders their pages, reads and searches their text, stores annotations and form values, and checks every call against the permissions in the user’s token.
The CloudPDF 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.
import { cloudEngine } from '@cloudpdf/engine';
const engine = cloudEngine();
const doc = await engine.open({ kind: 'token', token: () => fetchDocumentToken(documentId) });
const { pages } = await doc.pages.list();
const image = await doc.page(pages[0].ref).render.image();What you can do#
- Render pages as images, at any size.
- Read, search and select the text on a page, and find out where each character is.
- Add and edit annotations: highlights, notes, shapes, stamps, measurements. Copy them to another document with import & export.
- Fill forms, create form fields and sign documents.
- Change pages: rotate, reorder, delete, insert, merge and split.
- Redact content for good, and save the result.
- Group edits into 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:
import { isLocalDocument } from '@cloudpdf/engine';
if (isLocalDocument(doc)) {
const layer = await doc.downloadLayer();
}isLocalEngine(engine) does the same for an engine.