mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
throw informative exception when the document is encrypted
This commit is contained in:
@@ -123,6 +123,11 @@
|
||||
private static CosBase ParseTrailer(IRandomAccessRead reader, CrossReferenceTable crossReferenceTable,
|
||||
DynamicParser dynamicParser, BruteForceSearcher bruteForceSearcher, CosObjectPool pool, bool isLenientParsing)
|
||||
{
|
||||
if (crossReferenceTable.Dictionary.ContainsKey(CosName.ENCRYPT))
|
||||
{
|
||||
throw new NotSupportedException("Cannot currently parse a document using encryption: " + crossReferenceTable.Dictionary);
|
||||
}
|
||||
|
||||
foreach (var value in crossReferenceTable.Dictionary.Values)
|
||||
{
|
||||
if (value is CosObject temporaryObject)
|
||||
|
@@ -64,8 +64,20 @@
|
||||
Pages = new Pages(log, Catalog, pdfObjectParser, pageFactory, reader, isLenientParsing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="PdfDocument"/> for reading from the provided file bytes.
|
||||
/// </summary>
|
||||
/// <param name="fileBytes">The bytes of the PDF file.</param>
|
||||
/// <param name="options">Optional parameters controlling parsing.</param>
|
||||
/// <returns>A <see cref="PdfDocument"/> providing access to the file contents.</returns>
|
||||
public static PdfDocument Open(byte[] fileBytes, ParsingOptions options = null) => PdfDocumentFactory.Open(fileBytes, options);
|
||||
public static PdfDocument Open(string filename, ParsingOptions options = null) => PdfDocumentFactory.Open(filename, options);
|
||||
/// <summary>
|
||||
/// Opens a file and creates a <see cref="PdfDocument"/> for reading from the provided file path.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The full path to the file location of the PDF file.</param>
|
||||
/// <param name="options">Optional parameters controlling parsing.</param>
|
||||
/// <returns>A <see cref="PdfDocument"/> providing access to the file contents.</returns>
|
||||
public static PdfDocument Open(string filePath, ParsingOptions options = null) => PdfDocumentFactory.Open(filePath, options);
|
||||
|
||||
/// <summary>
|
||||
/// Get the page with the specified page number.
|
||||
|
Reference in New Issue
Block a user