For MBS Xojo Plugins 20.5pr3 we include the new DynaPDF library in version 18.104.22.168. The WriteFText function can now create links within the text:
- to a web site
- to a named destination within the same PDF.
- to a named destination within another PDF document
You include \LK command in the text as command in your text and then specify the website. Within the brackets you specify 4 to 5 parameters:
- IsNamedDest (false or 0, true or 1)
- IsExternalLink (false or 0, true or 1)
- OpenInNewWindow (false or 0, true or 1)
- URL or name of a named destination (see .CreateNamedDest())
- PDF file in which the named destination is located
As you see you can specify booleans either as true/false or 1/0. Whitespace before/after is ignored. To give a few examples:
- \LK[false, TRUE, false, https://www.dynaforms.com]Test\EK#
- \LK[true, true, true, NameOfADestination, test.pdf]Test\EK#
- \LK[true, true, true, DestName, file name with spaces.pdf ]Test\EK#
You may want to use SetLinkHighlightMode function before calling WriteFText to set the highlight mode for clicking the link. You can have a border around the link defined with SetLineWidth or SetStrokeColor functions.
It may be good to combine this link feature with underline \ul# and then switch color with \FC and the right color. For blue, we use 16711680, which is 255 * 256 * 256 as returned by DynaPDF.RGB funtion:
\FC\ul#\LK[false, TRUE, false, https://www.dynaforms.com]Test\EK#\ul#\FC
Looks like this: Test. As you see we pick blue color, underline and the text with link inside. But on the end we turn underline off and set text color to black (0).
In Xojo use this with WriteFText and WriteFTextEx functions in DynaPDFMBS class. If you like to use styled text from TextArea control, please use ConvertStyledText function to get the text converted for WriteFText. Then you can add links after that and before you pass text to WriteFText funtions.