public static void Run() { try { // ExStart:GetHyperlinkDestinations // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Load the PDF file Document document = new Document(dataDir + "input.pdf"); // Traverse through all the page of PDF foreach (Aspose.Pdf.Page page in document.Pages) { // Get the link annotations from particular page AnnotationSelector selector = new AnnotationSelector(new Aspose.Pdf.Annotations.LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial)); page.Accept(selector); // Create list holding all the links IList list = selector.Selected; // Iterate through invidiaul item inside list foreach (LinkAnnotation a in list) { // Print the destination URL Console.WriteLine("\nDestination: " + (a.Action as Aspose.Pdf.Annotations.GoToURIAction).URI + "\n"); } } // ExEnd:GetHyperlinkDestinations } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Open document Document document = new Document(dataDir+ "input.pdf"); //Extract actions Page page = document.Pages[1]; AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial)); page.Accept(selector); IList list = selector.Selected; Annotation annotation = (Annotation)list[0]; //Save updated document document.Save(dataDir + "output.pdf"); }
public static void Run() { // ExStart:ExtractLinks // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Open document Document document = new Document(dataDir+ "ExtractLinks.pdf"); // Extract actions Page page = document.Pages[1]; AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial)); page.Accept(selector); IList list = selector.Selected; Annotation annotation = (Annotation)list[0]; dataDir = dataDir + "ExtractLinks_out.pdf"; // Save updated document document.Save(dataDir); // ExEnd:ExtractLinks Console.WriteLine("\nLinks extracted successfully.\nFile saved at " + dataDir); }
public static void Run() { // ExStart:ExtractLinks // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_LinksActions(); // Open document Document document = new Document(dataDir + "ExtractLinks.pdf"); // Extract actions Page page = document.Pages[1]; AnnotationSelector selector = new AnnotationSelector(new LinkAnnotation(page, Aspose.Pdf.Rectangle.Trivial)); page.Accept(selector); IList list = selector.Selected; Annotation annotation = (Annotation)list[0]; dataDir = dataDir + "ExtractLinks_out.pdf"; // Save updated document document.Save(dataDir); // ExEnd:ExtractLinks Console.WriteLine("\nLinks extracted successfully.\nFile saved at " + dataDir); }