DynaPDF WriteFText with links inside
For the next pre-release we include the new DynaPDF library in version 4.0.43.121. 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 DynaPDF.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[0,1,0,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 DynaPDF.SetLinkHighlightMode function before calling DynaPDF.WriteFText to set the highlight mode for clicking the link. You can have a border around the link defined with DynaPDF.SetLineWidth or DynaPDF.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[16711680]\ul#\LK[false, TRUE, false, https://www.dynaforms.com]Test\EK#\ul#\FC[0]
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 FileMaker use this with DynaPDF.WriteFText or DynaPDF.WriteFTextEx functions. For DynaPDF.WriteStyledText, this won't work as we escape the backslash. So use a placeholder like "$link$", call DynaPDF.ConvertStyledText to convert text and then replace the placeholder with the command above.
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.