DynaPDF WriteFText with links inside

For MBS Xojo Plugins 20.5pr3 we include the new DynaPDF library in version 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:

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[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 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.


Sounds cool!

Works perfectly fine. Great addition, thank you @Christian_Schmitz

1 Like

Welcome. Tell others and write blog posts :slight_smile:

1 Like

First I need to correct my typos: Munich instead of München in the German version of my footer. Good making screenshots: QA via Xojo Forum :slight_smile: