We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extracting bookmark content containing bullets

Hi Support,

Please find attached a sample project I created.
button1 takes some rtf text and paste it in second cell of the table, it also displays it in a ms richtextbox

button2 tries to extract the content of the bookmark. I’m using the ExtractConent from the following link
https://docs.aspose.com/words/net/how-to-extract-selected-content-between-nodes-in-a-document/

the function is returning empty string instead of retuning the bulleted paragraph

Please advise

Hi Akram,

Thanks for your inquiry. In your case, I suggest you please pass the third parameter’s value as ‘True’ in ExtractContent method. This will fix the issue which you are facing. See the following code snippet.

Dim bkm As Bookmark = aspdoc.Range.Bookmarks(BookmarkName)
Dim startNode As Node = bkm.BookmarkStart
Dim endNode As Node = bkm.BookmarkEnd
Dim nodes As ArrayList = ExtractContent(startNode, endNode, True)
Dim newDoc As Document = GenerateDocument(aspdoc, nodes)

Please let us know if you have any more queries.

Hi Tahir,

I tried this and I’m getting something back this time but the return result is not what I’m expecting.

it seems it’s returning everything around the bookmark, including the cell, row and table.

This is a good progress to what we had before but I see a slight problem.
the returned rtf text loses the bulleting attributes (if I hit enter on the last line in the ritchtextbox control there is no new bullets created)

the original rtf is:

{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{
\fonttbl
{\f0\froman\fprq2\fcharset2 Symbol;}
{\f1\froman\fprq2\fcharset0 Times New Roman;}
}
\viewkind4\uc1\pard\ltrpar\li60\sl240\slmult1\f0\fs28’b7\tab\b\f1 POLYPOID FRAGMENT OF COLONIC-TYPE MUCOSA WITH NON SPECIFIC CHRONIC INFLAMMATION. asdfasdf fasdf fasdfa asdfas\par
\lang1024\b0\f0’b7\tab\b\f1 NO DYSPLASIA IDENTIFIED.\par
\b0\f0’b7\tab\b\f1 Test\par
\b0\f0’b7\tab\b\f1 ttttt\par
\pard\ltrpar\sl240\slmult1\par
}

while the extracted rtf is:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{
\fonttbl
{\f0\froman\fprq2\fcharset0 Times New Roman;}
{\f1\fnil\fcharset2 Symbol;}
}
\viewkind4\uc1\pard{\pntext\f1’B7\tab}{*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb’B7}}\li60\b\f0\fs28 POLYPOID FRAGMENT OF COLONIC-TYPE MUCOSA WITH NON SPECIFIC CHRONIC INFLAMMATION. asdfasdf fasdf fasdfa asdfas\par
{\pntext\f1’B7\tab}NO DYSPLASIA IDENTIFIED.\par
{\pntext\f1’B7\tab}Test\par
{\pntext\f1’B7\tab}ttttt\par
\pard\lang1024\par
}

Hi Akram,

Thanks for your inquiry. You are getting this RTF from RichTextBox.Rtf which is incorrect. Aspose.Words saves the RTF correctly. I have modified your ExtractRTF method. See the following highlighted code snippet. Please let us know if you have any more queries.

Private Function ExtractRTF(ByVal BookmarkName As String) As String
Dim bkm As Bookmark = aspdoc.Range.Bookmarks(BookmarkName)
Dim startNode As Node = bkm.BookmarkStart
Dim endNode As Node = bkm.BookmarkEnd
Dim nodes As ArrayList = ExtractContent(startNode, endNode, True)
Dim newDoc As Document = GenerateDocument(aspdoc, nodes)
Dim newbuilder As New DocumentBuilder(newDoc)
newbuilder.MoveToDocumentEnd()
If newDoc.LastSection.Body.LastParagraph.IsListItem Then
If newDoc.LastSection.Body.LastParagraph.ToString.Trim.Equals("") Then
newDoc.LastSection.Body.LastParagraph.Remove()
End If
End If
Dim rtb As New RichTextBox
Dim rtfstring As String
rtfstring = getString(newDoc, Aspose.Words.SaveFormat.Rtf)
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(rtfstring)
Using stream As New MemoryStream(byteArray)
rtb.LoadFile(stream, RichTextBoxStreamType.RichText)
End Using
ExtractRTF = rtfstring
End Function

still not working. If I load the rtfstring in a ritchtextbox the paragraph is not bulleted, even when you save the output to a .rtf file and open it in wordpad it doesnt work. the only place where it keeps the bullets is when opening the .rtf file in ms word

here is the rtf from the code you changed

{\rtf1\ansi\ansicpg1252\uc0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deff0\adeff0

{\fonttbl
{\f0\froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}
{\f1\froman\fcharset2\fprq2{*\panose 05050102010706020507}Symbol;}
{\f2\fswiss\fcharset0\fprq2{*\panose 020b0604020202020204}Arial;}
{\f3\fswiss\fcharset0\fprq2{*\panose 020f0502020204030204}Calibri;}
{\f4\fswiss\fcharset0\fprq2{*\panose 020f0302020204030204}Calibri Light;}
{\f5\fnil\fcharset0 Cambria Math;}}

{\colortbl;}

{\stylesheet
{\s0\snext0\sqformat\spriority0\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\afs24\ltrch\fs24 Normal;}
{*\cs10\additive\ssemihidden\spriority0 Default Paragraph Font;}
{\s15\snext15\styrsid12744936\sqformat\spriority0\sa0\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\afs24\ltrch\fs24\f0 Normal_0;}
{\s16\snext16\styrsid8412110\sqformat\spriority0\sa0\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\alang1024\afs24\ltrch\fs24\lang1024\langnp1024\langfe1024\langfenp1024\f0 Normal_1;}}
{*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelstartat1\levelold1\levelprev0\levelprevspace0\levelindent0\levelspace0{\leveltext\leveltemplateid0 '01’b7;}{\levelnumbers;}\levelfollow0\rtlch
\ltrch\f1\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid1 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid2 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid3 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid4 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid5 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid6 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid7 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelstartat1{\leveltext\leveltemplateid8 '00;}{\levelnumbers;}\levelfollow0\li0\lin0}
\listid1}
}
{*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}}

{*\rsidtbl\rsid9843944\rsid12744936}

{*\generator Aspose.Words for .NET 14.6.0.0;}

{\info\version1\edmins0\nofpages1\nofwords0\nofchars0\nofcharsws0}

{\mmathPr\mbrkBin0\mbrkBinSub0\mdefJc1\mdispDef1\minterSp0\mintLim0\mintraSp0\mlMargin0\mmathFont0\mnaryLim1\mpostSp0\mpreSp0\mrMargin0\msmallFrac0\mwrapIndent1440\mwrapRight0}
\deflang1033\deflangfe2052\adeflang1025\jexpand\showxmlerrors1\validatexml1{*\wgrffmtfilter 013f}\viewkind1\viewscale100\fet0\ftnbj\aenddoc\ftnrstcont\aftnrstcont\ftnnar\aftnnrlc\widowctrl\nospaceforul\nolnhtadjtbl\alntblind\lyttblrtgr\dntblnsbdb
\noxlattoyen\wrppunct\nobrkwrptbl\expshrtn\snaptogridincell\asianbrkrule\htmautsp\noultrlspc\useltbaln\splytwnine\ftnlytwnine\lytcalctblwd\allowfieldendsel\lnbrkrule\nouicompat\nofeaturethrottle1\formshade\nojkernpunct\dghspace180\dgvspace180\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1
\dgmargin\pgbrdrhead\pgbrdrfoot

\sectd\sectlinegrid360\pgwsxn12240\pghsxn15840\marglsxn1800\margrsxn1800\margtsxn1440\margbsxn1440\guttersxn0\headery708\footery708\colsx708\ltrsect

\pard\plain\itap0\s15\ls1\sa0\pararsid9843944\ltrpar\li60\lin60\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\afs24\ltrch\fs24\f0{\listtext\pard\plain\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql\faauto\rtlch\ab0\af0\alang1025\afs24\ltrch\fs28\lang1033\langnp1033\langfe1033\langfenp1033\f1\insrsid12744936\cs10 'b7\tab }
{*\bkmkstart Bookmark1}
{\rtlch\af0\alang1025\afs24\ltrch\b\fs28\lang1033\langnp1033\langfe1033\langfenp1033\f0\cs10 POLYPOID FRAGMENT OF COLONIC-TYPE MUCOSA WITH NON SPECIFIC CHRONIC INFLAMMATION. asdfasdf fasdf fasdfa asdfas}{\rtlch\ab0\af0\alang1025\afs24\ltrch\b\i0\fs28\lang1033\langnp1033\langfe1033\langfenp1033\f0\insrsid12744936\cs10
\ulnone\par}

\pard\plain\itap0\s16\ilvl0\ls1\sa0\ltrpar\li60\lin60\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\alang1024\afs24\ltrch\fs24\lang1024\langnp1024\langfe1024\langfenp1024\f0{\listtext\pard\plain\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql
\faauto\rtlch\af0\alang1024\afs24\ltrch\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f1\cs10 'b7\tab }
{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10 NO DYSPLASIA IDENTIFIED.}{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10\par}

\pard\plain\itap0\s16\ilvl0\ls1\sa0\ltrpar\li60\lin60\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\alang1024\afs24\ltrch\fs24\lang1024\langnp1024\langfe1024\langfenp1024\f0{\listtext\pard\plain\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql
\faauto\rtlch\af0\alang1024\afs24\ltrch\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f1\cs10 'b7\tab }
{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10 Test}{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10\par}

\pard\plain\itap0\s16\ilvl0\ls1\sa0\ltrpar\li60\lin60\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\alang1024\afs24\ltrch\fs24\lang1024\langnp1024\langfe1024\langfenp1024\f0{\listtext\pard\plain\aspalpha\aspnum\adjustright\ltrpar\li0\lin0\ri0\rin0\ql
\faauto\rtlch\af0\alang1024\afs24\ltrch\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f1\cs10 'b7\tab }
{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10 ttttt}{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10\par}

\pard\plain\itap0\s16\sa0\ltrpar\li0\lin0\ri0\rin0\ql\faauto\sl240\slmult1\rtlch\af0\alang1024\afs24\ltrch\fs24\lang1024\langnp1024\langfe1024\langfenp1024\f0{*\bkmkend Bookmark1}
{\rtlch\af0\alang1024\afs24\ltrch\b\fs28\lang1024\langnp1024\langfe1024\langfenp1024\f0\cs10\noproof\par}

{*\latentstyles\lsdstimax267\lsdlockeddef0\lsdsemihiddendef0\lsdunhideuseddef0\lsdqformatdef0\lsdprioritydef0{\lsdlockedexcept\lsdqformat1 Normal;\lsdqformat1 heading 1;\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 2;\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 3;
\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 4;\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 5;\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 6;\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 7;\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 8;
\lsdsemihidden1\lsdunhideused1\lsdqformat1 heading 9;\lsdsemihidden1\lsdunhideused1\lsdqformat1 caption;\lsdqformat1 Title;\lsdqformat1 Subtitle;\lsdqformat1 Strong;\lsdqformat1 Emphasis;\lsdsemihidden1\lsdpriority99 Placeholder Text;\lsdqformat1\lsdpriority1 No Spacing;
\lsdpriority60 Light Shading;\lsdpriority61 Light List;\lsdpriority62 Light Grid;\lsdpriority63 Medium Shading 1;\lsdpriority64 Medium Shading 2;\lsdpriority65 Medium List 1;\lsdpriority66 Medium List 2;\lsdpriority67 Medium Grid 1;\lsdpriority68 Medium Grid 2;
\lsdpriority69 Medium Grid 3;\lsdpriority70 Dark List;\lsdpriority71 Colorful Shading;\lsdpriority72 Colorful List;\lsdpriority73 Colorful Grid;\lsdpriority60 Light Shading Accent 1;\lsdpriority61 Light List Accent 1;\lsdpriority62 Light Grid Accent 1;\lsdpriority63 Medium Shading 1 Accent 1;
\lsdpriority64 Medium Shading 2 Accent 1;\lsdpriority65 Medium List 1 Accent 1;\lsdsemihidden1\lsdpriority99 Revision;\lsdqformat1\lsdpriority34 List Paragraph;\lsdqformat1\lsdpriority29 Quote;\lsdqformat1\lsdpriority30 Intense Quote;\lsdpriority66 Medium List 2 Accent 1;
\lsdpriority67 Medium Grid 1 Accent 1;\lsdpriority68 Medium Grid 2 Accent 1;\lsdpriority69 Medium Grid 3 Accent 1;\lsdpriority70 Dark List Accent 1;\lsdpriority71 Colorful Shading Accent 1;\lsdpriority72 Colorful List Accent 1;\lsdpriority73 Colorful Grid Accent 1;
\lsdpriority60 Light Shading Accent 2;\lsdpriority61 Light List Accent 2;\lsdpriority62 Light Grid Accent 2;\lsdpriority63 Medium Shading 1 Accent 2;\lsdpriority64 Medium Shading 2 Accent 2;\lsdpriority65 Medium List 1 Accent 2;\lsdpriority66 Medium List 2 Accent 2;
\lsdpriority67 Medium Grid 1 Accent 2;\lsdpriority68 Medium Grid 2 Accent 2;\lsdpriority69 Medium Grid 3 Accent 2;\lsdpriority70 Dark List Accent 2;\lsdpriority71 Colorful Shading Accent 2;\lsdpriority72 Colorful List Accent 2;\lsdpriority73 Colorful Grid Accent 2;
\lsdpriority60 Light Shading Accent 3;\lsdpriority61 Light List Accent 3;\lsdpriority62 Light Grid Accent 3;\lsdpriority63 Medium Shading 1 Accent 3;\lsdpriority64 Medium Shading 2 Accent 3;\lsdpriority65 Medium List 1 Accent 3;\lsdpriority66 Medium List 2 Accent 3;
\lsdpriority67 Medium Grid 1 Accent 3;\lsdpriority68 Medium Grid 2 Accent 3;\lsdpriority69 Medium Grid 3 Accent 3;\lsdpriority70 Dark List Accent 3;\lsdpriority71 Colorful Shading Accent 3;\lsdpriority72 Colorful List Accent 3;\lsdpriority73 Colorful Grid Accent 3;
\lsdpriority60 Light Shading Accent 4;\lsdpriority61 Light List Accent 4;\lsdpriority62 Light Grid Accent 4;\lsdpriority63 Medium Shading 1 Accent 4;\lsdpriority64 Medium Shading 2 Accent 4;\lsdpriority65 Medium List 1 Accent 4;\lsdpriority66 Medium List 2 Accent 4;
\lsdpriority67 Medium Grid 1 Accent 4;\lsdpriority68 Medium Grid 2 Accent 4;\lsdpriority69 Medium Grid 3 Accent 4;\lsdpriority70 Dark List Accent 4;\lsdpriority71 Colorful Shading Accent 4;\lsdpriority72 Colorful List Accent 4;\lsdpriority73 Colorful Grid Accent 4;
\lsdpriority60 Light Shading Accent 5;\lsdpriority61 Light List Accent 5;\lsdpriority62 Light Grid Accent 5;\lsdpriority63 Medium Shading 1 Accent 5;\lsdpriority64 Medium Shading 2 Accent 5;\lsdpriority65 Medium List 1 Accent 5;\lsdpriority66 Medium List 2 Accent 5;
\lsdpriority67 Medium Grid 1 Accent 5;\lsdpriority68 Medium Grid 2 Accent 5;\lsdpriority69 Medium Grid 3 Accent 5;\lsdpriority70 Dark List Accent 5;\lsdpriority71 Colorful Shading Accent 5;\lsdpriority72 Colorful List Accent 5;\lsdpriority73 Colorful Grid Accent 5;
\lsdpriority60 Light Shading Accent 6;\lsdpriority61 Light List Accent 6;\lsdpriority62 Light Grid Accent 6;\lsdpriority63 Medium Shading 1 Accent 6;\lsdpriority64 Medium Shading 2 Accent 6;\lsdpriority65 Medium List 1 Accent 6;\lsdpriority66 Medium List 2 Accent 6;
\lsdpriority67 Medium Grid 1 Accent 6;\lsdpriority68 Medium Grid 2 Accent 6;\lsdpriority69 Medium Grid 3 Accent 6;\lsdpriority70 Dark List Accent 6;\lsdpriority71 Colorful Shading Accent 6;\lsdpriority72 Colorful List Accent 6;\lsdpriority73 Colorful Grid Accent 6;
\lsdqformat1\lsdpriority19 Subtle Emphasis;\lsdqformat1\lsdpriority21 Intense Emphasis;\lsdqformat1\lsdpriority31 Subtle Reference;\lsdqformat1\lsdpriority32 Intense Reference;\lsdqformat1\lsdpriority33 Book Title;\lsdsemihidden1\lsdunhideused1\lsdpriority37 Bibliography;
\lsdsemihidden1\lsdunhideused1\lsdqformat1\lsdpriority39 TOC Heading;}}}

Hi Akram,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. Its mean that If you generate the same RTF using MS Word and open it in WordPad or RichTextBox, you will get the same output. So, this is the expected behavior of Aspose.Words.

Please let us know if you have any more queries.