diff --git a/src/UglyToad.Pdf/Parser/PdfDocumentFactory.cs b/src/UglyToad.Pdf/Parser/PdfDocumentFactory.cs index e7864406..612d0812 100644 --- a/src/UglyToad.Pdf/Parser/PdfDocumentFactory.cs +++ b/src/UglyToad.Pdf/Parser/PdfDocumentFactory.cs @@ -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) diff --git a/src/UglyToad.Pdf/PdfDocument.cs b/src/UglyToad.Pdf/PdfDocument.cs index 7757e692..958cf16b 100644 --- a/src/UglyToad.Pdf/PdfDocument.cs +++ b/src/UglyToad.Pdf/PdfDocument.cs @@ -64,8 +64,20 @@ Pages = new Pages(log, Catalog, pdfObjectParser, pageFactory, reader, isLenientParsing); } + /// + /// Creates a for reading from the provided file bytes. + /// + /// The bytes of the PDF file. + /// Optional parameters controlling parsing. + /// A providing access to the file contents. 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); + /// + /// Opens a file and creates a for reading from the provided file path. + /// + /// The full path to the file location of the PDF file. + /// Optional parameters controlling parsing. + /// A providing access to the file contents. + public static PdfDocument Open(string filePath, ParsingOptions options = null) => PdfDocumentFactory.Open(filePath, options); /// /// Get the page with the specified page number.