From 47bec784c051d8658804405dd615057cbe1f65fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?janne=2Em=C3=B6tt=C3=B6l=C3=A4?= Date: Wed, 24 Aug 2022 10:52:51 +0300 Subject: [PATCH] Fix PdfOutline.SplitDestinationPage(PdfArray) to correctly handle PdfInteger members in the PdfArray argument --- PdfSharpCore/Pdf/PdfOutline.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PdfSharpCore/Pdf/PdfOutline.cs b/PdfSharpCore/Pdf/PdfOutline.cs index 34b75b26..39f5b5f9 100644 --- a/PdfSharpCore/Pdf/PdfOutline.cs +++ b/PdfSharpCore/Pdf/PdfOutline.cs @@ -389,7 +389,9 @@ void SplitDestinationPage(PdfArray destination) // Reference: 8.2 Destination s #pragma warning disable 162 // The destination page may not yet transformed to PdfPage. - PdfDictionary destPage = (PdfDictionary)((PdfReference)(destination.Elements[0])).Value; + PdfDictionary destPage = (destination.Elements[0] is PdfInteger) ? + destination.Owner.Pages[((PdfInteger)destination.Elements[0]).Value] : + (PdfDictionary)((PdfReference)destination.Elements[0]).Value; PdfPage page = destPage as PdfPage; if (page == null) page = new PdfPage(destPage);