Skip to content
galkahana edited this page Jul 16, 2011 · 5 revisions

Defining links in PDF ties a certain area in a document to a link. Pressing that area leads to the target of the link.

The PDFWriter class allows you to add link through calling the following method:

EStatusCode AttachURLLinktoCurrentPage(const wstring& inURL,const PDFRectangle& inLinkClickArea);

The AttachURLLinkToCurrentPage method will attach a certain area in a page to the input URL. The page which the link will be created on is the next page that will be written (By calling either WritePage or WritePageAndRelease).

It accepts two parameters:

  • inURL a string URL.
  • inLinkClickArea a rectangle defining the area where in a click would trigger accessing the URL. (on most system this would mean that a browser window is opened).

Note that PDF does not contain a native method for attaching links to text. Hence to place a link on a text you must posit the link on the area of the text.

The following is a simple usage example:

pdfWriter.AttachURLLinktoCurrentPage(L"http://www.soundcloud.com",PDFRectangle(90.024,200,367.524,375));

This call attached the URL www.soundcloud.com, to the area defined by the rectangle [90.024, 200, 367.524, 375].

For a complete code example see Links Test

Clone this wiki locally