The following shows how to insert a table of contents while
disabling kerning.
string text = File.ReadAllText(Server.MapPath("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.AddTextStyled(text.Replace(" ~", "<leader>.</leader>"));
doc.Save(Server.MapPath("TableOfContentsWithLeaders.pdf"));
}
Dim text As String = File.ReadAllText(Server.MapPath("tableofcontents.txt"))
text = text.Replace(vbCr, "<br>")
' make our carriage returns into breaks
text = text.Replace(" ", vbTab & vbTab & " ")
' 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.AddTextStyled(text.Replace(" ~", "<leader>.</leader>"))
doc.Save(Server.MapPath("TableOfContentsWithLeaders.pdf"))
End Using
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
|