Forum Home
Welcome to the new
A message board system written in pure python using the web2py framework.
pyForum is sporting a new, completely re-designed interface and back-end
Download pyForum from
C# and .Net code for selecting links from PDF pages
By: Saaspose
Rank: Starfleet Lieutenant, Junior Grade
Postings: 38
Posted: Sun, 03 March, 2013 - 05:52 PM

This technical tip allows developers to get selected link on a page in PDF file using Saaspose.Pdf REST API in your .NET applications. Saaspose.Pdf is a REST API to create, edit & manipulate PDF files. It also convert PDF file to DOC, DOCX, HTML, XPS, TIFF etc. It is platform independent REST API & working with web, desktop, mobile or cloud applications alike. Some important steps for performing this task are to build URI to get selected link on a page, Parse the json string to JObject, Deserializes the JSON to an object and the classes used in this process are given in detail.

Sample Code forGet Selected Link on a Page in PDF File

[C# Code]

//build URI to get selected link on a page
stringstrURI = "";
stringsignedURI = Sign(strURI);
Stream responseStream = ProcessCommand(signedURI, "GET");
StreamReader reader = new StreamReader(responseStream);
stringstrJSON = reader.ReadToEnd();
//Parse the json string to JObject
JObjectparsedJSON = JObject.Parse(strJSON);
//Deserializes the JSON to a object.
PdfLinkResponsepdfLinkResponse = JsonConvert.DeserializeObject (parsedJSON.ToString());
Link tempLink = pdfLinkResponse.Link;

//Here is the BaseResponse class
public class BaseResponse
publicBaseResponse() { }
public string Code { get; set; }
public string Status { get; set; }

//Here is the PdfLinkResponse class
public class PdfLinkResponse : BaseResponse
publicPdfLinkResponse() { }
public Link Link { get; set; }

//Here is the LinkResponse class
public class LinkResponse
public string Href { get; set; }
public string Rel { get; set; }
public string Title { get; set; }
public string Type { get; set; }

//Here is the Link class
public class Link
public Link() { }
publicLinkActionTypeActionType { get; set; }
public string Action { get; set; }
publicLinkHighlightingMode Highlighting { get; set; }
public Color Color { get; set; }

//Here is the LinkActionTypeenum

//Here is the LinkHighlightingModeenum

//Here is the Color class
public class Color
public Color() { }
public List Links { get; set; }
publicint A { get; set; }
publicint B { get; set; }
publicint G { get; set; }
publicint R { get; set; }

[VB.NET Code]

'build URI to get selected link on a page
Dim strURI As String = ""
Dim signedURI As String = Sign(strURI)
Dim responseStream As Stream = ProcessCommand(signedURI, "GET")
Dim reader As New StreamReader(responseStream)
Dim strJSON As String = reader.ReadToEnd()
'Parse the json string to JObject
Dim parsedJSON As JObject = JObject.Parse(strJSON)
'Deserializes the JSON to a object.
Dim pdfLinkResponse As PdfLinkResponse = JsonConvert.DeserializeObject(Of PdfLinkResponse)(parsedJSON.ToString())
Dim tempLink As Link = pdfLinkResponse.Link

This topic contains no responses.

System Announcements
Latest Posts
Support pyForum