Document sources

LumiPDF accepts a FileSource union so you can open PDFs from the network, disk, or memory.

URL

tsx
<DocumentViewer
  source={{ kind: "url", url: "https://example.com/doc.pdf" }}
/>

File input

tsx
function OpenPdf() {
  return (
    <input
      type="file"
      accept="application/pdf"
      onChange={(e) => {
        const file = e.target.files?.[0];
        if (!file) return;
        // setSource({ kind: "file", file })
      }}
    />
  );
}

// <DocumentViewer source={{ kind: "file", file }} />

ArrayBuffer

tsx
const buffer = await fetch("/local.pdf").then((r) => r.arrayBuffer());

<DocumentViewer
  source={{ kind: "buffer", buffer, name: "local.pdf" }}
/>

Password-protected PDFs

When a document requires a password, LumiPDF shows a built-in password dialog. Users can retry until the correct password is entered.