Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/foundation/src/PDFsharp/src/PdfSharp/Pdf.IO/PdfReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,17 @@ PdfDocument OpenFromStream(Stream stream, string? password, PdfDocumentOpenMode
// Reference.Values available by now: All trailers and cross-reference streams (which are not encrypted by definition).

// 2. Read the encryption dictionary, if existing.
if (_document.Trailer!.Elements[PdfTrailer.Keys.Encrypt] is PdfReference xrefEncrypt)
var trailer = _document.Trailer;
while (trailer != null)
{
var encrypt = parser.ReadIndirectObject(xrefEncrypt, null, true);
encrypt.Reference = xrefEncrypt;
xrefEncrypt.Value = encrypt;

_document.SecurityHandler.PrepareForReading();
if (_document.Trailer!.Elements[PdfTrailer.Keys.Encrypt] is PdfReference xrefEncrypt)
{
var encrypt = parser.ReadIndirectObject(xrefEncrypt, null, true);
encrypt.Reference = xrefEncrypt;
xrefEncrypt.Value = encrypt;

_document.SecurityHandler.PrepareForReading();
}
}
// References available by now: All references to file-level objects.
// Reference.Values available by now: All trailers and cross-reference streams and the encryption dictionary.
Expand Down