mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-07-19 12:57:23 +08:00

previously the only way to test if a password was correct was to supply a single password and throw if the value was incorrect. this was slow. now parsing options supports a list of passwords as well as a single password option (which is equivalent to a list with a single item). these passwords are all tested at the same time and an exception is only thrown once all passwords are tested.
45 lines
1.6 KiB
C#
45 lines
1.6 KiB
C#
namespace UglyToad.PdfPig
|
|
{
|
|
using System.Collections.Generic;
|
|
using Logging;
|
|
|
|
/// <summary>
|
|
/// Configures options used by the parser when reading PDF documents.
|
|
/// </summary>
|
|
public class ParsingOptions
|
|
{
|
|
/// <summary>
|
|
/// A default <see cref="ParsingOptions"/> with <see cref="UseLenientParsing"/> set to false.
|
|
/// </summary>
|
|
public static ParsingOptions LenientParsingOff { get; } = new ParsingOptions
|
|
{
|
|
UseLenientParsing = false
|
|
};
|
|
|
|
/// <summary>
|
|
/// Should the parser ignore issues where the document does not conform to the PDF specification?
|
|
/// </summary>
|
|
public bool UseLenientParsing { get; set; } = true;
|
|
|
|
private ILog logger = new NoOpLog();
|
|
/// <summary>
|
|
/// The <see cref="ILog"/> used to record messages raised by the parsing process.
|
|
/// </summary>
|
|
public ILog Logger
|
|
{
|
|
get => logger ?? new NoOpLog();
|
|
set => logger = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The password to use to open the document if it is encrypted. If you need to supply multiple passwords to test against
|
|
/// you can use <see cref="Passwords"/>. The value of <see cref="Password"/> will be included in the list to test against.
|
|
/// </summary>
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// All passwords to try when opening this document, will include any values set for <see cref="Password"/>.
|
|
/// </summary>
|
|
public List<string> Passwords { get; set; } = new List<string>();
|
|
}
|
|
} |