| Encryption is one of the famous security measures that is most widely being used in IT industry. Encryption is applied to PDF documents to make them more secure. One of the famous definition of encryption on the web is: |
| Any procedure used in cryptography to convert plaintext into ciphertext in order to prevent anyone except the intended recipient from reading that data. There are many types of data encryption, and they are the basis of network security. Common types include Data Encryption Standard and public-key encryption. |
By default, Aspose.Pdf for .NET applies encryption level to 40 bits on PDF documents. But if developers like to make their documents more secure then 128 bit encryption is also supported by Aspose.Pdf for .NET. Security class in Aspose.Pdf for .NET provides Is128BitsEncrypted property. Is128BitsEncrypted property is a boolean property and can be set to true to apply 128 bit encryption on the PDF documents.
Code Snippet
C#
//Instantiate Pdf instance by calling its empty constructor Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); //Assign a security instance to Pdf object pdf1.Security = new Aspose.Pdf.Generator.Security(); //Set encryption level to 128 bits pdf1.Security.Is128BitsEncrypted = true; //Add a section in the Pdf Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); //Create a text paragraph Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(sec1,"this is text content"); //Set the top maring of text paragraph to 30 text1.Margin.Top = 30; //Add the text paragraph to the section sec1.Paragraphs.Add(text1); //Save the Pdf pdf1.Save(...);
VB.NET
'Instantiate Pdf instance by calling its empty constructor
Dim pdf1 As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()
'Assign a security instance to Pdf object
pdf1.Security = New Aspose.Pdf.Generator.Security()
'Set encryption level to 128 bits
pdf1.Security.Is128BitsEncrypted = True
'Add a section in the Pdf
Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()
'Create a text paragraph
Dim text1 As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text(sec1, "this is text content")
'Set the top maring of text paragraph to 30
text1.Margin.Top = 30
'Add the text paragraph to the section
sec1.Paragraphs.Add(text1)
'Save the Pdf
pdf1.Save(...)
XML
<?xml version="1.0" encoding="utf-8" ?> <Pdf xmlns="Aspose.Pdf" Is128BitsEncrypted="true"> <Section> <Text MarginTop="30"> <Segment>this is text content</Segment> </Text> </Section> </Pdf>
