public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_RenderingAndPrinting();; // Open the document. Document doc = new Document(dataDir + "TestFile.doc"); // ExStart:PrintDialog // ExId:DocumentPreviewAndPrint_PrintDialog_Creation // ExSummary:Creates the print dialog. PrintDialog printDlg = new PrintDialog(); // Initialize the print dialog with the number of pages in the document. printDlg.AllowSomePages = true; printDlg.PrinterSettings.MinimumPage = 1; printDlg.PrinterSettings.MaximumPage = doc.PageCount; printDlg.PrinterSettings.FromPage = 1; printDlg.PrinterSettings.ToPage = doc.PageCount; // ExEnd:PrintDialog // ExStart:ShowDialog // ExId:DocumentPreviewAndPrint_PrintDialog_Check_Result // ExSummary:Check if the user accepted the print settings and proceed to preview the document. if (!printDlg.ShowDialog().Equals(DialogResult.OK)) { return; } // ExEnd:ShowDialog // ExStart:AsposeWordsPrintDocument // ExId:DocumentPreviewAndPrint_AsposeWordsPrintDocument_Creation // ExSummary:Creates a special Aspose.Words implementation of the .NET PrintDocument class. // Pass the printer settings from the dialog to the print document. AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc); awPrintDoc.PrinterSettings = printDlg.PrinterSettings; // ExEnd:AsposeWordsPrintDocument // ExStart:ActivePrintPreviewDialog // ExId:DocumentPreviewAndPrint_ActivePrintPreviewDialog_Creation // ExSummary:Creates an overridden version of the .NET Print Preview dialog to preview the document. ActivePrintPreviewDialog previewDlg = new ActivePrintPreviewDialog(); // Pass the Aspose.Words print document to the Print Preview dialog. previewDlg.Document = awPrintDoc; // Specify additional parameters of the Print Preview dialog. previewDlg.ShowInTaskbar = true; previewDlg.MinimizeBox = true; previewDlg.PrintPreviewControl.Zoom = 1; previewDlg.Document.DocumentName = "TestName.doc"; previewDlg.WindowState = FormWindowState.Maximized; // Show the appropriately configured Print Preview dialog. previewDlg.ShowDialog(); // ExEnd:ActivePrintPreviewDialog }
public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); ; // Open the document. Document doc = new Document(dataDir + "TestFile.doc"); // ExStart:PrintDialog // ExId:DocumentPreviewAndPrint_PrintDialog_Creation // ExSummary:Creates the print dialog. PrintDialog printDlg = new PrintDialog(); // Initialize the print dialog with the number of pages in the document. printDlg.AllowSomePages = true; printDlg.PrinterSettings.MinimumPage = 1; printDlg.PrinterSettings.MaximumPage = doc.PageCount; printDlg.PrinterSettings.FromPage = 1; printDlg.PrinterSettings.ToPage = doc.PageCount; // ExEnd:PrintDialog // ExStart:ShowDialog // ExId:DocumentPreviewAndPrint_PrintDialog_Check_Result // ExSummary:Check if the user accepted the print settings and proceed to preview the document. if (!printDlg.ShowDialog().Equals(DialogResult.OK)) return; // ExEnd:ShowDialog // ExStart:AsposeWordsPrintDocument // ExId:DocumentPreviewAndPrint_AsposeWordsPrintDocument_Creation // ExSummary:Creates a special Aspose.Words implementation of the .NET PrintDocument class. // Pass the printer settings from the dialog to the print document. AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc); awPrintDoc.PrinterSettings = printDlg.PrinterSettings; // ExEnd:AsposeWordsPrintDocument // ExStart:ActivePrintPreviewDialog // ExId:DocumentPreviewAndPrint_ActivePrintPreviewDialog_Creation // ExSummary:Creates an overridden version of the .NET Print Preview dialog to preview the document. ActivePrintPreviewDialog previewDlg = new ActivePrintPreviewDialog(); // Pass the Aspose.Words print document to the Print Preview dialog. previewDlg.Document = awPrintDoc; // Specify additional parameters of the Print Preview dialog. previewDlg.ShowInTaskbar = true; previewDlg.MinimizeBox = true; previewDlg.PrintPreviewControl.Zoom = 1; previewDlg.Document.DocumentName = "TestName.doc"; previewDlg.WindowState = FormWindowState.Maximized; // Show the appropriately configured Print Preview dialog. previewDlg.ShowDialog(); // ExEnd:ActivePrintPreviewDialog }
public static void Run() { // ExStart:PrintMultiplePagesOnOneSheet // The path to the documents directory. string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); // Open the document. Document doc = new Document(dataDir + "TestFile.doc"); // ExStart:PrintDialogSettings PrintDialog printDlg = new PrintDialog(); // Initialize the Print Dialog with the number of pages in the document. printDlg.AllowSomePages = true; printDlg.PrinterSettings.MinimumPage = 1; printDlg.PrinterSettings.MaximumPage = doc.PageCount; printDlg.PrinterSettings.FromPage = 1; printDlg.PrinterSettings.ToPage = doc.PageCount; // ExEnd:PrintDialogSettings // Check if user accepted the print settings and proceed to preview. // ExStart:CheckPrintSettings if (!printDlg.ShowDialog().Equals(DialogResult.OK)) { return; } // ExEnd:CheckPrintSettings // Pass the printer settings from the dialog to the print document. MultipagePrintDocument awPrintDoc = new MultipagePrintDocument(doc, 4, true); awPrintDoc.PrinterSettings = printDlg.PrinterSettings; // ExStart:ActivePrintPreviewDialog // Create and configure the the ActivePrintPreviewDialog class. ActivePrintPreviewDialog previewDlg = new ActivePrintPreviewDialog(); previewDlg.Document = awPrintDoc; // Specify additional parameters of the Print Preview dialog. previewDlg.ShowInTaskbar = true; previewDlg.MinimizeBox = true; previewDlg.Document.DocumentName = "TestFile.doc"; previewDlg.WindowState = FormWindowState.Maximized; // Show appropriately configured Print Preview dialog. previewDlg.ShowDialog(); // ExEnd:ActivePrintPreviewDialog // ExEnd:PrintMultiplePagesOnOneSheet }
public static void Run() { // ExStart:PrintMultiplePagesOnOneSheet // The path to the documents directory. string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); // Open the document. Document doc = new Document(dataDir + "TestFile.doc"); // ExStart:PrintDialogSettings PrintDialog printDlg = new PrintDialog(); // Initialize the Print Dialog with the number of pages in the document. printDlg.AllowSomePages = true; printDlg.PrinterSettings.MinimumPage = 1; printDlg.PrinterSettings.MaximumPage = doc.PageCount; printDlg.PrinterSettings.FromPage = 1; printDlg.PrinterSettings.ToPage = doc.PageCount; // ExEnd:PrintDialogSettings // Check if user accepted the print settings and proceed to preview. // ExStart:CheckPrintSettings if (!printDlg.ShowDialog().Equals(DialogResult.OK)) return; // ExEnd:CheckPrintSettings // Pass the printer settings from the dialog to the print document. MultipagePrintDocument awPrintDoc = new MultipagePrintDocument(doc, 4, true); awPrintDoc.PrinterSettings = printDlg.PrinterSettings; // ExStart:ActivePrintPreviewDialog // Create and configure the the ActivePrintPreviewDialog class. ActivePrintPreviewDialog previewDlg = new ActivePrintPreviewDialog(); previewDlg.Document = awPrintDoc; // Specify additional parameters of the Print Preview dialog. previewDlg.ShowInTaskbar = true; previewDlg.MinimizeBox = true; previewDlg.Document.DocumentName = "TestFile.doc"; previewDlg.WindowState = FormWindowState.Maximized; // Show appropriately configured Print Preview dialog. previewDlg.ShowDialog(); // ExEnd:ActivePrintPreviewDialog // ExEnd:PrintMultiplePagesOnOneSheet }