Exemplo n.º 1
0
        public void PreviewAndPrint()
        {
            //ExStart
            //ExFor:AsposeWordsPrintDocument.#ctor(Document)
            //ExFor:AsposeWordsPrintDocument.CachePrinterSettings
            //ExSummary:Shows how to select a page range and a printer to print the document with, and then bring up a print preview.
            Document doc = new Document(MyDir + "Rendering.docx");

            PrintPreviewDialog previewDlg = new PrintPreviewDialog();

            // Call the "Show" method to get the print preview form to show on top.
            previewDlg.Show();

            // Initialize the Print Dialog with the number of pages in the document.
            PrintDialog printDlg = new PrintDialog();

            printDlg.AllowSomePages = true;
            printDlg.PrinterSettings.MinimumPage = 1;
            printDlg.PrinterSettings.MaximumPage = doc.PageCount;
            printDlg.PrinterSettings.FromPage    = 1;
            printDlg.PrinterSettings.ToPage      = doc.PageCount;

            if (printDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // Create the "Aspose.Words" implementation of the .NET print document,
            // and then pass the printer settings from the dialog.
            AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc);

            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;

            // Use the "CachePrinterSettings" method to reduce time of the first call of the "Print" method.
            awPrintDoc.CachePrinterSettings();

            // Call the "Hide", and then the "InvalidatePreview" methods to get the print preview to show on top.
            previewDlg.Hide();
            previewDlg.PrintPreviewControl.InvalidatePreview();

            // Pass the "Aspose.Words" print document to the .NET Print Preview dialog.
            previewDlg.Document = awPrintDoc;

            previewDlg.ShowDialog();
            //ExEnd
        }
Exemplo n.º 2
0
        public void PreviewAndPrint()
        {
            //ExStart
            //ExFor:AsposeWordsPrintDocument
            //ExSummary:Shows the Print dialog that allows selecting the printer and page range to print with. Then brings up the print preview from which you can preview the document and choose to print or close.
            Document doc = new Document(MyDir + "Rendering.doc");

            PrintPreviewDialog previewDlg = new PrintPreviewDialog();

            // Show non-modal first is a hack for the print preview form to show on top.
            previewDlg.Show();

            // Initialize the Print Dialog with the number of pages in the document.
            PrintDialog printDlg = new PrintDialog();

            printDlg.AllowSomePages = true;
            printDlg.PrinterSettings.MinimumPage = 1;
            printDlg.PrinterSettings.MaximumPage = doc.PageCount;
            printDlg.PrinterSettings.FromPage    = 1;
            printDlg.PrinterSettings.ToPage      = doc.PageCount;

            if (!printDlg.ShowDialog().Equals(DialogResult.OK))
            {
                return;
            }

            // Create the Aspose.Words' implementation of the .NET print document
            // and pass the printer settings from the dialog to the print document.
            // Use 'CachePrinterSettings' to reduce time of first call of Print() method.
            AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc);

            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;
            awPrintDoc.CachePrinterSettings();

            // Hide and invalidate preview is a hack for print preview to show on top.
            previewDlg.Hide();
            previewDlg.PrintPreviewControl.InvalidatePreview();

            // Pass the Aspose.Words' print document to the .NET Print Preview dialog.
            previewDlg.Document = awPrintDoc;

            previewDlg.ShowDialog();
            //ExEnd
        }
Exemplo n.º 3
0
 private void PPD_FormClosing(object sender, FormClosingEventArgs e)
 {
     e.Cancel = true;
     PPD.Hide();
 }