HTML is to <a href="x">y</a>
as RTF is to _______
?
Asked
Active
Viewed 6.4k times
41

John
- 29,788
- 18
- 89
- 130

C. Dragon 76
- 9,882
- 9
- 34
- 41
-
2For the record, on Windows machines you can open WordPad and create a document with any formatting you want in it. Then save it. Close it in wordpad and open it in your favorite text editor. Unlike word, wordpad produces clean RTF. – Seth Spearman Jan 29 '16 at 14:53
-
2@SethSpearman Very good point - much cleaner. Unfortunately WordPad doesn't do hyperlinks. – David Thielen Apr 18 '19 at 22:58
4 Answers
42
The equivalent of the following HTML:
<a href="https://www.google.com">Google</a>
for an RTF file is:
{\field{\*\fldinst HYPERLINK "http://www.google.com/"}{\fldrslt Google}}
which results in a link:
but without additional style information, will appear unformatted:

0b10011
- 18,397
- 4
- 65
- 86

MikeyBunny
- 647
- 6
- 13
-
RTF field syntax is covered in the [specification](http://msdn.microsoft.com/en-us/library/aa140283%28v=office.10%29.aspx#rtfspec_30), and using the HYPERLINK instruction will give you a link. This [question](http://social.msdn.microsoft.com/forums/en-US/winforms/thread/e7969408-4ab4-4080-84f1-06620d130c31) shows a usage of the HYPERLINK instruction. – Keeblebrox Aug 18 '11 at 14:31
-
5I'm getting this: `{\field{\*\fldinst { HYPERLINK "http://www.google.com" }}{\fldrslt {http://www.google.com}}}` – ToastyMallows Jun 14 '13 at 19:55
-
Note: this does not include any hyperlink formatting (underline, coloured link). – Oliver Bock May 08 '14 at 08:04
-
Interestingly, it appears this is reusing (abusing?) field calculation to show different text. That is, these control words are typically used for things like showing the current time (`{\field{\*\fldinst time \\@ "h:mm AM/PM"}{\fldrslt 12:35 PM}}`). It looks like this is the de facto standard for doing this, though. – 0b10011 Oct 20 '20 at 16:35
7
This will show the hyperlink in the usual blue, with underline:
{\colortbl ;\red0\green0\blue238;}
{\field{\*\fldinst HYPERLINK "URL"}{\fldrslt{\ul\cf1Text to display}}}

Oliver Bock
- 4,829
- 5
- 38
- 62
-
By adding this text e.g RTFBox.Rtf = "{\colortbl ;\red0\green0\blue238;}{\field{\*\fldinst HYPERLINK \"URL\"}{\fldrslt{\ul\cf1Text to display}}}" an exception is thrown. Any suggestions? – raiserle Feb 23 '15 at 12:45
-
1
4
The last article works fine. I even took it further to display multiple links (and replaced \par to \line tags in order to stay in the same paragraph).
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22
{\field{\*\fldinst{HYPERLINK "http://www.google.com"}}{\fldrslt{\ul\cf1This is a Google URL}}}\f0\fs22\line
{\field{\*\fldinst{HYPERLINK "http://www.google.com"}}{\fldrslt{\ul\cf1This is a Second URL}}}\f0\fs22\line
}
1
I don't know much about what your trying to do, but If I open and save an rtf document, with just the http://www.google.com link in it, and view it with notepad I get this:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\f0\fs22{\field{\*\fldinst{HYPERLINK "http://www.google.com"}}{\fldrslt{\ul\cf1 http://www.google.com}}}\f0\fs22\par
\par
}
-
3Yeah, that's typical Word-crud though, isn't it... I'd imagine the `{\field{*\fldinst{HYPERLINK "http://www.google.com"}}{\fldrslt{http://www.google.com}}` bit is the only actually-important part. – bobince May 17 '10 at 16:02
-
Ya I just copied pasted out of notepad - not positive of exactly which part is the one needed - but thats most likely it. – Jack May 17 '10 at 16:07