private void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            // 8.5 x 11 paper:
            float linesPerPage = 0;
            float fontPerPage  = 0;
            float fontPerPage1 = 0;
            float x0           = 25;
            float xEnd         = 850 - x0;

            float y0   = 25;
            float yEnd = 1100 * 2 - y0; // bottom of 2ed page

            int   page = dtPrn.Rows.Count % 7;
            int   page1 = page;
            float gapCol = 0, fixCol = 10, alignX = 0, len = 0;

            String doc = "", header1 = "", header2 = "", header3 = "", header = "", num = "", up = "", tod = "", down = "";

            header1 = "33333                       วันที่พิมพ์  " + lc.lotdb.selectDateDBtoShow() + " ";
            header2 = "ใบส่งต่อ                      จากเจ้ามือ " + thoD.Name + "  ถึงเจ้ามือ " + cboThoo.Text;
            header3 = "ประจำงวด                    ปี " + cboYear.Text + " เดือน " + cboMonth.Text + "     " + cboPeriod.Text;
            header  = "ตัวเลข     บน      โต๊ด     ล่าง     ";
            doc     = header1 + Environment.NewLine;
            doc    += header2 + Environment.NewLine;
            doc    += header3 + Environment.NewLine;
            Single    yPos       = 0;
            Single    leftMargin = e.MarginBounds.Left + 100;
            Single    topMargin  = e.MarginBounds.Top + 100;
            Image     img        = Image.FromFile("images.jpg");
            Rectangle logo       = new Rectangle(40, 40, 50, 50);

            using (Font printFont = new Font("Arial", 12.0f))
            {
                // Calculate the number of lines per page.
                linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
                fontPerPage  = e.MarginBounds.Width / printFont.SizeInPoints;
                gapCol       = fixCol * printFont.SizeInPoints;
                e.Graphics.DrawImage(img, logo);

                e.Graphics.DrawString(header1, printFont, Brushes.Black, leftMargin + 20, yPos + 30, new StringFormat());
                e.Graphics.DrawString(header2, printFont, Brushes.Black, leftMargin + 20, yPos + 60, new StringFormat());
                e.Graphics.DrawString(header3, printFont, Brushes.Black, leftMargin + 20, yPos + 90, new StringFormat());

                //e.Graphics.DrawString(header, printFont, Brushes.Black, leftMargin - 50, yPos + 150, new StringFormat());
                alignX = lc.alignR(gapCol, fixCol, 5, printFont.SizeInPoints);
                e.Graphics.DrawString("ตัวเลข", printFont, Brushes.Black, (leftMargin - 25), yPos + 150, new StringFormat());
                alignX = lc.alignR(gapCol, fixCol, 2, printFont.SizeInPoints);
                e.Graphics.DrawString("บน", printFont, Brushes.Black, ((leftMargin - 50) + alignX), yPos + 150, new StringFormat());
                alignX = lc.alignR(gapCol * 2, fixCol, 3, printFont.SizeInPoints);
                e.Graphics.DrawString("โต๊ด", printFont, Brushes.Black, ((leftMargin - 50) + alignX), yPos + 150, new StringFormat());
                alignX = lc.alignR(gapCol * 3, fixCol, 3, printFont.SizeInPoints);
                e.Graphics.DrawString("ล่าง", printFont, Brushes.Black, ((leftMargin - 50) + alignX), yPos + 150, new StringFormat());
                if (dtPrn.Rows.Count > 0)
                {
                    int gap = 150, i = 0;
                    for (i = 0; i < dtPrn.Rows.Count; i++)
                    {
                        gap += 30;
                        num  = dtPrn.Rows[i][lc.lotdb.lot.number].ToString();
                        e.Graphics.DrawString(num, printFont, Brushes.Black, (leftMargin - 25), yPos + gap, new StringFormat());
                        //num = lc.alignPrint(num, 10);
                        //e.Graphics.DrawString(num, printFont, Brushes.Black, ((leftMargin - 25) + (gapCol + ((fixCol - num.Length) * printFont.SizeInPoints))), yPos + gap, new StringFormat());
                        up = dtPrn.Rows[i][lc.lotdb.lot.up].ToString();

                        alignX = lc.alignR(gapCol, fixCol, up.Length, printFont.SizeInPoints);
                        e.Graphics.DrawString(up, printFont, Brushes.Black, ((leftMargin - 25) + alignX), yPos + gap, new StringFormat());

                        tod = dtPrn.Rows[i][lc.lotdb.lot.tod].ToString();
                        //alignX = ((gapCol * 2) + (fixCol - tod.Length) * printFont.SizeInPoints);
                        alignX = lc.alignR(gapCol * 2, fixCol, tod.Length, printFont.SizeInPoints);
                        e.Graphics.DrawString(tod, printFont, Brushes.Black, ((leftMargin - 25) + alignX), yPos + gap, new StringFormat());

                        down = dtPrn.Rows[i][lc.lotdb.lot.down].ToString();
                        //alignX = ((gapCol * 3) + (fixCol - down.Length) * printFont.SizeInPoints);
                        alignX = lc.alignR(gapCol * 3, fixCol, down.Length, printFont.SizeInPoints);
                        e.Graphics.DrawString(down, printFont, Brushes.Black, ((leftMargin - 25) + alignX), yPos + gap, new StringFormat());
                    }
                    e.Graphics.DrawString(prnNum, printFont, Brushes.Black, (leftMargin + 20), yPos + gap + 30, new StringFormat());
                }
            }
        }