This is a migrated thread and some comments may be shown as answers.

TableOfContents Questions

5 Answers 86 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
zj
Top achievements
Rank 1
zj asked on 08 Apr 2018, 07:46 AM

Hi:

   1.  How can I create a TOC with links that can go to its source section when I use Ctrl+click?

   2.  How can I create a TOC that ignores the previous pages (for example  : the first three pages)?

   3.  why I created a TOC ,when the document exported to a pdf file, something changed(see the attach files )

5 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 11 Apr 2018, 08:46 AM
Hi zj,

I will cover the questions one by one:
1. You can use the \h switch in the field code, or the TableOfContentsField.HyperlinkEntries property if you are using the model
2. This functionality is not supported. You can experiment whether something will fit your scenario  - the switches currently supported by the TableOfContentsField in RadRichTextBox are \h, \f, \o, \l, \u, \c, \n, \p.
3. This is a known issue. You can follow the item to track eventual status changes using the item in the feedback portal here: 
RichTextBox: Tab stop leaders are not exported to PDF

Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
zj
Top achievements
Rank 1
answered on 12 Apr 2018, 06:20 AM

Hi:

   Thanks for your reply!

   For the first question,I used the TableOfContentsField.HyperlinkEntries property, but there are some differences except that the answer of question 3 mentioned(dot, underline,hyphen) :

              In the RadRichTextBox, it shows like the file richTextBoxShow in the attachments; 

          But,  in the pdf, it shows like the file pdfShow in the attachments; 

            the differences:  the first is the color (from black to blue), the second is the Italic style that  Signed by red rectangle;

the code of My TOC Style is:

 

private void SetTocFontStyle(RadDocument document)
{
FontFamily font = new FontFamily("Calibri");
Color fontColor = Colors.Black;
StyleDefinition styleTmp;

styleTmp = document.StyleRepository[RadDocumentDefaultStyles.GetTocStyleNameByIndex(1)];

SetSpanFontStyle(styleTmp.SpanProperties, 14.0, fontColor, font, false, false, false);
styleTmp.IsPrimary = true;      //show in list of styles in Microsoft Word ribbon

styleTmp = document.StyleRepository[RadDocumentDefaultStyles.GetTocStyleNameByIndex(2)];
SetSpanFontStyle(styleTmp.SpanProperties, 12.0, fontColor, font, false, false, false);
styleTmp.IsPrimary = true;      //show in list of styles in Microsoft Word ribbon

styleTmp = document.StyleRepository[RadDocumentDefaultStyles.GetTocStyleNameByIndex(3)];
SetSpanFontStyle(styleTmp.SpanProperties, 10.0, fontColor, font, false, false, true);
styleTmp.IsPrimary = true;      //show in list of styles in Microsoft Word ribbon
}

private void SetSpanFontStyle(SpanProperties span, double fontSize, Color fontColor, FontFamily fontFamily, bool isUnderline, bool isBold, bool isItalic)
{
if (span == null)       //span should not be null
return;

System.Diagnostics.Debug.Assert((fontSize > 0.0) && (fontSize <= 500.0));
System.Diagnostics.Debug.Assert(fontFamily != null); span.FontSize = fontSize;

span.ForeColor = fontColor;
span.FontFamily = fontFamily;

if (isUnderline == true)
span.UnderlineDecoration = UnderlineTypes.Line;

if (isBold == true)
span.FontWeight = FontWeights.Bold;

if (isItalic == true)
span.FontStyle = FontStyles.Italic;
}

 

For the Second question,  is there anyway to create page Numbers for directories independently, and also create page Numbers for the text independently ??

 

 

 

0
Boby
Telerik team
answered on 17 Apr 2018, 06:16 AM
Hello zj,

Indeed this seems as a bug in the PDF export. I just logged in our public portal here:
RichTextBox: TableOfContentsField (TOC) is exported to PDF with hyperlink styling
The bug is currently not scheduled for a release, so I cannot commit to specific time frame for its fixing.

As a workaround, you can try manually cleaning the hyperlink style from the Spans inside the TOC:
var firstTocRange = this.radRichTextBox.Document.EnumerateChildrenOfType<FieldRangeStart>().Where(frs => frs.Field is TableOfContentsField).First();
this.radRichTextBox.Document.Selection.SelectAnnotationRange(firstTocRange);
foreach (var spanLayoutBox in this.radRichTextBox.Document.Selection.GetSelectedBoxes<SpanLayoutBox>())
{
    spanLayoutBox.AssociatedSpan.Style = null;
}

Please, excuse us for the inconvenience. We have added points to your account for the report. Don't hesitate to contact us if you have other questions.



Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Remus
Top achievements
Rank 1
Veteran
answered on 20 May 2020, 08:06 AM
Is there any workaround for this: RichTextBox: Tab stop leaders are not exported to PDF?
0
Martin
Telerik team
answered on 21 May 2020, 11:20 AM

Hello Remus,

I am afraid we cannot suggest an approach to work around this behavior. I apologize for the inconvenience this issue might be causing you. 

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
RichTextBox
Asked by
zj
Top achievements
Rank 1
Answers by
Boby
Telerik team
zj
Top achievements
Rank 1
Remus
Top achievements
Rank 1
Veteran
Martin
Telerik team
Share this question
or