Method Unlock
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
inputPathstringPath to the password-protected PDF file.
passwordstringThe password to open the document.
outputPathstringPath 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, oroutputPathisnull.- FileNotFoundException
Thrown when
inputPathdoes 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
inputPathstringPath to the password-protected PDF file.
passwordstringThe 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
inputPathorpasswordisnull.- FileNotFoundException
Thrown when
inputPathdoes 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
sourceAttachmentThe password-protected PDF attachment.
passwordstringThe 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
sourceorpasswordisnull.- ArgumentException
Thrown when the source attachment is not a PDF.