Forum Home
Welcome to the new pyForum.org.
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 https://bitbucket.org/speedbird/pyforum
C# and .Net code for selecting links from PDF pages
By: Saaspose
Rank: Starfleet Lieutenant, Junior Grade
Postings: 38
From:
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 = "http://api.saaspose.com/v1.0/pdf/input.pdf/pages/1/links/1";
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
publicenumLinkActionType
{
GoToAction,
GoToURIAction,
JavascriptAction,
LaunchAction,
NamedAction,
SubmitFormAction
}

//Here is the LinkHighlightingModeenum
publicenumLinkHighlightingMode
{
None,
Invert,
Outline,
Push,
Toggle
}

//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 = "http://api.saaspose.com/v1.0/pdf/input.pdf/pages/1/links/1"
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.

Welcome
System Announcements
Latest Posts
Support pyForum