Error processing SSI file
LEADTOOLS PDF (Leadtools.Pdf assembly)

Show in webframe

PDFSecurityOptions Class






Members 
PDF encryption options
Object Model
Syntax
[SerializableAttribute()]
public class PDFSecurityOptions 
'Declaration
 
<SerializableAttribute()>
Public Class PDFSecurityOptions 
'Usage
 
Dim instance As PDFSecurityOptions
[SerializableAttribute()]
public ref class PDFSecurityOptions 
Remarks

The PDFSecurityOptions class is used as the type for the SecurityOptions and used to set the security and encryption options to use when creating or updating PDF files.

The following methods of the PDFFile class will use the security options set in .SecurityOptions when updating or created a PDF file:

If the value of PDFFile.SecurityOptions is null, then the PDFFile will not encrypt the result PDF file.

There are two different ways to protect a PDF file with a password:

You cannot use both UserPassword and OwnerPassword in the same PDF file. If both values are set, then the PDFFile object will use OwnerPassword and ignore UserPassword.

Example

This example will re-encrypt a PDF file with an owner password and restrict printing.

Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Pdf
Imports Leadtools.WinForms
Imports Leadtools.Svg
Imports Leadtools.ImageProcessing

<TestMethod> _
Public Sub PDFFileSecurityOptionsExample()
   Dim sourceFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf")
   Dim destinationFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_EncryptedNoPrint.pdf")
   Dim pdfFile As PDFFile = New PDFFile(sourceFileName)

   ' Set the security options
   pdfFile.SecurityOptions = New PDFSecurityOptions()
   pdfFile.SecurityOptions.UserPassword = "LEAD"
   pdfFile.SecurityOptions.PrintEnabled = False
   pdfFile.SecurityOptions.HighQualityPrintEnabled = False
   pdfFile.SecurityOptions.EncryptionMode = PDFEncryptionMode.RC128Bit

   ' Encrypt the file by saving it to the destination file
   pdfFile.Convert(1, -1, destinationFileName)
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Drawing;
using Leadtools.ImageProcessing;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;

[TestMethod]
public void PDFFileSecurityOptionsExample()
{
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf");
   string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_EncryptedNoPrint.pdf");
   PDFFile pdfFile = new PDFFile(sourceFileName);

   // Set the security options
   pdfFile.SecurityOptions = new PDFSecurityOptions();
   pdfFile.SecurityOptions.UserPassword = "LEAD";
   pdfFile.SecurityOptions.PrintEnabled = false;
   pdfFile.SecurityOptions.HighQualityPrintEnabled = false;
   pdfFile.SecurityOptions.EncryptionMode = PDFEncryptionMode.RC128Bit;

   // Encrypt the file by saving it to the destination file
   pdfFile.Convert(1, -1, destinationFileName);
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms

See Also

Reference

PDFSecurityOptions Members
Leadtools.Pdf Namespace

Error processing SSI file
   Leadtools.Pdf requires a PDF Pro, Pro Suite, Document, or Medical license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features