Ejemplo n.º 1
0
 //
 /// <summary>
 /// Preview the Report on screen
 /// </summary>
 /// <remarks></remarks>
 public void PrintPreview(bool landscape, PrintMode_ENUM printMode, string docname = "PrintForm", Form Owner = null)
 {
     mblnLandscape = landscape;
     menuPrintMode = printMode;
     //
     // create the document object
     using (var pdcNew = new System.Drawing.Printing.PrintDocument())
     {
         //
         // wire up event handlers to handle pagination
         pdcNew.PrintPage         += PrintPage;
         pdcNew.QueryPageSettings += QueryPageSettings;
         //
         using (var ppvPreview = new PrintPreviewDialog())
         {
             ppvPreview.Document = pdcNew;
             ppvPreview.FindForm().WindowState = FormWindowState.Maximized;
             if (Owner == null)
             {
                 ppvPreview.ShowDialog();
             }
             else
             {
                 ppvPreview.ShowDialog(Owner);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public static void showInvoiceDialog(IWin32Window target, long tranId)
        {
            try
            {
                printTranID = tranId;
                System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
                int neededWidth = 600, height = 800;
                pDoc.DefaultPageSettings.Margins          = new Margins(0, 0, 0, 0);
                pDoc.DefaultPageSettings.PaperSize        = new PaperSize("Custom", neededWidth, height);
                pDoc.DefaultPageSettings.PaperSize.Height = height;
                pDoc.DefaultPageSettings.PaperSize.Width  = neededWidth;

                pDoc.PrintPage += PDoc_PrintPage;

                //PrintDialog printDialog = new PrintDialog();
                //printDialog.Document = pDoc;

                PrintPreviewDialog ppDialog = new PrintPreviewDialog();
                ppDialog.FindForm().WindowState = FormWindowState.Maximized;
                ppDialog.Document = pDoc;

                if (ppDialog.ShowDialog(target) == DialogResult.OK)
                {
                    pDoc.Print();
                }

                //new forms.frmInvoice(tranId).ShowDialog(target);
            }
            catch (Exception ex)
            {
                MessageBox.Show(target, "Sorry, error occured please try again after setting default printer in your Printers Setttings." + Environment.NewLine + "Error message : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="bPreview">是否预览</param>
        private void PrintData()
        {
            iLVRowCount = this.lvSell.Items.Count;

            m_iCurrentRow = 0;
            try
            {
                PrintDocument pd = new PrintDocument();
                //假定为默认打印机
                if (storedPageSettings != null)
                {
                    pd.DefaultPageSettings = storedPageSettings;
                }
                pd.DefaultPageSettings.Landscape = false;//页面是纵向false,如横向用true
                pd.PrintPage += new PrintPageEventHandler(PrintSell);

                m_iCurrentPage = 0;
                int m_iPageCount = iLVRowCount / this.m_iRowCountPerPage;
                if (iLVRowCount % this.m_iRowCountPerPage > 0)
                {
                    m_iPageCount++;
                }
                pd.PrinterSettings.MinimumPage = 1;
                pd.PrinterSettings.MaximumPage = m_iPageCount;
                pd.PrinterSettings.FromPage    = 1;
                pd.PrinterSettings.ToPage      = m_iPageCount;

                if (this.cbbPrint.Checked)
                {
                    PrintPreviewDialog dlg = new PrintPreviewDialog();
                    dlg.Document = pd;

                    Form print = dlg.FindForm();
                    print.Text          = "打印预览销售单";//标题
                    print.WindowState   = System.Windows.Forms.FormWindowState.Maximized;
                    print.StartPosition = FormStartPosition.CenterScreen;
                    pd.DocumentName     = m_iPageCount.ToString();

                    dlg.ShowDialog();
                }
                //else
                //{
                //pd.Print();//直接打印
                //}
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
 // Click do botão para visualizar a impressão no PrintPreviewDialog
 private void btnvisualizar_Click(object sender, EventArgs e)
 {
     try
     {
         leitor = new StringReader(this.labelImprimir.Text);                            //passando a labelImprimir para o leitor do tipo StringReader
         PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
         printPreviewDialog1.ClientSize      = new System.Drawing.Size(1366, 566);      // Tamanho do PrintPreviewDialog
         printPreviewDialog1.Document        = this.printDocument1;                     // PrintPreviewDialog recebendo o documento
         printPreviewDialog1.FormBorderStyle = FormBorderStyle.None;                    // PrintPreviewDialog sem borda
         printPreviewDialog1.FindForm().StartPosition = FormStartPosition.CenterScreen; // PrintPreviewDialog no centro da tela
         printPreviewDialog1.ShowDialog();
     }
     catch (Exception exp)
     {
         MessageBox.Show(" Erro : " + exp.Message.ToString());
     }
 }
Ejemplo n.º 5
0
        //used to display the printpreview dialog
        private void buttonAdv3_Click(object sender, EventArgs e)
        {
            // Print the contents of the grouping grid.
            GridPrintDocument  pd  = new GridPrintDocument(this.gridGroupingControl1.TableControl, true);
            PrintPreviewDialog ppv = new PrintPreviewDialog();

            ppv.MouseWheel += ppv_MouseWheel;
            ppv.Document    = pd;
            pd.DefaultPageSettings.Landscape = true;
            try
            {
                Icon ico            = new Icon(Syncfusion.Windows.Forms.WinFormsUtils.FindFile("Icon", "sfgrid.ico"));
                ppv.FindForm().Icon = ico;
            }
            catch
            { }
            ppv.ShowDialog();
            // NOTE: There is a known problem when the width of the nested table is larger
            // than the width of the parent table. Some columns that do not fit on the same
            // page as the last column of the parent table will be omitted. We are working
            // on a solution for this.
        }