• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Printing.PrintDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Drawing.Printing.PrintDocument的典型用法代码示例。如果您正苦于以下问题:C# PrintDocument类的具体用法?C# PrintDocument怎么用?C# PrintDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PrintDocument类属于System.Drawing.Printing命名空间,在下文中一共展示了PrintDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PrintClass

 /// <summary>
 /// 打印信息的初始化
 /// </summary>
 /// <param datagrid="DataGridView">打印数据</param>
 /// <param PageS="int">纸张大小</param>
 /// <param lendscape="bool">是否横向打印</param>
 public PrintClass(DataGridView datagrid, int PageS, bool lendscape)
 {
     this.datagrid = datagrid;//获取打印数据
     this.PageSheet = PageS;//纸张大小
     printdocument = new PrintDocument();//实例化PrintDocument类
     pagesetupdialog = new PageSetupDialog();//实例化PageSetupDialog类
     pagesetupdialog.Document = printdocument;//获取当前页的设置
     printpreviewdialog = new PrintPreviewDialog();//实例化PrintPreviewDialog类
     printpreviewdialog.Document = printdocument;//获取预览文档的信息
     printpreviewdialog.FormBorderStyle = FormBorderStyle.Fixed3D;//设置窗体的边框样式
     //横向打印的设置
     if (PageSheet >= 0)
     {
         if (lendscape == true)
         {
             printdocument.DefaultPageSettings.Landscape = lendscape;//横向打印
         }
         else
         {
             printdocument.DefaultPageSettings.Landscape = lendscape;//纵向打印
         }
     }
     pagesetupdialog.Document = printdocument;
     printdocument.PrintPage += new PrintPageEventHandler(this.printdocument_printpage);//事件的重载
 }
开发者ID:mahuidong,项目名称:c-1200-II,代码行数:31,代码来源:PrintClass.cs


示例2: bPay_Click

 private void bPay_Click(object sender, EventArgs e)
 {
     DB.Instance.Insert("order", new Parameter("customer_id", cid), new Parameter("dt", DateTime.Now), new Parameter("status", OrderStatus.New));
     uint oid = 0;
     using (MySqlDataReader reader = DB.Instance.SelectReader("select max(id) from order"))
     {
         if(reader != null && reader.Read()){
             oid = reader.GetUInt32(0);
         }
     }
     foreach (var item in Role.Instance.ShopCart)
     {
         DB.Instance.Insert("order_inventory", new Parameter("order_id", oid), new Parameter("inventory_id", item.ID), new Parameter("amount", item.Qty));
     }
     var dr = MessageBox.Show("Order Placed. Would you like to pay now?", "Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     if (dr == DialogResult.Yes)
     {
         new Payment().ShowDialog();
     }
     else if(dr == DialogResult.No)
     {
         var ppd = new PrintPreviewDialog();
         PrintDocument pd = new PrintDocument();
         ppd.Document = pd;
         pd.PrintPage += Pd_PrintPage;
         ppd.ShowDialog();
     }
 }
开发者ID:redlive,项目名称:csis3275,代码行数:28,代码来源:Checkout.cs


示例3: PrintOrder

 public static void PrintOrder()
 {
     var doc = new PrintDocument();
     doc.PrinterSettings.PrinterName = System.Configuration.ConfigurationManager.AppSettings["PrinterName"];
     doc.PrintPage += new PrintPageEventHandler(PrintPage);
     doc.Print();
 }
开发者ID:argetima,项目名称:Golex,代码行数:7,代码来源:Extensions.cs


示例4: OnEndPage

 public override void OnEndPage(
     PrintDocument document,
     PrintPageEventArgs e
     )
 {
     this.OriginController.OnEndPage(document, e);
 }
开发者ID:renyh1013,项目名称:dp2,代码行数:7,代码来源:NewPrintController.cs


示例5: PrintClicked

        private void PrintClicked(object sender, System.EventArgs e)
        {
            if (Viewer == null)
            {
                return;
            }

            PrintDocument pd = new PrintDocument();
            pd.DocumentName = Viewer.SourceFile.LocalPath;
            pd.PrinterSettings.FromPage = 1;
            pd.PrinterSettings.ToPage = Viewer.PageCount;
            pd.PrinterSettings.MaximumPage = Viewer.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            pd.DefaultPageSettings.Landscape = Viewer.PageWidth > Viewer.PageHeight ? true : false;
            using (PrintDialog dlg = new PrintDialog())
            {
                dlg.Document = pd;
                dlg.AllowSelection = true;
                dlg.AllowSomePages = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Viewer.Print(pd);
                }
            }

        }
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:26,代码来源:ViewerToolstrip.cs


示例6: Print

        public void Print()
        {
            try {
                _current = 0;

                PrintDocument document = new PrintDocument();
                document.PrinterSettings = _config.PrinterSettings;
                document.PrinterSettings.Collate = true;
                document.PrinterSettings.Copies = (short)_session.NumberOfCopies;
                //document.DefaultPageSettings.Margins = new Margins(100, 100, 100, 100);
                document.DefaultPageSettings.Margins = new Margins(25, 25, 25, 25);
                document.QueryPageSettings += OnQueryPageSettings;
                document.PrintPage += OnPrintPage;

                if (!String.IsNullOrEmpty(_config.PaperSource)) {
                    foreach (PaperSource source in document.PrinterSettings.PaperSources) {
                        if (source.SourceName == _config.PaperSource)
                            document.DefaultPageSettings.PaperSource = source;
                    }
                }

                if (_config.PreviewOnly) {
                    if (Application.OpenForms.Count > 0)
                        Application.OpenForms[0].BeginInvoke(new WaitCallback(PreviewProc), document);
                } else {
                    document.Print();
                }
            } catch (Exception ex) {
            #if DEBUG
                Dicom.Debug.Log.Error("DICOM Print Error: " + ex.ToString());
            #else
                Dicom.Debug.Log.Error("DICOM Print Error: " + ex.Message);
            #endif
            }
        }
开发者ID:k11hao,项目名称:mdcm-printscp,代码行数:35,代码来源:NPrintService.cs


示例7: InitializeComponent

 private void InitializeComponent()
 {
     this.printDocument1 = new System.Drawing.Printing.PrintDocument();
     //
     //Main DataSet Initialization
     //
     this.printPreviewDialog1 = new PrintPreviewDialog();
     this.maindataset = new SupremeTransport.maindataset();
     //
     //Table Adapter Initialization
     //
     this.mainbillTableAdapter = new SupremeTransport.maindatasetTableAdapters.mainbillTableAdapter();
     this.billTableAdapter = new SupremeTransport.maindatasetTableAdapters.billTableAdapter();
     // 
     // printDocument1
     // 
     this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
     // 
     // printPreviewDialog1
     // 
     this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
     this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
     this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
     this.printPreviewDialog1.Enabled = true;
     this.printPreviewDialog1.Name = "printPreviewDialog1";
     this.printPreviewDialog1.Visible = false;
 }
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:27,代码来源:PrintingClass.cs


示例8: Execute

        public override void Execute()
        {
            printDocument = new PrintDocument();

              printDocument.OriginAtMargins = true;
              printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
              printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);

              Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments);
              printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";

              // Sizes must be given in inch * 100 (sigh).
              int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254);
              int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
              PaperSize paperSize = new PaperSize("Doesn't matter", paperWidth, paperHeight);
              printDocument.DefaultPageSettings.PaperSize = paperSize;

              if ((bool)paperSettings["marginsSet"])
            printDocument.DefaultPageSettings.Margins =
              new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
            (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);

              printDialog = new System.Windows.Forms.PrintDialog();
              printDialog.Document = printDocument;
              printDialog.AllowPrintToFile = true;

              pageNumber = 0;
              pageCount = -1;

              if (printDialog.ShowDialog() == DialogResult.OK)
              {
            printDocument.Print();
              }
        }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:34,代码来源:PrintDialog.cs


示例9: OnStartPrint

        public override void OnStartPrint(PrintDocument document, PrintEventArgs e) {
            Debug.Assert(dc == null && graphics == null, "PrintController methods called in the wrong order?");

            // For security purposes, don't assume our public methods methods are called in any particular order
            CheckSecurity(document);

            base.OnStartPrint(document, e);
            // the win32 methods below SuppressUnmanagedCodeAttributes so assertin on UnmanagedCodePermission is redundant
            if (!document.PrinterSettings.IsValid)
                throw new InvalidPrinterException(document.PrinterSettings);

            dc = document.PrinterSettings.CreateDeviceContext(modeHandle);
            SafeNativeMethods.DOCINFO info = new SafeNativeMethods.DOCINFO();
            info.lpszDocName = document.DocumentName;
            if (document.PrinterSettings.PrintToFile)
                info.lpszOutput = document.PrinterSettings.OutputPort; //This will be "FILE:"
            else
                info.lpszOutput = null;
            info.lpszDatatype = null;
            info.fwType = 0;

            int result = SafeNativeMethods.StartDoc(new HandleRef(this.dc, dc.Hdc), info);
            if (result <= 0) {
                int error = Marshal.GetLastWin32Error();
                if (error == SafeNativeMethods.ERROR_CANCELLED) {
                    e.Cancel = true;
                }
                else {
                    throw new Win32Exception(error);
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:32,代码来源:DefaultPrintController.cs


示例10: Print_button_Click

 /* Events to execute when the "Print" button is clicked */
 private void Print_button_Click(object sender, EventArgs e)
 {
     /* Creates a new instance of printDocument, appends the result from PrintDocumentOnPrintPage and prints the result */
     PrintDocument printDocument = new PrintDocument();
     printDocument.PrintPage += PrintDocumentOnPrintPage;
     printDocument.Print();
 }
开发者ID:Nicolai-,项目名称:CSharp_Mail_Client_New,代码行数:8,代码来源:ShowMail.cs


示例11: axWindowsMediaPlayer1_PlayStateChange

        private void axWindowsMediaPlayer1_PlayStateChange(object sender, _WMPOCXEvents_PlayStateChangeEvent e)
        {
            //QUANDO VIDEO FOR PARADO
            if (  axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPaused )
            {
                //O VIDEO FOI PARADO, PARA CONTINUAR PRECISA CLICAR EM OK
                if ( MessageBox.Show("Video Parado. Clique aqui para continuar!", "",
                    MessageBoxButtons.OK , MessageBoxIcon.Information) == DialogResult.OK )
                {
                    axWindowsMediaPlayer1.Ctlcontrols.play();
                }
            }

            //QUANDO O VIDEO ACABAR
            if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
            {
                //IMPRIME
                PrintDocument document = new PrintDocument();
                document.PrintPage += new PrintPageEventHandler(impressaoConf);
                document.Print();

                this.Hide();

            }
        }
开发者ID:marcommas,项目名称:videoAlstomCSharp,代码行数:25,代码来源:Login.cs


示例12: Imprimir

        public static void Imprimir(Entidades.Álbum.Álbum álbum, ItensImpressão itens)
        {
            using (PrintDocument documento = new PrintDocument())
            {
                documento.DocumentName = "Álbum " + álbum.Nome;

                using (PrintDialog dlg = new PrintDialog())
                {
                    dlg.AllowCurrentPage = false;
                    dlg.AllowSelection = false;
                    dlg.AllowSomePages = true;
                    dlg.UseEXDialog = true;
                    dlg.Document = documento;

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        ControleImpressão ctrl = new ControleImpressão(álbum, itens);

                        ctrl.página = new Página(
                                documento.PrinterSettings.DefaultPageSettings.PrintableArea.Width / 100f,
                                documento.PrinterSettings.DefaultPageSettings.PrintableArea.Height / 100f,
                                4, 5);
            
                        ctrl.daPágina = dlg.PrinterSettings.FromPage;
                        ctrl.atéPágina = dlg.PrinterSettings.ToPage != 0 ?
                            dlg.PrinterSettings.ToPage : int.MaxValue;

                        documento.PrintPage += new PrintPageEventHandler(ctrl.ImprimirPágina);
                        documento.Print();
                    }
                }
            }
        }
开发者ID:andrepontesmelo,项目名称:imjoias,代码行数:33,代码来源:ControleImpressão.cs


示例13: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     PrintDocument pd = new PrintDocument();
         pd.PrintPage += PrintPage;
         pd.Print();
         this.Close();
 }
开发者ID:vivektarwan,项目名称:JSSRISf,代码行数:7,代码来源:Printpatientinfo.cs


示例14: createXmlApp

        //如下的这个方法可以注释掉,没有任何的作用
        public void createXmlApp()
        {
            // 首先创建文件
            FileStream fs = File.Create(Application.StartupPath + "\\xmlAPP.xml");
            fs.Close();//关闭文件

            //创建 XmlDocument 以便操作
            XmlDocument xmlDoc = new XmlDocument();

            //xml 唯一的根,我设置的根都是root
            XmlElement xmlEleRoot = xmlDoc.CreateElement("root");

            // 这个配置还有一个是必须的,就是打印机的DPI, 其他的都不是必要的
            XmlElement xmlElePrinter = xmlDoc.CreateElement("printer");

            //打印机名称,这里直接设置默认打印机
            PrintDocument printDoc = new PrintDocument();
            xmlElePrinter.SetAttribute("PrinterName", printDoc.PrinterSettings.PrinterName);
            printDoc.Dispose();//释放资源

            //DPI有两个
            xmlElePrinter.SetAttribute("DPIX", "600");
            xmlElePrinter.SetAttribute("DPIY", "600");

            //如下是两个添加操作了
            xmlEleRoot.AppendChild(xmlElePrinter);
            xmlDoc.AppendChild(xmlEleRoot);

            //保存操作
            xmlDoc.Save(Application.StartupPath + "\\xmlAPP.xml");
        }
开发者ID:kerwinxu,项目名称:barcodeManager,代码行数:32,代码来源:ClsXmlAPP.cs


示例15: butPrint_Click

		private void butPrint_Click(object sender,EventArgs e) {
			PrintDocument pd2=new PrintDocument();
			pd2.PrintPage+=new PrintPageEventHandler(this.pd2_PrintPage);
			pd2.OriginAtMargins=true;
			pd2.DefaultPageSettings.Margins=new Margins(0,0,0,0);
			pd2.Print();
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:7,代码来源:FormPerioTest.cs


示例16: A_FrmDCfgRealTime

        PrintDocument pd;//新建打印

        #region[事件]
        /// <summary>
        /// 初始化
        /// </summary>
        public A_FrmDCfgRealTime()
        {
            InitializeComponent();
            pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);//主函数中实例化,并且添加时间。
            this.MapGis.StationClick += new ZzhaControlLibrary.ZzhaMapGis.ClickStation(MapGis_StationClick);
        }
开发者ID:ZoeCheck,项目名称:128_5.6_2010,代码行数:13,代码来源:A_FrmDCfgRealTime.cs


示例17: PrintTokens

        public void PrintTokens(List<TokenPrint> tokens, Form parentDialog, string PrinterName, bool showPrintPreview)
        {
            _tokensToPrint = tokens;
            _pageCounter = 0;
            //bool showPrintPreview = true;
            PrintDocument pd = new PrintDocument();
            PrintDocument pd1 = new PrintDocument();

            pd.DefaultPageSettings.PaperSize = paperSize;
            pd.PrintPage += printDoc_PrintPage;
            pd.PrinterSettings.PrinterName = PrinterName;

            //ToDo: can remove preview in the actual production.
            if (showPrintPreview)
            {
                var ppDlg = new PrintPreviewDialog();
                ppDlg.SetBounds(30, 30, 1024, 500);
                ppDlg.PrintPreviewControl.AutoZoom = true;
                ppDlg.PrintPreviewControl.Zoom = 0.75;
                ppDlg.Document = pd;
                var dr = ppDlg.ShowDialog(parentDialog);
            }
            else
            {
                pd.Print();
            }
        }
开发者ID:akhilnaruto,项目名称:WinApp,代码行数:27,代码来源:PrintHelper.cs


示例18: printImage

        public bool printImage(string[] imagePaths)
        {
            // Get desired image width
            int desiredImageWidth;
            if (imagePaths.Count() == 1)
            {
                desiredImageWidth = (A4_WIDTH - (gap + 2 * A4_BORDER_WIDTH));
            }
            else
            {
               desiredImageWidth = (A4_WIDTH - ((gap + 2 * A4_BORDER_WIDTH) / 2));
            }

            try
            {
                List<Image> images = new List<Image>();
                foreach (string imagePath in imagePaths)
                {
                    Image image = Image.FromFile(imagePath);
                    image = this.Scale(image, maxImageWidth, A4_HEIGHT);
                    images.Add(image);
                }

                PrintDocument pd = new PrintDocument();
                pd.PrintPage += (sender, e) => printDoc_PrintPage(images, sender, e);
                pd.Print();
            }
            catch (System.Drawing.Printing.InvalidPrinterException)
            {
                return false;
            }

            return true;
        }
开发者ID:ctompkinson,项目名称:PhotoBooth,代码行数:34,代码来源:PrintHandler.cs


示例19: PrintImage

        public static void PrintImage(string argstrImageFile, string argstrPrinterSelected)
        {
            if (System.IO.File.Exists(argstrImageFile))
            {
                string strPrinterSelected = GetDefaultPrinter();
                if (strPrinterSelected == "")
                {
                    string strTemp = ConfigRoutines.GetSetting("DefaultPrinter");
                    strDefaultPrinter = strTemp == "" ? strDefaultPrinter : ConfigRoutines.GetSetting("DefaultPrinter");
                    strPrinterSelected = argstrPrinterSelected == "" ? strDefaultPrinter : argstrPrinterSelected;
                }
                PrintDocument objPrintDocument = new PrintDocument();
                objPrintDocument.PrintPage += new PrintPageEventHandler(objPrintDocument_PrintPage);
                objBitmap = new Bitmap(argstrImageFile);

                // print the file
                try
                {
                    objPrintDocument.PrinterSettings.PrinterName = strPrinterSelected;
                    //if (!bolPrintAsIs)
                    //{
                    //    Margins objMargins = new Margins(150, 20, 20, 20);
                    //    objPrintDocument.DefaultPageSettings.Margins = objMargins;
                    //}
                    objPrintDocument.Print();
                }
                catch (Exception ex)
                {
                    CommonRoutines.Log(ex.Message);
                }
            }
        }
开发者ID:steven-e-smith,项目名称:igenfuels-igenformsviewer,代码行数:32,代码来源:PlexPrint.cs


示例20: OnStartPrint

        /// <include file='doc\PrintControllerWithStatusDialog.uex' path='docs/doc[@for="PrintControllerWithStatusDialog.OnStartPrint"]/*' />
        /// <internalonly/>
        /// <devdoc>
        ///    <para>
        ///       Implements StartPrint by delegating to the underlying controller.
        ///    </para>
        /// </devdoc>
        public override void OnStartPrint(PrintDocument document, PrintEventArgs e) {
            base.OnStartPrint(document, e);

            this.document = document;
            pageNumber = 1;

            if (SystemInformation.UserInteractive) {
                backgroundThread = new BackgroundThread(this); // starts running & shows dialog automatically
            }

            // OnStartPrint does the security check... lots of 
            // extra setup to make sure that we tear down
            // correctly...
            //
            try {
                underlyingController.OnStartPrint(document, e);
            }
            catch {
                if (backgroundThread != null) {
                    backgroundThread.Stop();
                }
                throw;
            }
            finally {
                if (backgroundThread != null && backgroundThread.canceled) {
                    e.Cancel = true;
                }
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:36,代码来源:PrintControllerWithStatusDialog.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Printing.PrintEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Printing.PaperSize类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap