Table of Contents

Method Unlock

Namespace
LMKit.Document.Pdf
Assembly
LM-Kit.NET.dll

Unlock(string, string, string)

Opens a password-protected PDF file and saves it without protection.

public static void Unlock(string inputPath, string password, string outputPath)

Parameters

inputPath string

Path to the password-protected PDF file.

password string

The password to open the document.

outputPath string

Path where the unlocked PDF will be written.

Examples

using LMKit.Document.Pdf;

PdfUnlocker.Unlock(
    "confidential_report.pdf",
    "s3cretP@ss",
    "report_unlocked.pdf");

Exceptions

ArgumentNullException

Thrown when inputPath, password, or outputPath is null.

FileNotFoundException

Thrown when inputPath does not exist.

Unlock(string, string)

Opens a password-protected PDF file and returns an unlocked copy as an attachment.

public static Attachment Unlock(string inputPath, string password)

Parameters

inputPath string

Path to the password-protected PDF file.

password string

The password to open the document.

Returns

Attachment

A new Attachment containing the unlocked PDF.

Examples

using LMKit.Data;
using LMKit.Document.Pdf;

Attachment unlocked = PdfUnlocker.Unlock("protected.pdf", "password123");
Console.WriteLine($"Unlocked PDF has {unlocked.PageCount} pages");

Exceptions

ArgumentNullException

Thrown when inputPath or password is null.

FileNotFoundException

Thrown when inputPath does not exist.

Unlock(Attachment, string)

Opens a password-protected PDF attachment and returns an unlocked copy.

public static Attachment Unlock(Attachment source, string password)

Parameters

source Attachment

The password-protected PDF attachment.

password string

The password to open the document.

Returns

Attachment

A new Attachment containing the unlocked PDF.

Examples

using LMKit.Data;
using LMKit.Document.Pdf;

var source = new Attachment("protected.pdf");
Attachment unlocked = PdfUnlocker.Unlock(source, "password123");

Exceptions

ArgumentNullException

Thrown when source or password is null.

ArgumentException

Thrown when the source attachment is not a PDF.

Share