Getting started with MigraDoc
Version 6.1.0
In this section
Learning the programming model
Please examine the sample source code to learn about the classes that come with MigraDoc and what they can do.
The Hello World sample demonstrates how to create a PDF with the obligatory "Hello, World!" message.
The Hello MigraDoc sample demonstrates how to create a real document with sections, styles, tables, and more.
MigraDoc uses a document object model that allows to create documents without redundancies. You can create paragraph styles and text styles that inherit attributes from other styles. With an ideal MigraDoc document, you specify font names and font sizes only when defining the styles.
When creating a new MigraDoc document, you create an instance of the Document
class.
The document has an AddSection
method that returns a Section
object.
The section has an AddParagraph
method that returns a Paragraph
object.
The paragraph has methods like AddFormattedText
and AddImage
that allow to extend the contents of the paragraph.
Similarly, you can call AddTable
or AddImage
for a section object to add more contents. The table in turn has AddColumn
and AddRow
and for table cells you can call AddParagraph
and AddImage
and other methods.
The MigraDoc source code has XML documentation for all public classes and methods and the Intellisense of Visual Studio will show you the available methods with their documentation.
Sample source code
Sample code can be found on GitHub.
For samples that are included with MigraDoc 6.x, see here:
https://github.com/empira/PDFsharp.Samples/tree/master/src/samples/src/MigraDoc/src
More samples
The PDFsharp forum has a board with sample code from members:
https://forum.pdfsharp.net/viewforum.php?f=8
These samples cover various topics and might help you solve your tasks.
Getting support
If you have specific questions, feel free to ask them at our peer support forum:
https://forum.pdfsharp.net/
Reporting bugs
When reporting bugs, it is important for us to be able to replicate the issue.
We created a sample project that uses the Nuget packages to help you providing a minimal code sample that replicates the issue.