Page 2 of 2
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Sat Feb 22, 2025 1:32 am
by filbertumbawa
Hello, could it be response?
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Sun Feb 23, 2025 5:23 pm
by Master600
I haven't used Stimulsoft Reports.JS for a while, but from what I remember, it might not have all those advanced PDF protection features built-in.
What I ended up doing in a similar situation was generating the PDF normally with Stimulsoft, and then using a separate PDF library (like PDFKit or jsPDF) to add the password protection and restrictions as a post-processing step.
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Mon Feb 24, 2025 1:54 am
by filbertumbawa
Answer to @Master600, but in Stimulsoft Report.JS already had feature to protected PDF. But it set in DocumentSecurity. And when i test, it works.
I just want could it be set when we generated in the javascript, not using viewer to set it in PDF for document security.
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Mon Feb 24, 2025 6:25 am
by Max Shamanov
Hello,
You can use the following code to protect pdf from the code:
Code: Select all
var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
settings.passwordInputUser = "1234";
settings.passwordInputOwner = "12345";
// Export to PDF
report.exportDocumentAsync((pdfData) => {
// Converting Array into buffer
var buffer = Buffer.from(pdfData);
// File System module
var fs = require('fs');
// Saving string with rendered report in PDF into a file
fs.writeFileSync('./SVG-Example-Report.pdf', buffer);
console.log("Rendered report saved into PDF-file.");
}, Stimulsoft.Report.StiExportFormat.Pdf,
null,
settings);
Thank you.
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Mon Feb 24, 2025 7:19 am
by filbertumbawa
If don't want allowed edit, print or anything else?
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Tue Feb 25, 2025 8:18 am
by filbertumbawa
Hello Sir, could it help?
Thank you
Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?
Posted: Tue Feb 25, 2025 12:21 pm
by Max Shamanov
Hello,
You can use this code to restrict editing or printing of the document, if you do not want to print the document you will need to remove Stimulsoft.Report.Export.StiUserAccessPrivileges.PrintDocument from the line below:
Code: Select all
var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
settings.userAccessPrivileges = Stimulsoft.Report.Export.StiUserAccessPrivileges.ModifyContents
| Stimulsoft.Report.Export.StiUserAccessPrivileges.PrintDocument
| Stimulsoft.Report.Export.StiUserAccessPrivileges.CopyTextAndGraphics
| Stimulsoft.Report.Export.StiUserAccessPrivileges.AddOrModifyTextAnnotations;
Thank you.