Earlier versions of MigraDoc up to version 1.32 included the class MigraDocPrintDocument that allows MigraDoc to print directly.
This class can also be used with MigraDoc 1.50 beta 2.
The current implementation of class MigraDocPrintDocument works with the GDI build of MigraDoc only and can only be used on platforms where GDI+ is available.
If you are using Windows Desktop and the GDI build, just copy the class file MigraDocPrintDocument.cs into your project and use it. At the end of this post is a link to a ZIP file that includes MigraDocPrintDocument.cs and a sample that shows how to use it.
If you are using the WPF build of MigraDoc on a platform that supports GDI+, then you can also use MigraDocPrintDocument for printing. But you have to use a small trick to make it work.
You have to create one assembly that contains the class MigraDocPrintDocument and that references the GDI build of MigraDoc. Your application can still use the WPF build of MigraDoc.
And now for the small trick: you can invoke printing through a new class MigraDocPrintDocumentEx which internally calls class MigraDocPrintDocument. You have to pass your MigraDoc document to class MigraDocPrintDocumentEx as a string in the MDDDL format that MigraDoc uses to persist files. It takes only one line of code to convert from Document to MDDDL and the sample shows how to do it.
Further limitations of printing with MigraDocPrintDocument: Fonts from a FontResolver won’t be used for printing.
If you want to use private fonts also for printing, then you currently have to use the GDI build of MigraDoc and register your fonts in the XPrivateFontCollection.
Here is a sample solution that shows MigraDocPrintDocument at work and also shows printing from an application that uses the WPF build of MigraDoc.