PermissionException Class

Represents errors that occurs when an attempt is made to perform an operation not allowed by the document author.

public class PermissionException : PdfException
Namespace
PdfToSvg
Package
PdfToSvg.NET (since v0.7.0)
Inheritance
System.Object System.Exception PdfToSvg.PdfException PdfToSvg.PermissionException

Example

If the author has restricted extraction of content from the PDF document, you can specify the PDF owner password to override the restrictions.

Convert PDF with usage restrictions
var openOptions = new OpenOptions();

do
{
    try
    {
        using (var document = PdfDocument.Open("maybe-password-protected.pdf", openOptions))
        {
            var pageNo = 1;

            foreach (var page in document.Pages)
            {
                page.SaveAsSvg($"output_{pageNo++}.svg");
            }
        }

        Console.WriteLine("Success!");
        break;
    }
    catch (Exception ex) when (ex is InvalidCredentialException || ex is PermissionException)
    {
        Console.WriteLine(string.IsNullOrEmpty(openOptions.Password)
            ? "A password is required to convert the document."
            : "The password is incorrect. Try again.");
        Console.WriteLine();
        Console.WriteLine("Enter password:");
        openOptions.Password = Console.ReadLine();

        Console.WriteLine();
    }
}
while (!string.IsNullOrEmpty(openOptions.Password));

Constructors

PermissionExceptionCreates a new instance of a PermissionException.

See Also

PdfToSvg Namespace