Пример #1
0
		internal PdfRow(PdfTable owner,int index)
		{
			this.owner=owner;
			this.index=index;
			this.startRow=index;
			this.endRow=index;
			this.startColumn=0;
			this.endColumn=this.owner.columns-1;
		}
Пример #2
0
 internal PdfColumn(PdfTable owner, int index)
 {
     this.owner       = owner;
     this.index       = index;
     this.startColumn = index;
     this.endColumn   = index;
     this.startRow    = 0;
     this.endRow      = this.owner.rows - 1;
 }
Пример #3
0
		internal PdfColumn(PdfTable owner,int index)
		{
			this.owner=owner;
			this.index=index;
			this.startColumn=index;
			this.endColumn=index;
			this.startRow=0;
			this.endRow=this.owner.rows-1;
		}
Пример #4
0
 internal PdfRow(PdfTable owner, int index)
 {
     this.owner       = owner;
     this.index       = index;
     this.startRow    = index;
     this.endRow      = index;
     this.startColumn = 0;
     this.endColumn   = this.owner.columns - 1;
 }
Пример #5
0
		internal PdfCellRange(PdfTable owner,int startRow,int startColumn,int endRow,int endColumn)
		{
			object o=owner.Cell(startRow,startColumn);
			o=owner.Cell(endRow,endColumn);
			this.owner=owner;
			this.startColumn=startColumn;
			this.startRow=startRow;
			this.endColumn=endColumn;
			this.endRow=endRow;
		}
Пример #6
0
        internal PdfCellRange(PdfTable owner, int startRow, int startColumn, int endRow, int endColumn)
        {
            object o = owner.Cell(startRow, startColumn);

            o                = owner.Cell(endRow, endColumn);
            this.owner       = owner;
            this.startColumn = startColumn;
            this.startRow    = startRow;
            this.endColumn   = endColumn;
            this.endRow      = endRow;
        }
Пример #7
0
 internal PdfCell(PdfTable owner, int row, int column, ContentAlignment ContentAlignment, Color ForegroundColor, Font Font, double CellPadding)
 {
     this.colSpan          = 1;
     this.rowSpan          = 1;
     this.row              = row;
     this.stringFormat     = "{0}";
     this.transparent      = true;
     this.Font             = Font;
     this.owner            = owner;
     this.column           = column;
     this.ContentAlignment = ContentAlignment;
     this.foregroundColor  = ForegroundColor;
     this.cellPadding      = CellPadding;
 }
Пример #8
0
        /// <summary>
        /// Instantiates a new PdfTable setting the default specs.
        /// </summary>
        /// <param name="DefaultFont"></param>
        /// <param name="Rows"></param>
        /// <param name="Columns"></param>
        /// <param name="CellPadding"></param>
        /// <returns></returns>
        public PdfTable NewTable(Font DefaultFont, int Rows, int Columns, double CellPadding)
        {
            if (Rows <= 0)
            {
                throw new Exception("Rows must be grater than zero.");
            }
            if (Columns <= 0)
            {
                throw new Exception("Columns must be grater than zero.");
            }
            if (CellPadding < 0)
            {
                throw new Exception("CellPadding must be non-negative.");
            }
            PdfTable pt = new PdfTable(this, ContentAlignment.TopCenter, DefaultFont, Color.Black, Rows
                                       , Columns, CellPadding);

            pt.header = new PdfTable(this, ContentAlignment.MiddleCenter, DefaultFont, Color.Black, 1
                                     , Columns, CellPadding);

            return(pt);
        }
Пример #9
0
		/// <summary>
		/// Instantiates a new PdfTable setting the default specs.
		/// </summary>
		/// <param name="DefaultFont"></param>
		/// <param name="Rows"></param>
		/// <param name="Columns"></param>
		/// <param name="CellPadding"></param>
		/// <returns></returns>
		public PdfTable NewTable(Font DefaultFont,int Rows,int Columns,double CellPadding)
		{
			if (Rows<=0) throw new Exception("Rows must be grater than zero.");
			if (Columns<=0) throw new Exception("Columns must be grater than zero.");
			if (CellPadding<0) throw new Exception("CellPadding must be non-negative.");
			PdfTable pt=new PdfTable(this,ContentAlignment.TopCenter,DefaultFont,Color.Black,Rows
				,Columns,CellPadding);
			pt.header=new PdfTable(this,ContentAlignment.MiddleCenter,DefaultFont,Color.Black,1
				,Columns,CellPadding);
			
			return pt;
		}
    protected void btnprint_click(object sender, EventArgs e)
    {
        try
        {
            int RowCheckedCnt = 0;
            if (grdBarcode.Rows.Count > 0)
            {
                foreach (GridViewRow row in grdBarcode.Rows)
                {
                    CheckBox cbsel = (CheckBox)row.FindControl("chkenbl");
                    if (cbsel.Checked == true)
                    {
                        RowCheckedCnt++;
                    }
                }
            }
            PdfDocument          mydoc = new PdfDocument(PdfDocumentFormat.InCentimeters(24, 30));
            Gios.Pdf.PdfDocument mypdf = new Gios.Pdf.PdfDocument(PdfDocumentFormat.A4);

            Gios.Pdf.PdfPage mypdfpage   = mydoc.NewPage();
            Font             Fontsmall   = new Font("Times New Roman", 10, FontStyle.Regular);
            Font             Fontbold    = new Font("Book Antique", 10, FontStyle.Bold);
            Font             Fontnormal  = new Font("Book Antique", 10, FontStyle.Regular);
            Font             fontCoverNo = new Font("IDAutomationHC39M", 10, FontStyle.Bold);

            List <string> Acc_No = new List <string>();
            mypdfpage = mydoc.NewPage();
            string  collegename = "";
            string  address1    = "";
            string  address2    = "";
            string  address3    = "";
            string  PhNo        = "";
            string  faxno       = "";
            string  colquery    = "select collname,address1,address2,address3,phoneno,faxno from collinfo where college_code='" + ddl_collegename.SelectedItem.Value + "'";
            DataSet ds1         = d2.select_method_wo_parameter(colquery, "Text");
            if (ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
            {
                collegename = Convert.ToString(ds1.Tables[0].Rows[0]["collname"]);
                address1    = Convert.ToString(ds1.Tables[0].Rows[0]["address1"]);
                address2    = Convert.ToString(ds1.Tables[0].Rows[0]["address2"]);
                address3    = Convert.ToString(ds1.Tables[0].Rows[0]["address3"]);
                PhNo        = Convert.ToString(ds1.Tables[0].Rows[0]["phoneno"]);
                faxno       = Convert.ToString(ds1.Tables[0].Rows[0]["faxno"]);
            }
            PdfTextArea ptc = new PdfTextArea(Fontbold, System.Drawing.Color.Black,
                                              new PdfArea(mydoc, 140, 50, 400, 30), System.Drawing.ContentAlignment.MiddleCenter, collegename);
            mypdfpage.Add(ptc);

            PdfTextArea ptc1 = new PdfTextArea(Fontbold, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 125, 65, 400, 30), System.Drawing.ContentAlignment.MiddleCenter, address1 + "," + address2 + "," + address3);
            mypdfpage.Add(ptc1);
            PdfTextArea ptc2 = new PdfTextArea(Fontbold, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 130, 80, 400, 30), System.Drawing.ContentAlignment.MiddleCenter, PhNo + "," + faxno);
            mypdfpage.Add(ptc2);

            int SpreadCheckCount = 0;
            if (RowCheckedCnt > 30)
            {
                SpreadCheckCount = RowCheckedCnt / 2;
            }
            if (RowCheckedCnt < 30)
            {
                SpreadCheckCount = RowCheckedCnt;
            }

            Gios.Pdf.PdfTable table = mydoc.NewTable(Fontsmall, SpreadCheckCount + 1, 5, 1);

            table.SetBorders(Color.Black, 1, BorderType.CompleteGrid);
            table.VisibleHeaders = false;
            table.Cell(0, 0).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 0).SetContent("Acc No");
            table.Cell(0, 0).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 0).SetFont(Fontbold);
            table.Cell(0, 1).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 1).SetContent("Title");
            table.Cell(0, 1).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 1).SetFont(Fontbold);
            table.Cell(0, 2).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 2).SetContent("Author");
            table.Cell(0, 2).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 2).SetFont(Fontbold);
            table.Cell(0, 3).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 3).SetContent("Class No");
            table.Cell(0, 3).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 3).SetFont(Fontbold);
            table.Cell(0, 4).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 4).SetContent("Bar code");
            table.Cell(0, 4).SetContentAlignment(ContentAlignment.MiddleCenter);
            table.Cell(0, 4).SetFont(Fontbold);
            table.Columns[0].SetWidth(50);
            table.Columns[0].SetCellPadding(9);
            table.Columns[1].SetWidth(200);
            table.Columns[1].SetCellPadding(9);
            table.Columns[2].SetWidth(150);
            table.Columns[2].SetCellPadding(9);
            table.Columns[3].SetWidth(80);
            table.Columns[3].SetCellPadding(9);
            table.Columns[4].SetWidth(100);
            table.Columns[4].SetCellPadding(9);
            int img_pos = 212;
            int TR      = 1;
            //for (int dsrow = 0; dsrow < SpreadCheckCount; dsrow++)
            if (SpreadCheckCount > 0)
            {
                foreach (GridViewRow row in grdBarcode.Rows)
                {
                    CheckBox cbsel  = (CheckBox)row.FindControl("chkenbl");
                    int      RowCnt = Convert.ToInt32(row.RowIndex);
                    if (cbsel.Checked == true)
                    {
                        string accNo      = Convert.ToString(grdBarcode.Rows[RowCnt].Cells[2].Text);
                        string title      = Convert.ToString(grdBarcode.Rows[RowCnt].Cells[3].Text);
                        string author     = Convert.ToString(grdBarcode.Rows[RowCnt].Cells[4].Text);
                        string classNo    = Convert.ToString(grdBarcode.Rows[RowCnt].Cells[7].Text);
                        string LibBarCode = Convert.ToString(grdBarcode.Rows[RowCnt].Cells[17].Text);

                        string barCode = LibBarCode;
                        System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();

                        table.Cell(TR, 0).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table.Cell(TR, 0).SetCellPadding(13);
                        table.Cell(TR, 0).SetContent(Convert.ToString(accNo));
                        table.Cell(TR, 1).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table.Cell(TR, 1).SetCellPadding(13);
                        table.Cell(TR, 1).SetContent(Convert.ToString(title));
                        table.Cell(TR, 2).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table.Cell(TR, 2).SetCellPadding(13);
                        table.Cell(TR, 2).SetContent(Convert.ToString(author));
                        table.Cell(TR, 3).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table.Cell(TR, 3).SetCellPadding(13);
                        table.Cell(TR, 3).SetContent(Convert.ToString(classNo));

                        using (Bitmap bitMap = new Bitmap(accNo.Length * 40, 80))
                        {
                            using (Graphics graphics = Graphics.FromImage(bitMap))
                            {
                                Font       oFont      = new Font("IDAutomationHC39M", 16);
                                PointF     point      = new PointF(2f, 2f);
                                SolidBrush blackBrush = new SolidBrush(Color.Black);
                                SolidBrush whiteBrush = new SolidBrush(Color.White);
                                graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
                                graphics.DrawString("*" + accNo + "*", oFont, blackBrush, point);
                            }
                            using (MemoryStream ms = new MemoryStream())
                            {
                                bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                                byte[] byteImage = ms.ToArray();

                                if (File.Exists(HttpContext.Current.Server.MapPath("~/BarCode/" + accNo + ".jpeg")))
                                {
                                    PdfImage LogoImage1 = mydoc.NewImage(HttpContext.Current.Server.MapPath("~/BarCode/" + accNo + ".jpeg"));
                                    mypdfpage.Add(LogoImage1, 580, img_pos, 200);
                                }
                                else
                                {
                                    File.WriteAllBytes(Server.MapPath("~/BarCode/" + accNo + ".jpeg"), byteImage);

                                    DirectoryInfo dir = new DirectoryInfo("~/BarCode/" + accNo + ".jpeg");
                                    dir.Refresh();
                                    ms.Dispose();
                                    ms.Close();
                                    PdfImage LogoImage1 = mydoc.NewImage(HttpContext.Current.Server.MapPath("~/BarCode/" + accNo + ".jpeg"));
                                    mypdfpage.Add(LogoImage1, 580, img_pos, 200);
                                }
                            }
                            img_pos += 36;
                        }
                        TR++;
                    }
                }
                //}
                Gios.Pdf.PdfTablePage newpdftabpage1 = table.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 15, 180, 650, 1200));
                mypdfpage.Add(newpdftabpage1);
                mypdfpage.SaveToDocument();

                string appPath = HttpContext.Current.Server.MapPath("~");
                if (appPath != "")
                {
                    string szPath = appPath + "/Report/";
                    string szFile = "LibraryBarcode" + DateTime.Now.ToString("ddMMyyyy") + DateTime.Now.ToString("HHmmss") + ".pdf";
                    mydoc.SaveToFile(szPath + szFile);
                    Response.ClearHeaders();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + szFile);
                    Response.ContentType = "application/pdf";
                    Response.WriteFile(szPath + szFile);
                }
            }
            else
            {
                imgdiv2.Visible = true;
                lbl_alert.Text  = "Please select the record";
            }
        }
        catch (Exception ex)
        {
            d2.sendErrorMail(ex, collegecode, "BarcodeGeneration");
        }
    }
Пример #11
0
		internal PdfCell(PdfTable owner,int row,int column,ContentAlignment ContentAlignment,Color ForegroundColor,Font Font,double CellPadding)
		{
			this.colSpan=1;
			this.rowSpan=1;
			this.row=row;
			this.stringFormat="{0}";
			this.transparent=true;
			this.Font=Font;
			this.owner=owner;
			this.column=column;
			this.ContentAlignment=ContentAlignment;
			this.foregroundColor=ForegroundColor;
			this.cellPadding=CellPadding;
		}