C. Dragon 76
C. Dragon 76

Reputation: 10072

What is the RTF syntax for a hyperlink?

HTML is to <a href="x">y</a> as RTF is to _______?

Upvotes: 42

Views: 71507

Answers (4)

MikeyBunny
MikeyBunny

Reputation: 657

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:

Google

but without additional style information, will appear unformatted:

Google

Upvotes: 43

Oliver Bock
Oliver Bock

Reputation: 5115

This will show the hyperlink in the usual blue, with underline:

{\colortbl ;\red0\green0\blue238;}
{\field{\*\fldinst HYPERLINK "URL"}{\fldrslt{\ul\cf1Text to display}}}

Upvotes: 8

Vlad P.
Vlad P.

Reputation: 99

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
}

Upvotes: 4

Jack
Jack

Reputation: 9252

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
}

Upvotes: 1

Related Questions