public static void Run() { try { // ExStart:SetTargetLink // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Load the PDF file Document document = new Document(dataDir + "UpdateLinks.pdf"); LinkAnnotation linkAnnot = (LinkAnnotation)document.Pages[1].Annotations[1]; GoToRemoteAction goToR = (GoToRemoteAction)linkAnnot.Action; // Next line update destination, do not update file goToR.Destination = new XYZExplicitDestination(2, 0, 0, 1.5); // Next line update file goToR.File = new FileSpecification(dataDir + "input.pdf"); dataDir = dataDir + "SetTargetLink_out_.pdf"; // Save the document with updated link document.Save(dataDir); // ExEnd:SetTargetLink Console.WriteLine("\nTarget link setup successfully.\nFile saved at " + dataDir); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal override Action Clone(IDocumentEssential owner) { PDFDictionary dict = new PDFDictionary(); dict.AddItem("Type", new PDFName("Action")); dict.AddItem("S", new PDFName("GoToR")); PDFDictionary fs = _dictionary["F"] as PDFDictionary; if (fs != null) { dict.AddItem("F", fs); } string[] keys = { "D", "NewWindow" }; for (int i = 0; i < keys.Length; ++i) { IPDFObject obj = _dictionary[keys[i]]; if (obj != null) { dict.AddItem(keys[i], obj.Clone()); } } GoToRemoteAction action = new GoToRemoteAction(dict, owner); IPDFObject next = _dictionary["Next"]; if (next != null) { for (int i = 0; i < Next.Count; ++i) { action.Next.Add(Next[i]); } } return(action); }