Skip to content

PDF image using Uint8Array throws an error #1446

Description

@chrishj59

Bug Report

Description of the problem

I am using an image as the Uint8Array that is downloaded from AWS.

doc.image throws the error:
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received Uint8Array(1239071)

The buffer is Uint8Array as console.log(jpgBuffer instanceof Uint8Array) returns true;

Code sample

const jpgBuffer: Uint8Array = await response.Body.transformToByteArray();
console.log(jpgBuffer instanceof Uint8Array); // true
doc.image(jpgBuffer, 50, 45, { width: 50 });

Your environment

  • pdfkit version: ^0.13.0
  • Node version: 16.13.1
  • Browser version (if applicable):
  • Operating System: MacOs 13.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions