Select PDF Text and Create Hyperlinks with the Acrobat SDK in C++
Question details
Find out how to select PDF text and create hyperlinks programmatically using the Adobe Acrobat SDK in C++.

- Product
- Adobe Acrobat SDK
- Device & OS
- not provided
- Scenario
- A developer wants to handle arrow or rectangular text selection and add links to a PDF from C++ or Visual C++.
- Observed behavior
- The goal is to obtain the relevant text or page coordinates and create a link annotation with a document destination or URL.
Install the Acrobat SDK and review its documentation and samples for your target Acrobat version. Identify whether you are building an Acrobat plug-in or an external application, because their available interfaces differ.
Use Acrobat SDK Selection and Link Annotation APIs
Use this approach when building an Acrobat plug-in that can access the required viewer and PDF document APIs.
The SDK separates viewer interaction and selection from PDF annotation and action creation. Check the API reference for the interfaces supported by your Acrobat version and integration type.
Open the Acrobat SDK documentation and samples, and look for plug-in examples covering the active document, text selection, annotations, and actions.
In your plug-in, use the documented AV interfaces to access the active document and its current selection. For custom arrow or rectangular selection behavior, consult the SDK's selection and event-handling documentation.
Use the selection or page text information to determine the page and bounding area for the link. Convert viewer coordinates to PDF page coordinates where necessary, accounting for page rotation and text spanning multiple lines or pages.
Use the documented PD annotation APIs to create a link annotation on the relevant page, then assign a document destination or URI action to it.
Save the PDF through the supported SDK interface, reopen it in Acrobat, and click the link to verify its target and clickable area.

Work with PDF and Office Files in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and support for common file formats, making it easy to move everyday document work. It does not replace the Acrobat SDK for C++ programming.

Frequently Asked Questions
Can an external C++ application use every Acrobat plug-in API?
No. External applications and Acrobat plug-ins use different integration interfaces. Check the Acrobat SDK documentation for the API and integration type you plan to use.
How do I make a PDF link open a web page?
Create a link annotation in the desired page area and assign it a URI action using the applicable PD APIs documented in the Acrobat SDK.
How do I link to another location in the same PDF?
Create a link annotation and assign a destination that identifies the target location in the document. Consult the SDK's destination and action documentation for your Acrobat version.
What if selected text spans multiple lines or pages?
Determine the relevant page coordinates for each portion of the selection and create suitable link areas on the affected pages. Test the clickable areas after saving the PDF.




