Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The argument 'path' must be a string or Uint8Array without null bytes #135

Open
rodpf opened this issue Feb 14, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@rodpf
Copy link

rodpf commented Feb 14, 2024

Hi,

Since I need support for ES5, I am using V4.3.1.

I am passing a ByteArray and receiving the following error:

The argument 'path' must be a string or Uint8Array without null bytes. Received Uint8Array(95657)

This is the snippet for creating the stream:

        const file = await _getObjectStream(null)

        const merger = new PDFMerger();
        for (let i=0 ; i<1000; i++)
        {
            await merger.add (file)
        }
        const mergedPdfBuffer = await merger.saveAsBuffer();

The error occurs on await merger.add (file)

As you can see I am receiving the file as a Uint8Array and trying to merge the same content a few times to execute a stress test and limit the size of the merged file.

The value for 'file' is valid, since I can see and download the content from the same variable.

@mojoaxel mojoaxel added bug Something isn't working pdf-lib This problem was comes from pdf-lib and should be solved there labels Jun 17, 2024
@mojoaxel
Copy link
Collaborator

mojoaxel commented Jun 17, 2024

It looks like this error is thrown by node itself and not by us or pdf-lib.

@rodpf You could try to ensure file is a Uint8Array:

await merger.add(Buffer.from(file));

see also foliojs/pdfkit#1446

@mojoaxel mojoaxel removed the pdf-lib This problem was comes from pdf-lib and should be solved there label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants