Export pdf without permission for editing

Posted by: ricgom731 on 22 March 2019, 1:36 am EST

    • Post Options:
    • Link

    Posted 22 March 2019, 1:36 am EST

    Good day.

    Please help.

    I have an application in which I use AR 12 and C #, and I need to export a PDF report to a specific folder. But I need the PDF file to have a password for editing.

    It is possible to do this?.

    I tried something like this …

    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdf = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport ();

                                    pdf.Security.OwnerPassword = "test";
                                    pdf.Security.Permissions = GrapeCity.ActiveReports.Export.Pdf.Section.PdfPermissions.AllowCopy; // In PdfPermissions. ??? I did not stay put.
                                    pdf.Export (rpt.Document, "C: \\ xxx \\ TestPDF.pdf");
    

    I have tried several options in PdfPermissions. but I can not get the pdf file to ask me for a password for editing.

    Or some way that the generated file does not allow me to edit? either with password or without password.

    I wish you could help me.

  • Posted 24 March 2019, 5:11 pm EST

    Hello,

    In order to add a password in the exported Pdf document for User, you need to use Security.UserPassword property of PdfExport. Further, you need to set the Security.Encrypt property to true. To allow the user to edit the document, you need to set Permissions to AllowModifyContents permission. The code snippet would be:

    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
                pdfExport.Security.Encrypt = true;
                pdfExport.Security.UserPassword = "SectionReport";
                pdfExport.Security.Permissions = GrapeCity.ActiveReports.Export.Pdf.Section.PdfPermissions.AllowModifyContents;
                pdfExport.Export(report.Document, Application.StartupPath + "\\PdfReport.pdf"); 
    

    You can learn more about the UserPassword property from the below mentioned documentation link:

    https://help.grapecity.com/activereports/webhelp/AR12/webframe.html#GrapeCity.ActiveReports.Export.Pdf.v12~GrapeCity.ActiveReports.Export.Pdf.Section.PdfSecurity~UserPassword.html

    A sample has been attached here for your reference.

    Best Regards,

    Esha

    PdfExportInSectionReport.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels