private static LinkInfo getFirstLink(PdfDocument pdf) { int i = 0; foreach (PdfWidget widget in pdf.GetWidgets()) { PdfActionArea actionArea = widget as PdfActionArea; if (actionArea != null) { PdfGoToAction linkAction = actionArea.Action as PdfGoToAction; if (linkAction != null) { // lets ignore links which point to an absent page if (linkAction.View.Page != null) { return(new LinkInfo(pdf, actionArea, i)); } } } i++; } return(null); }
public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. using (PdfDocument pdf = new PdfDocument()) { PdfUriAction uriAction = pdf.CreateHyperlinkAction(new Uri("http://www.google.com")); PdfActionArea annotation = pdf.Pages[0].AddActionArea(10, 50, 100, 100, uriAction); annotation.BorderColor = new PdfRgbColor(0, 0, 0); annotation.BorderDashPattern = new PdfDashPattern(new float[] { 3, 2 }); pdf.Save("UriAction.pdf"); } Process.Start("UriAction.pdf"); }
public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. using (PdfDocument pdf = new PdfDocument()) { PdfUriAction uriAction = pdf.CreateHyperlinkAction(new Uri("http://www.google.com")); PdfActionArea annotation = pdf.Pages[0].AddActionArea(10, 50, 100, 100, uriAction); annotation.Border.Color = new PdfRgbColor(0, 0, 0); annotation.Border.DashPattern = new PdfDashPattern(new float[] { 3, 2 }); annotation.Border.Width = 1; annotation.Border.Style = PdfMarkerLineStyle.Dashed; pdf.Save("UriAction.pdf"); } Console.WriteLine($"The output is located in {Environment.CurrentDirectory}"); }
public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. using (PdfDocument pdf = new PdfDocument()) { PdfPage secondPage = pdf.AddPage(); secondPage.Canvas.DrawString(10, 300, "Go-to action target"); PdfGoToAction action = pdf.CreateGoToPageAction(1, 300); PdfActionArea annotation = pdf.Pages[0].AddActionArea(10, 50, 100, 30, action); annotation.BorderColor = new PdfRgbColor(255, 0, 0); annotation.BorderDashPattern = new PdfDashPattern(new float[] { 3, 2 }); pdf.Save("GoToAction.pdf"); } Process.Start("GoToAction.pdf"); }
public LinkInfo(PdfDocument pdf, PdfActionArea actionArea, int index) { if (pdf == null) { throw new ArgumentNullException("document"); } if (actionArea == null) { throw new ArgumentNullException("actionArea"); } Action = actionArea.Action as PdfGoToAction; if (Action == null) { throw new ArgumentException("Action area doesn't contain link", "actionArea"); } Index = index; Bounds = actionArea.BoundingBox; OwnerPageNumber = pdf.IndexOf(actionArea.Owner); TargetPageNumber = pdf.IndexOf(Action.View.Page); }
public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. using (PdfDocument pdf = new PdfDocument()) { PdfPage secondPage = pdf.AddPage(); secondPage.Canvas.DrawString(10, 300, "Go-to action target"); PdfGoToAction action = pdf.CreateGoToPageAction(1, 300); PdfActionArea annotation = pdf.Pages[0].AddActionArea(10, 50, 100, 30, action); annotation.Border.Color = new PdfRgbColor(255, 0, 0); annotation.Border.DashPattern = new PdfDashPattern(new float[] { 3, 2 }); annotation.Border.Width = 1; annotation.Border.Style = PdfMarkerLineStyle.Dashed; pdf.Save("GoToAction.pdf"); } Console.WriteLine($"The output is located in {Environment.CurrentDirectory}"); }