CloudPDF
DocsPricing
Start building

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#

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.

Next steps#