PdfPig icon indicating copy to clipboard operation
PdfPig copied to clipboard

Ability to update hyperlinks and annotations

Open icnocop opened this issue 5 years ago • 1 comments

I'd like the ability to update hyperlinks and annotations within a PdfDocument.

For example, given a hyperlink which points to an external resource, I want to change the hyperlink to point to a specific page within the same PDF instead.

Thank you.

            using (var document = PdfDocument.Open(pdfFilePath))
            {
                foreach (var page in document.GetPages())
                {
                    var annotations = page.ExperimentalAccess.GetAnnotations();
                    foreach (var annotation in annotations)
                    {
                        if (annotation.Uri == "file:///C:/Page2.html") // pseudo code
                        {
                            annotation.Uri = "Go To Page 2"; // pseudo code
                        }
                    }
                }
                document.Save(); // pseudo code
            }

icnocop avatar Apr 06 '20 08:04 icnocop

This isn't currently possible because it's only possible to create new documents rather than edit existing ones but there's an issue related to allowing editing #27 . I'll keep this issue open since it's part of the broader feature request.

EliotJones avatar Apr 08 '20 19:04 EliotJones

@icnocop do you found a solution ?

Zafoue avatar Sep 25 '23 12:09 Zafoue