private void KopSoftPrint_Load(object sender, EventArgs e)
        {
            string sDefault = printDocument.PrinterSettings.PrinterName; //设置默认打印机名

            foreach (string sPrint in PrinterSettings.InstalledPrinters) //获取所有打印机名称
            {
                cbPrint.Items.Add(sPrint);
                if (sPrint == sDefault)
                {
                    cbPrint.SelectedIndex = cbPrint.Items.IndexOf(sPrint);
                }
            }


            try
            {
                PageMargins = int.Parse(tbPageMargins.Text);//页面边距
                PagerSetting.PagePadding = (int)PagerSetting.MillimeterToPixel(panel1.Handle, PageMargins, 1);

                PageWidth  = int.Parse(tbPageWidth.Text);
                PageHeight = int.Parse(tbPageHeight.Text);
                if (PageWidth > 0 && PageHeight > 0)//进行尺码单位毫米(mm)转换成像素(Px)
                {
                    PagerSetting.PageHeight = (int)PagerSetting.MillimeterToPixel(panel1.Handle, PageHeight, 2);
                    PagerSetting.PageWidth  = (int)PagerSetting.MillimeterToPixel(panel1.Handle, PageWidth, 1);
                }

                //重绘pager纸张
                PageLayer pl = new PageLayer(PagerSetting.PageWidth, PagerSetting.PageHeight, PagerSetting.PagePadding);
                //先把旧纸张去掉
                if (panel1.Controls.Count > 0)
                {
                    for (int i = 0; i < panel1.Controls.Count; i++)
                    {
                        if (((ImageLayerBase)panel1.Controls[i]).layerType == LayerType.Paper)
                        {
                            panel1.Controls.RemoveAt(i);
                            break;
                        }
                    }
                }
                panel1.Controls.Add(pl);
                PagerSetting.IsPagerLayerCreated = true;

                //计算控件起始坐标
                int startX = (int)((panel1.Width - PagerSetting.PageWidth) / 2);
                int startY = (int)((panel1.Height - PagerSetting.PageHeight) / 2);
                pl.Left  = startX;
                pl.Top   = startY;
                m_startX = startX + PagerSetting.PagePadding;
                m_startY = startY + PagerSetting.PagePadding;

                lbMessage.Text = "设置成功,纸张尺寸" + PagerSetting.PageWidth + "*" + PagerSetting.PageHeight + "px 页面边距" + PagerSetting.PagePadding + "px";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void tbPageHeight_TextChanged(object sender, EventArgs e)
        {
            try
            {
                PageMargins = int.Parse(tbPageMargins.Text);//页面边距
                PagerSetting.PagePadding = (int)PagerSetting.MillimeterToPixel(panel1.Handle, PageMargins, 1);

                PageWidth  = int.Parse(tbPageWidth.Text);
                PageHeight = int.Parse(tbPageHeight.Text);
                if (PageWidth > 0 && PageHeight > 0)//进行尺码单位毫米(mm)转换成像素(Px)
                {
                    PagerSetting.PageHeight = (int)PagerSetting.MillimeterToPixel(panel1.Handle, PageHeight, 2);
                    PagerSetting.PageWidth  = (int)PagerSetting.MillimeterToPixel(panel1.Handle, PageWidth, 1);
                }

                //重绘pager纸张
                PageLayer pl = new PageLayer(PagerSetting.PageWidth, PagerSetting.PageHeight, PagerSetting.PagePadding);
                //先把旧纸张去掉
                if (panel1.Controls.Count > 0)
                {
                    for (int i = 0; i < panel1.Controls.Count; i++)
                    {
                        if (((ImageLayerBase)panel1.Controls[i]).layerType == LayerType.Paper)
                        {
                            panel1.Controls.RemoveAt(i);
                            break;
                        }
                    }
                }
                panel1.Controls.Add(pl);
                PagerSetting.IsPagerLayerCreated = true;

                //计算控件起始坐标
                int startX = (int)((panel1.Width - PagerSetting.PageWidth) / 2);
                int startY = (int)((panel1.Height - PagerSetting.PageHeight) / 2);
                pl.Left  = startX;
                pl.Top   = startY;
                m_startX = startX + PagerSetting.PagePadding;
                m_startY = startY + PagerSetting.PagePadding;

                lbMessage.Text = "设置成功,纸张尺寸" + PagerSetting.PageWidth + "*" + PagerSetting.PageHeight + "px 页面边距" + PagerSetting.PagePadding + "px";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }