The following shows how to insert a table of contents while disabling kerning.
[C#]
string text = File.ReadAllText("tableofcontents.txt");
text = text.Replace("\r", "<br>"); // make our carriage returns into breaks
text = text.Replace(" ", " "); // make our indent at start of line into nbsp
using (Doc doc = new Doc()) {
doc.TextStyle.Size = 36;
doc.TextStyle.Kerning = XTextStyle.KerningType.None;
doc.Rect.Inset(10, 10);
doc.Page = doc.AddPage();
doc.AddHtml(text.Replace(" ~", "<leader>.</leader>"));
doc.Save("TableOfContentsWithLeaders.pdf");
}
[Visual Basic]
Dim text As String = File.ReadAllText("tableofcontents.txt")
text = text.Replace(vbCr, "<br>")
' make our carriage returns into breaks
text = text.Replace(" ", " ")
' make our indent at start of line into nbsp
Using doc As New Doc()
doc.TextStyle.Size = 36
doc.TextStyle.Kerning = XTextStyle.KerningType.None
doc.Rect.Inset(10, 10)
doc.Page = doc.AddPage()
doc.AddHtml(text.Replace(" ~", "<leader>.</leader>"))
doc.Save("TableOfContentsWithLeaders.pdf")
End Using
End Sub
Using the following input text.
Chapter 1: Getting Started ~1
Introduction ~2
Next Steps ~3
Chapter 2: What To Do ~4
Some Difficult Bits ~15
Some More Difficult Bits ~20
Chapter 3: In Conclusion ~21
Summary ~22
Endword ~23
We get the following output.
TableOfContentsWithLeaders.pdf
|