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
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
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 ??
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
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
Our thoughts here at Progress are with those affected by the outbreak.