Tech Tip: Creating and removing hyperlinks in Write Pro
PRODUCT: 4D Write Pro | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 1, 2024
When exporting a 4D Write Pro document to PDF, all links in the document will become clickable, but you may want to have it look cleaner by having the link be a hyperlink instead.
To do so, you would use the WP SET LINK command somewhere within your application to have the hyperlink created. This command supports links to URLs, methods, and bookmarks, and you can apply the link to a range, an 4D WP element, or 4D WP document.
Below is an example method to have to have a hyperlink added to the footer of the document:
C_OBJECT($footer) $footer:=WP Get footer(WPArea;1) WP SET TEXT($footer; "4D US Website"; wk replace) WP SET LINK($footer; New object("url"; "https://us.4d.com/")) |
Please note that any special characters in a URL must be encoding, otherwise an error will occur. Links to 4D methods are removed once exported to HTML, MIME HTML, or .docx format.
To remove a link from the target object, you would use either WP RESET ATTRIBUTE or WP SET ATTRIBUTE. Below are the two ways to remove the hyperlink we had set up in the footer:
WP RESET ATTRIBUTES($footer; wk link url) //OR WP SET ATTRIBUTES($footer; wk link url; "") |
For more information on this command, please refer to the documentation here.