ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.06k stars 235 forks source link

Hyperlinks removed when combining PDF's #307

Open vsosinga opened 1 year ago

vsosinga commented 1 year ago

Version 1.3.41

Problem When combining 1 or more PDF documents containing hyperlinks into a new PDF document the links are not clickable in the new document. Only links containing https:// are still clickable.

// Open the output document
var outputDocument = new PdfDocument();

// Open the document to import pages from it.
var inputDocument = PdfReader.Open(<input file>, PdfDocumentOpenMode.Import);

// Iterate pages
var count = inputDocument.PageCount;
for (var idx = 0; idx < count; idx++)
{
    // Get the page from the external document...
    var page = inputDocument.Pages[idx];

    // ...and add it to the output document.
    outputDocument.AddPage(page);
}

outputDocument.Save(<output file>);

Input: hyperlinks.pdf Output output.pdf