Exemple #1
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //ExStart
            //ExId:MultiplePagesOnSheet_PrintAndPreview
            //ExSummary:The usage of the MultipagePrintDocument for Previewing and Printing.
            // Open the document.
            Document doc = new Document(dataDir + "TestFile.doc");

            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;

            // Check if user accepted the print settings and proceed to preview.
            if (!printDlg.ShowDialog().Equals(DialogResult.OK))
            {
                return;
            }

            // Pass the printer settings from the dialog to the print document.
            MultipagePrintDocument awPrintDoc = new MultipagePrintDocument(doc, 4, true);

            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;

            // 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
        }
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //ExStart
            //ExId:MultiplePagesOnSheet_PrintAndPreview
            //ExSummary:The usage of the MultipagePrintDocument for Previewing and Printing.
            // Open the document.
            Document doc = new Document(dataDir + "TestFile.doc");

            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;

            // Check if user accepted the print settings and proceed to preview.
            if (!printDlg.ShowDialog().Equals(DialogResult.OK))
                return;

            // Pass the printer settings from the dialog to the print document.
            MultipagePrintDocument awPrintDoc = new MultipagePrintDocument(doc, 4, true);
            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;

            // 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
        }