public void PrintMultiplePages() { //ExStart:PrintMultiplePagesOnOneSheet Document doc = new Document(MyDir + "Rendering.docx"); //ExStart:PrintDialogSettings // Initialize the Print Dialog with the number of pages in the document. PrintDialog printDlg = new PrintDialog { AllowSomePages = true, PrinterSettings = { MinimumPage = 1, MaximumPage = doc.PageCount, FromPage = 1, ToPage = doc.PageCount } }; //ExEnd:PrintDialogSettings // Check if the user accepted the print settings and proceed to preview. //ExStart:CheckPrintSettings if (printDlg.ShowDialog() != DialogResult.OK) { return; } //ExEnd:CheckPrintSettings // Pass the printer settings from the dialog to the print document. MultipagePrintDocument awPrintDoc = new MultipagePrintDocument(doc, 4, true) { PrinterSettings = printDlg.PrinterSettings }; //ExStart:ActivePrintPreviewDialog // Create and configure the the ActivePrintPreviewDialog class. ActivePrintPreviewDialog previewDlg = new ActivePrintPreviewDialog { Document = awPrintDoc, ShowInTaskbar = true, MinimizeBox = true }; // Specify additional parameters of the Print Preview dialog. previewDlg.Document.DocumentName = "PrintDocuments.PrintMultiplePages.docx"; previewDlg.WindowState = FormWindowState.Maximized; previewDlg.ShowDialog(); // Show appropriately configured Print Preview dialog. //ExEnd:ActivePrintPreviewDialog //ExEnd:PrintMultiplePagesOnOneSheet }
public void Print() { Document doc = new Document(MyDir + "Rendering.docx"); //ExStart:PrintDialog // Initialize the print dialog with the number of pages in the document. PrintDialog printDlg = new PrintDialog { AllowSomePages = true, PrinterSettings = { MinimumPage = 1, MaximumPage = doc.PageCount, FromPage = 1, ToPage = doc.PageCount } }; //ExEnd:PrintDialog //ExStart:ShowDialog if (printDlg.ShowDialog() != DialogResult.OK) { return; } //ExEnd:ShowDialog //ExStart:AsposeWordsPrintDocument // Pass the printer settings from the dialog to the print document. AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc) { PrinterSettings = printDlg.PrinterSettings }; //ExEnd:AsposeWordsPrintDocument //ExStart:ActivePrintPreviewDialog // Pass the Aspose.Words print document to the Print Preview dialog. ActivePrintPreviewDialog previewDlg = new ActivePrintPreviewDialog { Document = awPrintDoc, ShowInTaskbar = true, MinimizeBox = true }; // Specify additional parameters of the Print Preview dialog. previewDlg.PrintPreviewControl.Zoom = 1; previewDlg.Document.DocumentName = "PrintDocuments.Print.docx"; previewDlg.WindowState = FormWindowState.Maximized; previewDlg.ShowDialog(); // Show the appropriately configured Print Preview dialog. //ExEnd:ActivePrintPreviewDialog }