From 2c41adef9a794d7891df62166e2ef3d38ac26c3d Mon Sep 17 00:00:00 2001 From: Piotr Pietrzyk <88336224+PetoMPP@users.noreply.github.com> Date: Tue, 17 Jun 2025 08:58:51 +0200 Subject: [PATCH 1/2] Keep /A element when reading PdfOutline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change updates PdfSharp’s outline and annotation parsing to preserve the /A (Action) dictionary even when a /Dest is also present. Previously, PdfSharp would discard the /A entry when replacing it with a /Dest, which resulted in the loss of important behaviors such as JavaScript execution or chained /Next actions. In many PDFs — especially those created with Adobe Acrobat or CAD tools — outlines and annotations include compound actions like: ```pdf Kopiuj Edytuj /A << /S /GoTo /D [...] /Next << /S /JavaScript /JS (...) >> >> ``` Discarding the action breaks interactive features such as: - Highlighting fields (e.g. flashing red rectangles) - Dynamic form behaviors - Any action-driven JavaScript logic Benefits: - Preserves full PDF behavior and interactivity - Aligns with the PDF spec, which allows both /A and /Dest - Enables advanced use cases like viewer development, script analysis, or validation This change is backward-compatible and improves PdfSharp’s ability to work with professionally authored interactive PDFs. --- src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs b/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs index c5989ff1..f8369d84 100644 --- a/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs +++ b/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs @@ -332,8 +332,7 @@ void Initialize() destArray = dest as PdfArray; if (destArray != null) { - // Replace Action with /Dest entry. - Elements.Remove(Keys.A); + // Add /Dest entry keeping existing action, as it can contain additional entries within action, like /Next Elements.Add(Keys.Dest, destArray); SplitDestinationPage(destArray); } From 77e146f25af8af2c2f5df95c32caebd78ddfbea3 Mon Sep 17 00:00:00 2001 From: Piotr Pietrzyk <88336224+PetoMPP@users.noreply.github.com> Date: Tue, 17 Jun 2025 10:51:12 +0200 Subject: [PATCH 2/2] Add missing case --- src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs b/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs index f8369d84..cf022c23 100644 --- a/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs +++ b/src/foundation/src/PDFsharp/src/PdfSharp/Pdf/PdfOutline.cs @@ -358,8 +358,7 @@ void Initialize() } if (destArray != null) { - // Replace Action with /Dest entry. - Elements.Remove(Keys.A); + // Add /Dest entry keeping existing action, as it can contain additional entries within action, like /Next Elements.Add(Keys.Dest, destArray); SplitDestinationPage(destArray); }