Export Selected Link on a Page in PDF File in .NET Applications


SUBMITTED BY: Guest

DATE: June 12, 2013, 1:19 a.m.

FORMAT: C#

SIZE: 3.3 kB

HITS: 1104

  1. [C# Code]
  2. //build URI to get selected link on a page
  3. string strURI = "http://api.saaspose.com/v1.0/pdf/input.pdf/pages/1/links/1";
  4. string signedURI = Sign(strURI);
  5. Stream responseStream = ProcessCommand(signedURI, "GET");
  6. StreamReader reader = new StreamReader(responseStream);
  7. string strJSON = reader.ReadToEnd();
  8. //Parse the json string to JObject
  9. JObject parsedJSON = JObject.Parse(strJSON);
  10. //Deserializes the JSON to a object.
  11. PdfLinkResponse pdfLinkResponse = JsonConvert.DeserializeObject<PdfLinkResponse>(parsedJSON.ToString());
  12. Link tempLink = pdfLinkResponse.Link;
  13. //Here is the BaseResponse class
  14. public class BaseResponse
  15. {
  16. public BaseResponse() { }
  17. public string Code { get; set; }
  18. public string Status { get; set; }
  19. }
  20. //Here is the PdfLinkResponse class
  21. public class PdfLinkResponse : BaseResponse
  22. {
  23. public PdfLinkResponse() { }
  24. public Link Link { get; set; }
  25. }
  26. //Here is the LinkResponse class
  27. public class LinkResponse
  28. {
  29. public string Href { get; set; }
  30. public string Rel { get; set; }
  31. public string Title { get; set; }
  32. public string Type { get; set; }
  33. }
  34. //Here is the Link class
  35. public class Link
  36. {
  37. public Link() { }
  38. public LinkActionType ActionType { get; set; }
  39. public string Action { get; set; }
  40. public LinkHighlightingMode Highlighting { get; set; }
  41. public Color Color { get; set; }
  42. }
  43. //Here is the LinkActionType enum
  44. public enum LinkActionType
  45. {
  46. GoToAction,
  47. GoToURIAction,
  48. JavascriptAction,
  49. LaunchAction,
  50. NamedAction,
  51. SubmitFormAction
  52. }
  53. //Here is the LinkHighlightingMode enum
  54. public enum LinkHighlightingMode
  55. {
  56. None,
  57. Invert,
  58. Outline,
  59. Push,
  60. Toggle
  61. }
  62. //Here is the Color class
  63. public class Color
  64. {
  65. public Color() { }
  66. public List<LinkResponse> Links { get; set; }
  67. public int A { get; set; }
  68. public int B { get; set; }
  69. public int G { get; set; }
  70. public int R { get; set; }
  71. }
  72. [VB.NET Code]
  73. 'build URI to get selected link on a page
  74. Dim strURI As String = "http://api.saaspose.com/v1.0/pdf/input.pdf/pages/1/links/1"
  75. Dim signedURI As String = Sign(strURI)
  76. Dim responseStream As Stream = ProcessCommand(signedURI, "GET")
  77. Dim reader As New StreamReader(responseStream)
  78. Dim strJSON As String = reader.ReadToEnd()
  79. 'Parse the json string to JObject
  80. Dim parsedJSON As JObject = JObject.Parse(strJSON)
  81. 'Deserializes the JSON to a object.
  82. Dim pdfLinkResponse As PdfLinkResponse = JsonConvert.DeserializeObject(Of PdfLinkResponse)(parsedJSON.ToString())
  83. Dim tempLink As Link = pdfLinkResponse.Link

comments powered by Disqus