示例#1
0
        public void Printing(string pname, string path)
        {
            using (IOStream = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                using (PrintDocument pd = new PrintDocument())
                {
                    _qu = new PagingImage(path);

                    pd.PrintPage += new PrintPageEventHandler((sender, ev) =>
                    {
                        var img = _qu.GetPage(page);
                        if (img == null)
                        {
                            ev.HasMorePages = false;
                            return;
                        }
                        ev.Graphics.DrawImage(img, ev.Graphics.VisibleClipBounds);
                        page++;
                        ev.HasMorePages = _qu.Max >= page;
                    });
                    pd.PrinterSettings.PrinterName = pname;
                    pd.Print();
                }
            }
        }
        public void Printing(string pname, string path)
        {
            using (IOStream = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                using (PrintDocument pd = new PrintDocument())
                {
                    _qu = new PagingImage(path);

                    pd.PrintPage += new PrintPageEventHandler((sender, ev) =>
                    {
                        var img = _qu.GetPage(page);
                        if (img == null)
                        {
                            ev.HasMorePages = false;
                            return;
                        }
                        ev.Graphics.DrawImage(img, ev.Graphics.VisibleClipBounds);
                        page++;
                        ev.HasMorePages = _qu.Max >= page;
                    });
                    pd.PrinterSettings.PrinterName = pname;
                    pd.Print();

                }
            }
        }