RTF bullet list example

It seems impossible to find a very simple working example for an RTF bullet list that looks like this:

  • Hello
  • Peace
    • Nested (but with a square, like a bullet, please)
    • Also enclosed (also square stamp)
  • and regular again

I tried to make a small sample using Word or TextEdit.app, but they produce a lot of garbage. Can anyone help?

+8
source share
4 answers

If you watched RTF in Word or Wordpad for a long time, you will find several lines that look like this:

{\ f2 {\ pntext \ 'B7 \ tab} {* \ pn \ pnlvlblt \ pnstart1 {\ pntxtb \' B7}} {\ ltrch This is a test.} \ Li720 \ ri0 \ sa0 \ sb0 \ jclisttab \ tx720 \ fi- 360 \ ql \ par}

{\ f2 {\ pntext \ 'B7 \ tab} {* \ pn \ pnlvlblt \ pnstart1 {\ pntxtb \' B7}} {\ ltrch Similarly.} \ Li720 \ ri0 \ sa0 \ sb0 \ jclisttab \ tx720 \ fi -360 \ ql \ par}

It will look like this:

  • This is a test.
  • Like this.

Nested lists are probably a little more complicated, but this is what you need if you don't have nested lists.

Now it depends on what you want to do with it. If you just show it, each tag means something useful. When I worked with lists, I converted them to HTML, so many formatting tags ( \li , \ri , \tx , etc.) I didnโ€™t need for my application because I just used <ol> , <ul> and <li> . The main thing to see is the \pnlvlblt tag, which makes this list a bulleted list. Also, \'B7 is the actual unicode tag for the bullet, and # xB7;

The most updated RTF specification is here:

https://www.microsoft.com/en-us/download/details.aspx?id=10725

+7
source

A simple, easy way is to use the characters as follows:

 \line \bullet Hello \line \bullet World \line \tab \bullet Nested (but with square as bullet please) \line \tab \u9632 Also nested (also square bullet) \line \tab and regular again 

After that, you could still analyze RTF back into the tag-based format with the inclusion of tags, since hierarchy information is provided by indentation.

As you can see, any use of unicode is fine. For Unicodes see this site .

For more information, be sure to check out the " Markers and Numbering" section in the RTF Specifications.

+3
source

I tried Saur anser, but in the line "Also nested (also a square bullet)" A was also covered by a square bullet. I donโ€™t know why this happened. โ–  lso nested (also square bullets)

I like to use line indentation commands, so if line wrapping occurs, the wrapped text also has indentation. When you do \ line \ tab, everything that ends on the printed page starts with the left margin, and not with your indented text. This is the system generated by System.Windows.Forms.RichTextBox that I inserted into (from MS-Word) and then called RichTextBox.RTF to get the code.

 {\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset2 Symbol;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fnil\fprq2\fcharset2 Wingdings;}{\f3\fnil\fcharset0 Microsoft Sans Serif;}} \viewkind4\uc1\pard\ltrpar\fi-360\li360\f0\fs20\'b7\tab\f1 Hello\par \f0\'b7\tab\f1 World\par \pard\ltrpar\fi-360\li990\f2\'a7\tab\f1 Nested (but with square as bullet please)\par \f2\'a7\tab\f1 Also nested (also square bullet)\par \pard\ltrpar\fi-360\li360\sa200\sl276\slmult1\f0\'b7\tab\f1 and regular again\lang1024\par \pard\ltrpar\lang1033\f3\fs17\par } 
+2
source

This is how I create a list of tokens:

 {\rtf1\ansi\deff0 {{\li0\pntext\pn\pnlvlblt\pntxtb\u8226?\tab}{This is item one}\par} {{\li0\pntext\pn\pnlvlblt\pntxtb\u8226?\tab}{This is item two}\par} {{\li400\pntext\pn\pnlvlblt\pntxtb\u9642?\tab}{This is item three}\par} {{\li400\pntext\pn\pnlvlblt\pntxtb\u9642?\tab}{This is item four}\par} {{\li0\pntext\pn\pnlvlblt\pntxtb\u8226?\tab}{This is item five}\par} } 

Displayed as:

enter image description here

Keep in mind that a multi-level list is not really threatening, like the one in a word. This is basically a normal indented list.

Explanation:

\li0 : \li0 0 (useful for multi-level lists)

\pntext : prefix for all numbered / bulleted paragraphs

\pn : enables paragraph numbering (also needed for bulleted lists)

\pnlvlblt : this paragraph is a bullet paragraph

\pntxtb : text before (icon)

\u8226? : Unicode character for marker

\u9642? Unicode character for a small black square

\tab : adds a tab after the icon

\par : end of paragraph

+1
source

All Articles