We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Encrypt PDF
pdfDoc.encrypt({ userPassword: 'abcd', ownerPassword: '1234', permissions: { modifying: true }, });
Error creating PDF: TypeError: pdfDoc.encrypt is not a function
Need to create password protected pdf
async function createPasswordProtectedPDF() { const pdfDoc = await PDFDocument.create(); const page = pdfDoc.addPage(); page.drawText('Creating PDFs in JavaScript is awesome!', { x: 50, y: 700, });
pdfDoc.encrypt({ userPassword: 'abcd', ownerPassword: '1234', permissions: { modifying: true }, }); const pdfBytes = await pdfDoc.save({ useObjectStreams: false }); fs.writeFileSync('sample.pdf', pdfBytes);
}
function createPwdProtectedPDF(req, res) { createPasswordProtectedPDF() .then(() => console.log('Password-protected PDF created!')) .catch(err => console.error('Error creating PDF:', err)); }
Run the above code in node environment
"pdf-lib": "^1.17.1",
Node
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What were you trying to do?
Encrypt PDF
How did you attempt to do it?
pdfDoc.encrypt({
userPassword: 'abcd',
ownerPassword: '1234',
permissions: { modifying: true },
});
What actually happened?
Error creating PDF: TypeError: pdfDoc.encrypt is not a function
What did you expect to happen?
Need to create password protected pdf
How can we reproduce the issue?
async function createPasswordProtectedPDF() {
const pdfDoc = await PDFDocument.create();
const page = pdfDoc.addPage();
page.drawText('Creating PDFs in JavaScript is awesome!', {
x: 50,
y: 700,
});
}
function createPwdProtectedPDF(req, res) {
createPasswordProtectedPDF()
.then(() => console.log('Password-protected PDF created!'))
.catch(err => console.error('Error creating PDF:', err));
}
Run the above code in node environment
Version
"pdf-lib": "^1.17.1",
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: