Paperful Icon

Paperfuldocs

Papers

Upload a paper

Upload a document and wait for it to be processed.

Uploading a document creates a paper. By default, the SDK waits until processing finishes and returns the ready paper.

All examples assume you've created a client. See Limits for supported file types and sizes.

Upload a file

import { readFile } from "node:fs/promises";

const file = await readFile("./report.pdf");

const paper = await paperful.papers.upload({
  file,
  fileName: "report.pdf",
});

console.log(paper.id, paper.status);

fileName is required when it can't be inferred from the file. File objects carry their own name, while buffers don't.

Track progress

Pass onEvent to follow processing as it happens.

const paper = await paperful.papers.upload({
  file,
  fileName: "report.pdf",
  onEvent: ({ event, data }) => {
    if (event === "progress") {
      console.log(`${data.processed}/${data.total}`);
    }
  },
});
EventDescription
startedProcessing has started.
progressProcessing advanced. Includes processed and total.
completedProcessing finished. Includes the paper.

Don't wait for processing

Set waitForProcessing to false to return as soon as the upload is accepted. Processing continues in the background, and you can check on the paper later.

const paper = await paperful.papers.upload({
  file,
  fileName: "report.pdf",
  waitForProcessing: false,
});

Options

Prop

Type

On this page