/// <summary> /// Prints the current document on a printer. /// </summary> private void miPrint_Click(object sender, System.EventArgs e) { // Reuse the renderer from the preview DocumentRenderer renderer = this.pagePreview.Renderer; if (renderer != null) { int pageCount = renderer.FormattedDocument.PageCount; // Creates a PrintDocument that simplyfies printing of MigraDoc documents MigraDocPrintDocument printDocument = new MigraDocPrintDocument(); // Attach the current printer settings printDocument.PrinterSettings = this.printerSettings; if (this.printerSettings.PrintRange == PrintRange.Selection) printDocument.SelectedPage = this.pagePreview.Page; // Attach the current document renderer printDocument.Renderer = renderer; // Print the document printDocument.Print(); } }
/// <summary> /// Demonstrates the preview using System.Windows.Froms.PrintPreviewDialog. /// In .NET 1.x this dialog is a lousy implementation. In .NET 2.0 it's a litte bit better /// (at least portrait/landscape is handled correctly...). /// </summary> private void miPreview_Click(object sender, System.EventArgs e) { using (PrintPreviewDialog dialog = new PrintPreviewDialog()) { dialog.Text = "Preview using System.Windows.Froms.PrintPreviewDialog"; #if NET_2_0 dialog.ShowIcon = false; #endif dialog.MinimizeBox = false; dialog.MaximizeBox = false; // Reuse the renderer from the preview DocumentRenderer renderer = this.pagePreview.Renderer; // Creates a PrintDocument that simplifies printing of MigraDoc documents MigraDocPrintDocument printDocument = new MigraDocPrintDocument(); // Attach the current printer settings printDocument.PrinterSettings = this.printerSettings; // Attach the current document renderer printDocument.Renderer = renderer; // Attach the current print document dialog.Document = printDocument; // Show the preview dialog.ShowDialog(); } }
public MigraDocPrintDocumentEx(string ddl) { _printDocument = new MigraDocPrintDocument(ddl); }