Exemple #1
0
        private void pd2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Rectangle bounds = new Rectangle(50, 40, 800, 1035);       //Some printers can handle up to 1042
            Graphics  g      = e.Graphics;
            string    text;
            Font      headingFont    = new Font("Arial", 13, FontStyle.Bold);
            Font      subHeadingFont = new Font("Arial", 10, FontStyle.Bold);
            int       yPos           = bounds.Top;
            int       center         = bounds.X + bounds.Width / 2;

            #region printHeading
            if (!headingPrinted)
            {
                text = AccountCur.Description + " (" + Lan.g("enumAccountType", AccountCur.AcctType.ToString()) + ")";
                g.DrawString(text, headingFont, Brushes.Black, center - g.MeasureString(text, headingFont).Width / 2, yPos);
                yPos += (int)g.MeasureString(text, headingFont).Height;
                text  = DateTime.Today.ToShortDateString();
                g.DrawString(text, subHeadingFont, Brushes.Black, center - g.MeasureString(text, subHeadingFont).Width / 2, yPos);
                yPos          += 20;
                headingPrinted = true;
                headingPrintH  = yPos;
            }
            #endregion
            int totalPages = gridMain.GetNumberOfPages(bounds, headingPrintH);
            yPos = gridMain.PrintPage(g, pagesPrinted, bounds, headingPrintH);
            pagesPrinted++;
            if (pagesPrinted < totalPages)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }
        }
        private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Rectangle bounds = e.MarginBounds;
            //new Rectangle(50,40,800,1035);//Some printers can handle up to 1042
            Graphics g = e.Graphics;
            string   text;
            Font     headingFont    = new Font("Arial", 13, FontStyle.Bold);
            Font     subHeadingFont = new Font("Arial", 10, FontStyle.Bold);
            int      yPos           = bounds.Top;
            int      center         = bounds.X + bounds.Width / 2;

            #region printHeading
            if (!headingPrinted)
            {
                text = Lan.g(this, "Recall List");
                g.DrawString(text, headingFont, Brushes.Black, center - g.MeasureString(text, headingFont).Width / 2, yPos);
                yPos += (int)g.MeasureString(text, headingFont).Height;
                text  = textDateStart.Text + " " + Lan.g(this, "to") + " " + textDateEnd.Text;
                g.DrawString(text, subHeadingFont, Brushes.Black, center - g.MeasureString(text, subHeadingFont).Width / 2, yPos);
                yPos          += 20;
                headingPrinted = true;
                headingPrintH  = yPos;
            }
            #endregion
            int totalPages = gridMain.GetNumberOfPages(bounds, headingPrintH);
            yPos = gridMain.PrintPage(g, pagesPrinted, bounds, headingPrintH);
            pagesPrinted++;
            if (pagesPrinted < totalPages)
            {
                e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
            }
            g.Dispose();
        }