当前位置: 首页>>代码示例>>C#>>正文


C# PrintDialog.PrintDocument方法代码示例

本文整理汇总了C#中System.Windows.Controls.PrintDialog.PrintDocument方法的典型用法代码示例。如果您正苦于以下问题:C# PrintDialog.PrintDocument方法的具体用法?C# PrintDialog.PrintDocument怎么用?C# PrintDialog.PrintDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.PrintDialog的用法示例。


在下文中一共展示了PrintDialog.PrintDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoPrint

        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;

            var q = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog { PrintQueue = q };
            if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.PageHeight = pd.PrintableAreaHeight;
                document.PageWidth = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap = 0;
                document.ColumnWidth = (document.PageWidth -
                                       document.ColumnGap -
                                       document.PagePadding.Left -
                                       document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.PageHeight = ph;
            document.PageWidth = pw;
            document.PagePadding = pp;
            document.ColumnGap = cg;
            document.ColumnWidth = cw;
        }
开发者ID:Spanky81,项目名称:SambaPOS-3,代码行数:29,代码来源:WindowsPrinterJob.cs

示例2: btnPrint_Click

 private void btnPrint_Click(object sender, EventArgs e)
 {
     //REFACTOR ME
     dtgParentReport.Update();
     System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();
     Nullable<bool> print = printDialog.ShowDialog();
     if (print == true)
     {
         try
         {
             XpsDocument xpsDocument = new XpsDocument("C:\\FixedDocumentSequence.xps", FileAccess.ReadWrite);
             FixedDocumentSequence fixedDocSeq = xpsDocument.GetFixedDocumentSequence();
             printDialog.PrintDocument(fixedDocSeq.DocumentPaginator, "Test print job");
         }
         catch (UnauthorizedAccessException e1)
         {
             const string message =
                 "Unauthoried to access that printer.";
             const string caption = "Unauthoried Access";
             var result = MessageBox.Show(message, caption,
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
         }
         catch (PrintDialogException e2)
         {
             const string message =
                 "Unknow error occurred.";
             const string caption = "Error Printing";
             var result = MessageBox.Show(message, caption,
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
         }
     }
 }
开发者ID:jeffBunce,项目名称:Math-Monkeys-3.0,代码行数:34,代码来源:frmParentReport.cs

示例3: cmdPrintCustom_Click

        private void cmdPrintCustom_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                FlowDocument doc = docReader.Document;
                
                // Save all the existing settings.                                
                double pageHeight = doc.PageHeight;
                double pageWidth = doc.PageWidth;
                Thickness pagePadding = doc.PagePadding;
                double columnGap = doc.ColumnGap;
                double columnWidth = doc.ColumnWidth;

                // Make the FlowDocument page match the printed page.
                doc.PageHeight = printDialog.PrintableAreaHeight;
                doc.PageWidth = printDialog.PrintableAreaWidth;
                doc.PagePadding = new Thickness(50);

                // Use two columns.
                doc.ColumnGap = 25;
                doc.ColumnWidth = (doc.PageWidth - doc.ColumnGap
                    - doc.PagePadding.Left - doc.PagePadding.Right) / 2;

                printDialog.PrintDocument(((IDocumentPaginatorSource)doc).DocumentPaginator, "A Flow Document");
                
                // Reapply the old settings.
                doc.PageHeight = pageHeight;
                doc.PageWidth = pageWidth;
                doc.PagePadding = pagePadding;
                doc.ColumnGap = columnGap;
                doc.ColumnWidth = columnWidth;
            }
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:34,代码来源:PrintFlowDocument.xaml.cs

示例4: printOrder

        public static void printOrder( Order o )
        {
            PrintDialog printDlg = new PrintDialog();

            String textToPrint = "";
            textToPrint += "\t\t Τραπέζι "+o.Table_id+"\n\n";

            textToPrint += "Παραγγελία : \n";
            String orderName = "";
            foreach (Items i in DBController.LoadItems())
            {
                if (i.Id == o.Items_id)
                    orderName = i.Name;
            }

            orderName += o.CharacteristicsInfo;
            textToPrint += "\t1 "+orderName+"\n";

            textToPrint += "\n\n";

            String waiterName = "";
            foreach (User u in DBController.LoadUsers())
            {
                if (u.User_id == o.User_id)
                    waiterName = u.Name;
            }

            textToPrint += "Σερβιτόρος : "+waiterName+"\n";
            textToPrint += "Ώρα : " + DateTime.Now.ToString("dd/MM/yyyy h:mm:ss tt");

            FlowDocument doc = new FlowDocument(new Paragraph(new Run(textToPrint)));
            doc.Name = "FlowDoc";
            IDocumentPaginatorSource idpSource = doc;
            printDlg.PrintDocument(idpSource.DocumentPaginator, "smart order");
        }
开发者ID:MeTaXaS4,项目名称:smartOrderPC,代码行数:35,代码来源:Printer.cs

示例5: DoPrint

        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;
            var fm = document.FontFamily;
            var bg = document.Background;

            var q = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog { PrintQueue = q };
            if (q != null || pd.PrintQueue.FullName == Printer.ShareName || Printer.ShareName.ToLower() == "default" || Printer.ShareName.Contains("/") || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.Background = Brushes.Transparent;
                document.FontFamily = new FontFamily(LocalSettings.PrintFontFamily);
                document.PageHeight = pd.PrintableAreaHeight;
                document.PageWidth = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap = 0;
                document.ColumnWidth = (document.PageWidth -
                                       document.ColumnGap -
                                       document.PagePadding.Left -
                                       document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.Background = bg;
            document.FontFamily = fm;
            document.PageHeight = ph;
            document.PageWidth = pw;
            document.PagePadding = pp;
            document.ColumnGap = cg;
            document.ColumnWidth = cw;
        }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:35,代码来源:WindowsPrinterJob.cs

示例6: PrintDialog

        /// <summary>
        /// Invokes a System.Windows.Controls.PrintDialog to print the TextEditor.Document with specified title.
        /// </summary>
        public static void PrintDialog(this TextEditor textEditor, string title)
        {
            Printing.mDocumentTitle = title;

              Printing.InitPageSettings();

              System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

              printDialog.PrintQueue = mPrintQueue;

              if (mPageSettings.Landscape)
            Printing.mPrintTicket.PageOrientation = PageOrientation.Landscape;

              printDialog.PrintTicket = mPrintTicket;
              printDialog.PrintQueue.DefaultPrintTicket.PageOrientation = mPrintTicket.PageOrientation;

              if (printDialog.ShowDialog() == true)
              {
            Printing.mPrintQueue = printDialog.PrintQueue;

            Printing.mPrintTicket = printDialog.PrintTicket;

            printDialog.PrintDocument(CreateDocumentPaginatorToPrint(textEditor), "PrintJob");
              }
        }
开发者ID:joazlazer,项目名称:ModdingStudio,代码行数:28,代码来源:Printing.cs

示例7: PrintCommand

 public void PrintCommand()
 {
     PrintDialog printDlg = new PrintDialog();
     FlowDocument doc = new FlowDocument(new Paragraph(new Run(WebAddress))) {Name = "Directions"};
     IDocumentPaginatorSource idpSource = doc;
     printDlg.PrintDocument(idpSource.DocumentPaginator, "Directions Printing.");
 }
开发者ID:brucedog,项目名称:Morning-Commuter,代码行数:7,代码来源:TravelDirectionsViewModel.cs

示例8: ButtonOk_Click

        private void ButtonOk_Click(object sender, RoutedEventArgs e)
        {
            this.TextBoxRealReportNumber.Text = this.TextBoxRealReportNumber.Text.ToUpper();
            this.TextBoxDummyReportNumber.Text = this.TextBoxDummyReportNumber.Text.ToUpper();

            if (this.TextBoxRealReportNumber.Text.Length < 4)
            {
                MessageBox.Show("The real report number does not appear to be a valid number.\n\nPlease check it and try again.", "Invalid report number", MessageBoxButton.OK);
                return;
            }
            string lastName = this.GetPatientLastName();

            if (lastName.Length == 0)
            {
                MessageBox.Show("The report number does not appear to be a valid number.\n\nPlease check it and try again.", "Case not found", MessageBoxButton.OK);
                return;
            }

            YellowstonePathology.UI.Login.CytologySlideLabelDocument cyologySlideLabelDocument = new CytologySlideLabelDocument(this.TextBoxDummyReportNumber.Text, lastName, false);
            System.Windows.Controls.PrintDialog printDialog = new System.Windows.Controls.PrintDialog();

            System.Printing.PrintQueue printQueue = YellowstonePathology.UI.PrintQueueFactory.GetSlideLabelPrintQueue(YellowstonePathology.Properties.Settings.Default.CytologySlideLabelPrinterName);
            printDialog.PrintQueue = printQueue;
            printDialog.PrintDocument(cyologySlideLabelDocument.DocumentPaginator, "Slide Labels");

            Close();
        }
开发者ID:ericramses,项目名称:YPILIS,代码行数:27,代码来源:CytologyDummySlideLabel.xaml.cs

示例9: Print

        public static void Print(FlowDocument printedPage)
        {
            PrintDialog dialog = new PrintDialog();

            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Portrait;
            dialog.PrintTicket.OutputQuality = OutputQuality.High;
            dialog.PrintTicket.PageBorderless = PageBorderless.None;
            dialog.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);

            if (dialog.ShowDialog() == true)
            {
                double pageHeight = printedPage.PageHeight;
                double pageWidth = printedPage.PageWidth;
                Thickness pagePadding = printedPage.PagePadding;
                double columnGap = printedPage.ColumnGap;
                double columnWidth = printedPage.ColumnWidth;

                printedPage.PageHeight = dialog.PrintableAreaHeight;
                printedPage.PageWidth = dialog.PrintableAreaWidth;
                printedPage.PagePadding = new Thickness(50);

                dialog.PrintDocument(((IDocumentPaginatorSource)printedPage).DocumentPaginator, "");

                printedPage.PagePadding = pagePadding;
                printedPage.PageHeight = pageHeight;
                printedPage.PageWidth = pageWidth;
                printedPage.ColumnWidth = columnWidth;
                printedPage.ColumnGap = columnGap;

            }
        }
开发者ID:Ashna,项目名称:ShayanDent,代码行数:32,代码来源:Common.cs

示例10: btnPrint_Click

        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            //Show a Print Dialog
            PrintDialog dialog = new PrintDialog();
            dialog.MaxPage = this.pdfViewer1.PageCount > 0 ? (uint)this.pdfViewer1.PageCount : 1;
            dialog.MinPage = 1;
            dialog.UserPageRangeEnabled = true;

            bool? result = dialog.ShowDialog();

            if (result.Value)
            {
                try
                {
                    //Set print parnameters.
                    this.pdfViewer1.PrintDialog = dialog;
                    //Get the PrintDocument.
                    dialog.PrintDocument(pdfViewer1.PrintDocument.DocumentPaginator, "Print Document");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }

        }
开发者ID:e-iceblue,项目名称:Spire.Office-for-.NET,代码行数:26,代码来源:MainWindow.xaml.cs

示例11: Print_Click

 private void Print_Click(object sender, RoutedEventArgs e)
 {
     //If you reduce the size of the view area of the window, so the text does not all fit into one page, it will print separate pages
     PrintDialog printDialog = new PrintDialog();
     if (printDialog.ShowDialog() == true)
         printDialog.PrintDocument(((IDocumentPaginatorSource)flowDocument).DocumentPaginator, "This is a Flow Document");
 }
开发者ID:nanomouse,项目名称:stratasys,代码行数:7,代码来源:Window2.xaml.cs

示例12: print_btn_Click

 private void print_btn_Click(object sender, RoutedEventArgs e)
 {
     try
      {
             report.report_cr_dr p = new BMS.report.report_cr_dr();
         p.lst_balance.ItemsSource = dr;
         p.r_date.Content = DateTime.Now.Date.ToShortDateString();
         p.r_name.Content = "Top Debitors";
         PrintDialog pd = new PrintDialog();
         FixedDocument document = new FixedDocument();
         document.DocumentPaginator.PageSize = new Size(96 * 8.5, 96 * 11);
         FixedPage page1 = new FixedPage();
         page1.Width = document.DocumentPaginator.PageSize.Width;
         page1.Height = document.DocumentPaginator.PageSize.Height;
         Canvas can = p.layout;
         page1.Children.Add(can);
         PageContent page1Content = new PageContent();
         ((IAddChild)page1Content).AddChild(page1);
         document.Pages.Add(page1Content);
         pd.PrintDocument(document.DocumentPaginator, "My first document");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Sorry some system error has occour please try again");
     }
 }
开发者ID:sumit10,项目名称:BMS,代码行数:26,代码来源:home.xaml.cs

示例13: cmdPrint_Click

        private void cmdPrint_Click(object sender, RoutedEventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            if (pd.ShowDialog().GetValueOrDefault())
            {
                PrintTicket ticket = pd.PrintTicket;

                if (cmboOrientation.SelectedIndex == 0)
                {
                    ticket.PageOrientation = PageOrientation.Landscape;
                }
                else
                {
                    ticket.PageOrientation = PageOrientation.Portrait;
                }
                pd.PrintTicket = ticket;


                mDoc.PageHeight = pd.PrintableAreaHeight;
                mDoc.PageWidth = pd.PrintableAreaWidth;
                mDoc.PagePadding = new Thickness(50);
                mDoc.ColumnGap = 0;
                mDoc.ColumnWidth = pd.PrintableAreaWidth;

                IDocumentPaginatorSource dps = mDoc;
                pd.PrintDocument(dps.DocumentPaginator, title);
            }
        }
开发者ID:phillipCouto,项目名称:Clear-Choice,代码行数:28,代码来源:DocumentPreviewer.xaml.cs

示例14: DoPrint

        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;

            var q = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog { PrintQueue = q };
            if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.FontFamily = new System.Windows.Media.FontFamily(LocalSettings.PrintFontFamily);
                document.Typography.EastAsianWidths = FontEastAsianWidths.Half;
                document.PageHeight = pd.PrintableAreaHeight;
                document.PageWidth = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap = 0;
                document.ColumnWidth = (document.PageWidth -
                                       document.ColumnGap -
                                       document.PagePadding.Left -
                                       document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.PageHeight = ph;
            document.PageWidth = pw;
            document.PagePadding = pp;
            document.ColumnGap = cg;
            document.ColumnWidth = cw;
        }
开发者ID:BOBAHbI4,项目名称:SambaPOS-3,代码行数:31,代码来源:WindowsPrinterJob.cs

示例15: btnPrint_Click_1

        private void btnPrint_Click_1(object sender, RoutedEventArgs e)
        {
            var printControl = new SummaryControl();
            printControl.DataContext = _reservation;
            printControl.Width = 8.27 * 96;
            printControl.Height = 11.69 * 96;

            //Create a fixed Document and Print the document
            FixedDocument fixedDoc = new FixedDocument();
            PageContent pageContent = new PageContent();
            FixedPage fixedPage = new FixedPage();
            fixedPage.Height = 11.69 * 96;
            fixedPage.Width = 8.27 * 96;

            fixedPage.Children.Add(printControl);
            ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
            fixedDoc.Pages.Add(pageContent);

            PrintDialog dialog = new PrintDialog();
            if (dialog.ShowDialog() == true)
            {
                //dialog.PrintVisual(_PrintCanvas, "My Canvas");
                dialog.PrintDocument(fixedDoc.DocumentPaginator, "Print label");
            }
        }
开发者ID:jaggavarapu,项目名称:AirlineReservation,代码行数:25,代码来源:OrderSummaryPage.xaml.cs


注:本文中的System.Windows.Controls.PrintDialog.PrintDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。