Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Stimulsoft Reports.JS discussion
filbertumbawa
Posts: 13
Joined: Fri Jan 08, 2021 10:11 am

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post by filbertumbawa »

Hello, could it be response?
Master600
Posts: 5
Joined: Wed Feb 28, 2018 5:38 pm

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post 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.
filbertumbawa
Posts: 13
Joined: Fri Jan 08, 2021 10:11 am

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post 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.
Max Shamanov
Posts: 999
Joined: Tue Sep 07, 2021 10:11 am

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post 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.
filbertumbawa
Posts: 13
Joined: Fri Jan 08, 2021 10:11 am

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post by filbertumbawa »

If don't want allowed edit, print or anything else?
filbertumbawa
Posts: 13
Joined: Fri Jan 08, 2021 10:11 am

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post by filbertumbawa »

Hello Sir, could it help?
Thank you
Max Shamanov
Posts: 999
Joined: Tue Sep 07, 2021 10:11 am

Re: Does Stimulsoft Reports.JS (v2023.1.1) Support PDF Protection?

Post 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.
Post Reply