sempdf
sempdf v1.9.1Type aliases

Type Alias: BinaryData

sempdf v1.9.1


sempdf / BinaryData

type BinaryData = Uint8Array | ArrayBuffer;

Defined in: src/types.ts:678

Binary input accepted by the library.

Accepted types:

  • Uint8Array
  • ArrayBuffer

Node.js Buffer (which extends Uint8Array) works directly. Browser Blob values must be converted first:

Example

// Node.js Buffer — works directly
import { readFileSync } from "node:fs";
const fontBytes: BinaryData = readFileSync("font.ttf"); // Buffer extends Uint8Array

// Browser Blob — convert first
const blob = await fetch("image.png").then(r => r.blob());
const imageBytes: BinaryData = await blob.arrayBuffer();

On this page