Print2eDoc SDK
SDK for document conversion to PDF, PNG, JPEG, TIFF...
Compatibility
VB VB.NET VC++ C# Delphi

Adding Hyperlinks When Printing to PDF

Converted documents need not be boring. Make them active by adding hyperlinks.
By Shivaranjini M.
Important

This product has been discontinued. Please check our old products page for more information.

Hyperlinks are a great way of providing additional information or interactivity to PDF documents. Print2eDoc SDK provides several ways of adding hyperlinks when you convert documents. Hyperlinks in converted PDF document can link to:

  1. another location in the same document
  2. another file
  3. a URI (Uniform Resource Indicator)

To add such hyperlinks, you need to use the following methods of IgtPrint2eDoc interface.

  1. AddPDFLinkWithinDocument()
  2. AddPDFLinkToFile()
  3. AddPDFLinkToURI()

Link to Another Location in the Document

To add a link to another location in the same document, you need to specify link properties such as number of the page where the link is placed, number of the page that is linked, link border color, and link highlight style.

DestPage = 2;
BorderColor = Color.Green;
BorderWidth = TxgtLinkBorderWidth.bwThin;
HighlightMode = TxgtLinkHighlightMode.hmInvertContent;

PrinterObj.AddPDFLinkWithinDocument(
  Left, Top, Right, Bottom, // Coordinates of link area
  Page, // Number of the page where hyperlink needs to be added
  300,  // Y-coordinate of top-edge of viewer window on the page
  DestPage, // Number of the linked page
  Convert.ToUInt32( // Link border color
    ColorTranslator.ToOle(BorderColor)), 
  BorderWidth, 
  HighlightMode 
);

Link to Another File in the File System

When you add a hyperlink to a file, you can specify the file's relative or absolute path. In either case, the file should be available in the specified location when the user selects the hyperlink in a viewer application (such as AdobeĀ® Reader). Otherwise, the link will not work.

Page = 2;
BorderColor = Color.Blue;

PrinterObj.AddPDFLinkToFile(
   @"C:\Sample.xls",          // Path of linked file
   Left, Top, Right, Bottom,  // Coordinates of link area
   Page, // Number of the page where hyperlink needs to be added
   Convert.ToUInt32(          // Color of link
     ColorTranslator.ToOle(BorderColor)), 
   TxgtLinkBorderWidth.bwMedium,   // Link border width
   TxgtLinkHighlightMode.hmPushed  // Link highlight style
);

Link to a Website URL

Adding a link to a website location can be done in a similar manner. When you select a hyperlink to a URI on a PDF document, the viewer application makes the OS shell program (Windows Explorer or explorer.exe in Windows OSs) "resolve" the URI. Typically, this means that the website specified by the URI will be opened in a window of the default browser (IE, Firefox, or Opera).

Page = 3;
BorderColor = Color.Red;

PrinterObj.AddPDFLinkToURI(
  "www.gnostice.com", // URI
  Left, Top, Right, Bottom, // Coordinates of link area
  Page, // Number of the page where hyperlink needs to be added
  Convert.ToUInt32( // Link border color 
    ColorTranslator.ToOle(BorderColor)
                  ),
  TxgtLinkBorderWidth.bwThin,    // Link border width
  TxgtLinkHighlightMode.hmNone   // Link highlight style
);

After you add the hyperlinks, generate the output document.

PrinterObj.OutputDocumentFormat = TxgtDocumentFormat.PDF;
PrinterObj.ShowPreview = true;
PrinterObj.ShowSaveDialog = false;
PrinterObj.ShowSettingsDialog = true;
PrinterObj.ViewGeneratedDocuments = true;

// Print the document
PrinterObj.PrintDocument(@"C:\Input.doc"); 
Privacy | Legal | Feedback | Newsletter © 2002-2010 Gnostice Information Technologies Private Limited. All rights reserved.

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows users are advised to use Microsoft ClearType Tuning for optimal experience. Linux and other users can enable font smoothing, as supported by their OS. Also, please use the latest version of a standards-compliant browser such as Opera, FireFox, Chrome or Safari.