I'm using PDFsharp to create a PDF file, I'm now about to generate a Table Of Contents. How can I set the dot between the text dynamically?
I'm using XRect and a XGraphics Object to draw the String.
And set the Link with AddDocumentLink() e.g:
Text..................... 1
Text2.................... 2
Chapter4 ................ 10
You can use DrawString
to draw the dots. You can use MeasureString
to find out how many dots will fit.
PDFsharp was created for use with MigraDoc. And MigraDoc makes the creation of a ToC quite simple:
http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx
I mention this just in case that switching to a related library is an option.