Remove Additional Actions from a PDF

Question:
My PDF has an optional “additional-action” being triggered when I open it. How do I remove it?
Ex: Opening a PDF triggers an event to open a browser and load a URL.

Answer:
An additional-action defines an action to be taken in response to a “trigger event” affecting the document as a whole. These can be removed using the Apryse SDK SDF object. In the example below we get the SDFObject for a page and then check for the “AA” dictionary and if found remove it.

try
{
    // Open the PDF document
    using (PDFDoc doc = new PDFDoc($"{str_path}{input_file}.pdf"))
    {
        doc.InitSecurityHandler();

        // Access the page SDF object
        Obj page_sdf_obj = doc.GetPage(1).GetSDFObj();

        // Check if the SDFObj has an "Additional-Actions" entry
        if (page_sdf_obj.FindObj("AA") != null)
        {
            // Remove the "Additional-Actions" dictionary
            page_sdf_obj.Erase("AA");
            Console.WriteLine("Additional-Actions dictionary removed.");
        }
        else
        {
            Console.WriteLine("No Additional-Actions dictionary found.");
        }

        // Save the modified document
        doc.Save($"{str_path}{input_file}.output.pdf", SDFDoc.SaveOptions.e_remove_unused);
        Console.WriteLine("Document saved successfully.");
    }
}
catch (PDFNetException e)
{
    Console.WriteLine(e.Message);
}
finally
{
    // Terminate the SDK
    PDFNet.Terminate();
}