After concatenating two pdf files, the annotation links no longer work. I've tried updating the linkannotation.action as per your documentation, but the link does not work in the resulting file. I've attached the test files that I'm using and this is the code I've been working with. Can you tell me what I'm doing wrong? Thanks.
string inFile1 = "file1.pdf";
string inFile2 = "file2.pdf";
string outFile = "MergedFile.pdf";
FileStream fs1 = new FileStream(inFile1, System.IO.FileMode.Open);
FileStream fs2 = new FileStream(inFile2, System.IO.FileMode.Open);
FileStream OutFile = new FileStream(outFile, FileMode.Create);
PdfFileEditor editor = new PdfFileEditor();
editor.Concatenate(fs1, fs2, OutFile);
fs1.Close();
fs2.Close();
OutFile.Close();
FileStream MergedFS = new FileStream(outFile, FileMode.Open, FileAccess.ReadWrite);
Document pdfDocument = new Document(MergedFS);
Page DestPage = pdfDocument.Pages[1];
GoToAction newAction = new GoToAction(DestPage);
XYZExplicitDestination newDest = new Aspose.Pdf.InteractiveFeatures.XYZExplicitDestination(DestPage, 1, 1, 1);
newAction.Destination = newDest;
//loop through all the annotations - set the GoToAction to a link to the first page
foreach( Page p in pdfDocument.Pages)
{
foreach (LinkAnnotation annotation in p.Annotations)
{
annotation.Action = newAction;
}
}
pdfDocument.Save("MergedFileModified.pdf");
MergedFS.Close();