forked from vanielf/pdf-lib
-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Labels
Description
What were you trying to do?
await pdfDoc.save();
within a Cloudflare Worker
How did you attempt to do it?
- Load a PDF Buffer (generated from puppeteer)
- Add some properties
- Encrypt the PDF (password protect edits)
- Save the PDF
What actually happened?
I added a bunch of debug logs - it's returning this error on await pdfDoc.save();
Websocket error: SessionID: {uuid} [object ErrorEvent]
Despite the error, the application continues as the error is only logged and not thrown.
What did you expect to happen?
No error logged
How can we reproduce the issue?
In a Cloudflare worker (or other V8 Isolate)
const html = '<!DOCTYPE html><html><body><h1>Hello, world!</h1></body></html>';
const browser = await puppeteer.launch(env.BROWSER);
const page = await browser.newPage();
await page.setContent(html);
const pdfBuffer = await page.pdf({ printBackground: true, margin: { top: 0, right: 0, bottom: 0, left: 0 } });
await browser.close();
const pdfDoc = await PDFDocument.load(pdfBuffer);
pdfDoc.setProducer("foo");
pdfDoc.setCreator("bar");
pdfDoc.encrypt({
ownerPassword: "somerandomstring",
userPassword: "", // empty string = allow anyone to view
permissions: {
printing: "highResolution",
modifying: false, // disallow edits
copying: true, // allow copying text
annotating: false,
fillingForms: false,
contentAccessibility: false,
documentAssembly: false,
},
});
const finalPdf = await pdfDoc.save();Version
2.5.3
What environment are you running pdf-lib in?
Other
Checklist
- My report includes a Short, Self Contained, Correct (Compilable) Example.
- I have attached all PDFs, images, and other files needed to run my SSCCE.
Additional Notes
Not sure where the error is coming from. It doesn't throw but it is logged.