diff --git a/bin/browser.cjs b/bin/browser.cjs index b33f52c..d340150 100644 --- a/bin/browser.cjs +++ b/bin/browser.cjs @@ -49,7 +49,9 @@ const getOutput = async (request, page = null) => { const result = await page[request.action](request.options); // Ignore output result when saving to a file - output.result = request.options.path ? '' : result.toString('base64'); + output.result = request.options.path + ? '' + : (result instanceof Uint8Array ? Buffer.from(result) : result).toString('base64'); } } diff --git a/tests/PdfTest.php b/tests/PdfTest.php index 03c06b6..468ab73 100644 --- a/tests/PdfTest.php +++ b/tests/PdfTest.php @@ -64,6 +64,7 @@ ->base64pdf(); expect(is_string($base64))->toBeTrue(); + expect(base64_decode($base64, true))->toBeString(); }); it('can write options to a file and generate a pdf', function () {