As part of a project, I am required to make edits to PDF files. To achieve this, I have been using PDF Lib and have had success with it so far. However, I've encountered some difficulties when trying to load an existing PDF file which is evident in the following error message:
TypeError:
string
orUint8Array
orArrayBuffer
, but was actually of typeundefined
Below is the code snippet that triggers this error:
const pdfData = await fs.readFile('./test.pdf', 'utf8', (err, data) => {
if (err) {
console.error(err);
return;
}
});
const pdfDoc = await PDFDocument.load(pdfData);
Has anyone else come across this same issue?