ActiveReports 15 .NET Edition
GrapeCity.ActiveReports.Export.Pdf Assembly / GrapeCity.ActiveReports.Export.Pdf.Section Namespace / PdfSecurity Class / Encrypt Property
Example

In This Topic
    Encrypt Property (PdfSecurity)
    In This Topic
    Determines whether the document is encrypted or not.
    Syntax
    'Declaration
     
    Public Property Encrypt As Boolean
    public bool Encrypt {get; set;}
    Remarks
    You must set this property to true for the document to be encrypted and the permissions enforced.
    Example
    private void btnExport_Click(object sender, System.EventArgs e)
    {
        SectionReport1 rpt = new SectionReport1();
        GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport p = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
        p.Security.Encrypt = true;
        p.Security.OwnerPassword = "Mortimer";
        p.Security.UserPassword = "monkey";
        p.Security.Permissions = GrapeCity.ActiveReports.Export.Pdf.Section.PdfPermissions.AllowPrint;
        p.Security.Use128Bit = true;
        rpt.Run();
        this.viewer1.Document = rpt.Document;
        p.Export(rpt.Document, Application.StartupPath + "\\p.pdf");
    }
    Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim rpt As New SectionReport1
        Dim p As New GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport
        p.Security.Encrypt = True
        p.Security.OwnerPassword = "Mortimer"
        p.Security.UserPassword = "monkey"
        p.Security.Permissions = GrapeCity.ActiveReports.Export.Pdf.Section.PdfPermissions.AllowPrint
        p.Security.Use128Bit = True
        rpt.Run()
        Me.Viewer1.Document = rpt.Document
        p.Export(rpt.Document, Application.StartupPath & "\p.pdf")
    End Sub
    See Also