/// <summary>
		/// creates a new rectangle
		/// </summary>
		/// <param name="RectangleArea">the area which will contains the rectangle</param>
		/// <param name="BorderColor"></param>
		public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor)
		{
			this.PdfDocument=PdfDocument;
			this.rectangleArea=RectangleArea;
			this.BorderColor=BorderColor;
			this.strokeWidth=1;
		}
		/// <summary>
		/// creates a new rectangle 
		/// </summary>
		/// <param name="RectangleArea"></param>
		/// <param name="BorderColor"></param>
		/// <param name="BorderWidth"></param>
		public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor,double BorderWidth)
		{
			this.PdfDocument=PdfDocument;
			if (BorderWidth<=0) throw new Exception("BorderWidth must be greater than zero.");
			this.rectangleArea=RectangleArea;
			this.BorderColor=BorderColor;
			this.strokeWidth=BorderWidth;
		}
Beispiel #3
0
		internal PdfHeader(PdfDocument PdfDocument,string subject,string title,string author)
		{
			this.PdfDocument=PdfDocument;
			this.id=this.PdfDocument.GetNextId;
			this.subject=subject;
			this.title=title;
			this.author=author;
			this.creationdate=DateTime.Today.ToShortDateString();
		}
Beispiel #4
0
		public PdfCatalog(PdfDocument PdfDocument)
		{
			this.PdfDocument=PdfDocument;
			this.id=this.PdfDocument.GetNextId;
		}
    protected void btn_commonprint_OnClick(object sender, EventArgs e)
    {
        try
        {
            string coename  = "";
            string strquery = "select *,district+' - '+pincode  as districtpin from collinfo where college_code='" + Session["collegecode"].ToString() + "'";
            ds.Dispose();
            ds.Reset();
            ds = d2.select_method_wo_parameter(strquery, "Text");
            string Collegename = "";
            string aff         = "";
            string collacr     = "";
            string dispin      = "";
            string category    = "";
            if (ds.Tables[0].Rows.Count > 0)
            {
                Collegename = ds.Tables[0].Rows[0]["Collname"].ToString();
                aff         = ds.Tables[0].Rows[0]["affliatedby"].ToString();
                string[] strpa = aff.Split(',');
                aff      = strpa[0];
                coename  = ds.Tables[0].Rows[0]["coe"].ToString();
                collacr  = ds.Tables[0].Rows[0]["acr"].ToString();
                dispin   = ds.Tables[0].Rows[0]["districtpin"].ToString();
                category = ds.Tables[0].Rows[0]["category"].ToString();
            }
            string degreecode = ddlbranch.SelectedValue.ToString();
            //string
            //string eve = d2.GetFunction(" select c.type from Degree d,Course c where d.Course_Id=c.Course_Id and d.Degree_Code='" + degreecode + "'");
            string eve     = "";
            string course  = "";
            string deptacr = "";

            string headingquery = "select c.type,c.Course_Name,de.dept_name from Degree d,Course c,Department de where d.Course_Id=c.Course_Id and de.Dept_Code=d.Dept_Code and d.Degree_Code='" + degreecode + "'";
            hds = d2.select_method_wo_parameter(headingquery, "Text");
            if (hds.Tables[0].Rows.Count > 0)
            {
                eve     = hds.Tables[0].Rows[0]["type"].ToString();
                course  = hds.Tables[0].Rows[0]["Course_Name"].ToString();
                deptacr = hds.Tables[0].Rows[0]["dept_name"].ToString();
            }
            string batch = ddlbatch.SelectedItem.Text;
            string title = "PAPERS SELECTED BY THE STUDENTS OF " + course + " - " + deptacr + " - BATCH " + batch + " (" + eve + ")";

            Font Fontbold1  = new Font("Times New Roman", 15, FontStyle.Bold);
            Font font2bold  = new Font("Times New Roman", 12, FontStyle.Bold);
            Font font2small = new Font("Times New Roman", 12, FontStyle.Regular);
            Font font3bold  = new Font("Times New Roman", 9, FontStyle.Bold);
            Font font3small = new Font("Times New Roman", 10, FontStyle.Regular);
            Font font4bold  = new Font("Times New Roman", 7, FontStyle.Bold);
            Font font4small = new Font("Times New Roman", 7, FontStyle.Regular);

            Gios.Pdf.PdfDocument  mydoc;
            Gios.Pdf.PdfPage      mypdfpage;
            Gios.Pdf.PdfTable     table1forpage2;
            Gios.Pdf.PdfTablePage newpdftabpage2;

            if (FpSpread2.Sheets[0].RowCount > 0)
            {
                int       nofocolun = 0;
                Hashtable hatrowset = new Hashtable();
                int       haskpage  = 0;
                int       checkrow  = 0;
                for (int r = 0; r < FpSpread2.Sheets[0].RowCount; r++)
                {
                    string nameval = FpSpread2.Sheets[0].Cells[r, 1].Text.ToString();
                    if (nameval.Trim() != "")
                    {
                        checkrow++;
                        if (checkrow == 11 || checkrow == 1)
                        {
                            haskpage++;
                            checkrow = 1;
                        }
                    }
                    if (hatrowset.Contains(haskpage))
                    {
                        hatrowset[haskpage] = Convert.ToInt32(hatrowset[haskpage]) + 1;
                    }
                    else
                    {
                        hatrowset.Add(haskpage, 1);
                    }
                }
                int pagcount = hatrowset.Count;
                haskpage = 0;
                int totcol     = FpSpread2.Sheets[0].ColumnCount - 3;
                int noofcolumn = totcol / 10;
                if (((FpSpread2.Sheets[0].ColumnCount - 3) % 10) > 0)
                {
                    noofcolumn++;
                }
                mydoc = new Gios.Pdf.PdfDocument(PdfDocumentFormat.InCentimeters(60, 40));
                int startcolun = 0;
                int endcolumn;
                int stratrow = 0;
                int endrow   = 0;
                for (int pc = 1; pc <= pagcount; pc++)
                {
                    int noofrows = Convert.ToInt32(hatrowset[pc]);
                    startcolun = 3;
                    stratrow   = endrow;
                    endrow     = stratrow + noofrows;
                    startcolun = 3;
                    int colcou = 3;
                    for (int col = 0; col < noofcolumn; col++)
                    {
                        if (col > 0)
                        {
                            startcolun = startcolun + 10;
                        }
                        endcolumn = startcolun + 10;
                        if (endcolumn > FpSpread2.Sheets[0].ColumnCount)
                        {
                            endcolumn = FpSpread2.Sheets[0].ColumnCount;
                        }
                        colcou    = colcou + 10;
                        nofocolun = 13;
                        if (colcou > FpSpread2.Sheets[0].ColumnCount)
                        {
                            colcou    = (FpSpread2.Sheets[0].ColumnCount + 10) - colcou;
                            nofocolun = colcou + 3;
                        }

                        mypdfpage = mydoc.NewPage();
                        int coltop = 20;

                        #region Left Logo

                        if (File.Exists(HttpContext.Current.Server.MapPath("~/college/Left_Logo.jpeg")))
                        {
                            PdfImage LogoImage = mydoc.NewImage(HttpContext.Current.Server.MapPath("~/college/Left_Logo.jpeg"));
                            mypdfpage.Add(LogoImage, 35, 20, 320);
                        }

                        #endregion

                        #region TOP DETAILS

                        coltop = coltop + 10;

                        PdfTextArea ptc = new PdfTextArea(Fontbold1, System.Drawing.Color.Black,
                                                          new PdfArea(mydoc, 0, coltop, 1700, 30), System.Drawing.ContentAlignment.TopCenter, Collegename + "(" + category + ")");
                        mypdfpage.Add(ptc);

                        coltop = coltop + 20;

                        ptc = new PdfTextArea(Fontbold1, System.Drawing.Color.Black,
                                              new PdfArea(mydoc, 0, coltop, 1700, 30), System.Drawing.ContentAlignment.TopCenter, title);
                        mypdfpage.Add(ptc);

                        coltop = coltop + 20;

                        //ptc = new PdfTextArea(font2bold, System.Drawing.Color.Black,
                        //                                            new PdfArea(mydoc, 560, coltop, 595, 30), System.Drawing.ContentAlignment.TopCenter, aff);
                        //mypdfpage.Add(ptc);
                        //coltop = coltop + 15;

                        //ptc = new PdfTextArea(font2bold, System.Drawing.Color.Black,
                        //                                            new PdfArea(mydoc, 560, coltop, 595, 30), System.Drawing.ContentAlignment.TopCenter, dispin);
                        //mypdfpage.Add(ptc);

                        #endregion

                        # region Table Binding

                        table1forpage2 = mydoc.NewTable(font3small, noofrows + 1, nofocolun, 4);
                        table1forpage2.VisibleHeaders = false;
                        table1forpage2.SetBorders(Color.Black, 1, BorderType.CompleteGrid);
                        table1forpage2.Cell(0, 0).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table1forpage2.Cell(0, 0).SetContent("S.No");
                        table1forpage2.Columns[0].SetWidth(30);
                        table1forpage2.Cell(0, 1).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table1forpage2.Cell(0, 1).SetContent("Reg.No");
                        table1forpage2.Columns[1].SetWidth(60);
                        table1forpage2.Cell(0, 2).SetContentAlignment(ContentAlignment.MiddleCenter);
                        table1forpage2.Cell(0, 2).SetContent("Student Name");
                        table1forpage2.Columns[2].SetWidth(150);
                        //table1forpage2.Cell(0, 3).SetContentAlignment(ContentAlignment.MiddleCenter);
                        //table1forpage2.Cell(0, 3).SetContent("(Total Papers Selected)");
                        //table1forpage2.Columns[3].SetWidth(80);
                        //table1forpage2.Cell(0, 4).SetContentAlignment(ContentAlignment.MiddleCenter);
                        //table1forpage2.Cell(0, 4).SetContent("Total Papers Appeared");
                        //table1forpage2.Columns[4].SetWidth(80);

                        table1forpage2.Cell(0, 0).SetFont(font2bold);
                        table1forpage2.Cell(0, 1).SetFont(font2bold);
                        table1forpage2.Cell(0, 2).SetFont(font2bold);
                        //table1forpage2.Cell(0, 3).SetFont(font2bold);
                        //table1forpage2.Cell(0, 4).SetFont(font2bold);

                        int totalrow = endrow - stratrow;
                        int tr       = 0;
                        int tc       = 3;
                        for (int r = stratrow; r < endrow; r++)
                        {
                            tr++;
                            tc = 2;
                            table1forpage2.Cell(tr, 0).SetContentAlignment(ContentAlignment.MiddleCenter);
                            table1forpage2.Cell(tr, 1).SetContentAlignment(ContentAlignment.MiddleLeft);
                            table1forpage2.Cell(tr, 2).SetContentAlignment(ContentAlignment.MiddleLeft);
                            //table1forpage2.Cell(tr, 3).SetContentAlignment(ContentAlignment.MiddleCenter);
                            //table1forpage2.Cell(tr, 4).SetContentAlignment(ContentAlignment.MiddleCenter);
                            table1forpage2.Cell(tr, 0).SetContent(FpSpread2.Sheets[0].Cells[r, 0].Text.ToString());
                            table1forpage2.Cell(tr, 1).SetContent(FpSpread2.Sheets[0].Cells[r, 1].Text.ToString());
                            table1forpage2.Cell(tr, 1).SetFont(font2bold);
                            table1forpage2.Cell(tr, 2).SetContent(FpSpread2.Sheets[0].Cells[r, 2].Text.ToString());
                            table1forpage2.Cell(tr, 2).SetFont(font2bold);
                            //table1forpage2.Cell(tr, 3).SetContent(FpSpread2.Sheets[0].Cells[r, 3].Text.ToString());
                            //table1forpage2.Cell(tr, 3).SetFont(font3small);
                            //table1forpage2.Cell(tr, 4).SetContent(FpSpread2.Sheets[0].Cells[r, 4].Text.ToString());
                            //table1forpage2.Cell(tr, 4).SetFont(font3small);
                            for (int c = startcolun; c < endcolumn; c++)
                            {
                                tc++;
                                if (tc < FpSpread2.Sheets[0].ColumnCount)
                                {
                                    if (r == stratrow)
                                    {
                                        table1forpage2.Cell(0, tc).SetContentAlignment(ContentAlignment.MiddleCenter);
                                        table1forpage2.Cell(0, tc).SetContent(FpSpread2.Sheets[0].ColumnHeader.Cells[0, c].Text.ToString());
                                        table1forpage2.Cell(0, tc).SetFont(font2bold);
                                        table1forpage2.Columns[tc].SetWidth(100);
                                        table1forpage2.Cell(tr, tc).SetCellPadding(20);
                                    }
                                    table1forpage2.Cell(tr, tc).SetContent(FpSpread2.Sheets[0].Cells[r, c].Text.ToString());
                                    table1forpage2.Cell(tr, tc).SetFont(font2bold);
                                    string value = FpSpread2.Sheets[0].Cells[r, c].Text.ToString().ToString();
                                    if (value.Trim() == "")
                                    {
                                        table1forpage2.Cell(tr, tc).SetContent(".");
                                        table1forpage2.Cell(tr, tc).SetForegroundColor(Color.White);
                                    }
                                    if (totalrow > 40)
                                    {
                                        table1forpage2.Cell(tr, tc).SetCellPadding(1);
                                    }
                                    else if (totalrow > 30)
                                    {
                                        table1forpage2.Cell(tr, tc).SetCellPadding(5);
                                    }
                                    else if (totalrow > 18)
                                    {
                                        table1forpage2.Cell(tr, tc).SetCellPadding(10);
                                    }
                                    else
                                    {
                                        table1forpage2.Cell(tr, tc).SetCellPadding(20);
                                    }
                                }
                            }
                        }
                        newpdftabpage2 = table1forpage2.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 15, 130, 1670, 5000));
                        mypdfpage.Add(newpdftabpage2);
                        mypdfpage.SaveToDocument();

                        #endregion
                    }
                }

                string appPath = HttpContext.Current.Server.MapPath("~");
                if (appPath != "")
                {
                    string szPath = appPath + "/Report/";
                    string szFile = "SubjectAllotment" + 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);
                }
            }
        }
Beispiel #6
0
		internal PdfTable(PdfDocument PdfDocument,ContentAlignment DefaultContentAlignment,Font Font,Color DefaultForegroundColor,int Rows
			,int Columns,double CellPadding)
		{
			cells=new Hashtable();
			pdfRows=new ArrayList();
			this.owner=this;
			this.PdfDocument=PdfDocument;
			this.borderWidth=0;
			this.pdfColumns=new ArrayList();
			this.rows=Rows;
			this.startRow=0;
			this.startColumn=0;
			this.endColumn=Columns-1;
			this.endRow=Rows-1;
			this.columns=Columns;
			
			for (int c=0;c<columns;c++)
				for (int r=0;r<rows;r++)
				{
					this.cells[r+","+c]=new PdfCell(this,r,c,DefaultContentAlignment,DefaultForegroundColor
						,Font,CellPadding);
				}
			for (int r=0;r<rows;r++)
			{
				this.pdfRows.Add(new PdfRow(this,r));
			}
			for (int c=0;c<columns;c++)
			{
				PdfColumn pc=new PdfColumn(this,c);
				pc.Width=100/this.columns;
				this.pdfColumns.Add(pc);
			}
		}
Beispiel #7
0
		/// <summary>
		/// Generates a new Area inside the base one specifing the width difference.
		/// </summary>
		/// <param name="Difference">the Width difference of the inner Area</param>
		/// <returns></returns>
		public PdfArea InnerArea(double Difference)
		{
			this.PdfDocument=PdfDocument;
			if (Difference<0) throw new Exception("Difference must be non negative.");
			PdfArea pa=this.MemberwiseClone() as PdfArea;
			pa.width-=(double)Difference;
			pa.Height-=(double)Difference;
			pa.posx+=(double)Difference/2;
			pa.posy+=(double)Difference/2;
			return pa;
		}
Beispiel #8
0
		internal PdfArea (PdfDocument PdfDocument){this.PdfDocument=PdfDocument;}
Beispiel #9
0
		/// <summary>
		/// Creates a new Area for correctly placing objects into Pdf Pages
		/// </summary>
		/// <param name="posx">Top-Left Vertex X-coordinate</param>
		/// <param name="posy">Top-Left Vertex Y-coordinate</param>
		/// <param name="width">Width of the Area</param>
		/// <param name="height">Height of the Area</param>
		public PdfArea (PdfDocument PdfDocument,double posx,double posy,double width,double height)
		{
			this.PdfDocument=PdfDocument;
			if (width<=0) throw new Exception("Width must be grater than zero.");
			if (height<=0) throw new Exception("Height must be grater than zero.");
			this.PosX=(double)posx;
			this.PosY=(double)posy;
			this.Width=(double)width;
			this.Height=(double)height;
			
		}
    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");
        }
    }
Beispiel #11
0
		public PdfRoot(PdfDocument PdfDocument)
		{
			this.PdfDocument=PdfDocument;
			this.id=this.PdfDocument.GetNextId;

		}
        public Stream GenerateSelectedTasksPDF(IEnumerable <SelectedTask> selectedTasks, ReportInfo reportInfo)
        {
            int            countSelectedTasks = selectedTasks.Count();
            int            totalNoiseDosage   = selectedTasks.Sum(x => x.Percentage);
            NoiseLevelEnum noiseLevelEnum     = _noiseLevelService.CalculateNoiseLevelEnum(totalNoiseDosage);
            Color          noiseLevelColor    = GetColorForNoiseLevel(noiseLevelEnum);
            DataTable      dataTable          = GenerateDataTable(selectedTasks);


            // Starting instantiate the document.
            // Remember to set the Docuement Format. In this case, we specify width and height.
            PdfDocument myPdfDocument = new PdfDocument(PdfDocumentFormat.A4_Horizontal);

            // Now we create a Table with lines likt the number of selected tasks, 6 columns and 4 points of Padding.
            PdfTable myPdfTable = myPdfDocument.NewTable(new Font("Verdana", 12), countSelectedTasks, 6, 4);

            // Importing datas from the datatables... (also column names for the headers!)
            myPdfTable.ImportDataTable(dataTable);

            // Now we set our Graphic Design: Colors and Borders...
            myPdfTable.HeadersRow.SetColors(Color.FromRgb(255, 255, 255), Color.FromRgb(0, 0, 255));
            myPdfTable.SetColors(Color.FromRgb(0, 0, 0), Color.FromRgb(255, 255, 255), Color.FromRgb(0, 255, 255));
            myPdfTable.SetBorders(Color.FromRgb(0, 0, 0), 1, BorderType.CompleteGrid);

            // With just one method we can set the proportional width of the columns.
            // It's a "percentage like" assignment, but the sum can be different from 100.
            myPdfTable.SetColumnsWidth(new int[] { 90, 25, 45, 20, 20, 10 });

            // Now we set some alignment... for the whole table and then, for a column.
            myPdfTable.SetContentAlignment(ContentAlignment.MiddleCenter);
            foreach (PdfColumn pdfColumn in myPdfTable.Columns)
            {
                pdfColumn.SetContentAlignment(ContentAlignment.MiddleLeft);
            }

            // Here we start the loop to generate the table...
            while (!myPdfTable.AllTablePagesCreated)
            {
                // we create a new page to put the generation of the new TablePage:
                PdfPage newPdfPage = myPdfDocument.NewPage();

                // LAKHA
                PdfArea      pdfArea   = new PdfArea(myPdfDocument, 48, 95, 750, 670);
                PdfTablePage taskTable = myPdfTable.CreateTablePage(pdfArea);

                // we also put a Label
                PdfTextArea reportTitle = new PdfTextArea(new Font("Verdana", 26, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                          , new PdfArea(myPdfDocument, 48, 20, 595, 60), ContentAlignment.TopLeft, ReportResource.ReportTitle);

                // LAKHA - Status
                PdfTextArea statusText = new PdfTextArea(new Font("Verdana", 14, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                         , new PdfArea(myPdfDocument, 48, taskTable.CellArea(taskTable.LastRow, 6 - 1).BottomRightCornerY + 10, 595, 60), ContentAlignment.TopLeft,
                                                         _noiseLevelService.GetNoiseLevelStatusText(noiseLevelEnum));

                // LAKHA - Total prosent
                PdfRectangle summaryBackground = new PdfArea(myPdfDocument, 635, taskTable.CellArea(taskTable.LastRow, 6 - 1).BottomRightCornerY + 10, 165, 45).ToRectangle(noiseLevelColor, noiseLevelColor);
                PdfTextArea  summary           = new PdfTextArea(new Font("Verdana", 26, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                                 , new PdfArea(myPdfDocument, 640, taskTable.CellArea(taskTable.LastRow, 6 - 1).BottomRightCornerY + 20, 595, 60), ContentAlignment.TopLeft,
                                                                 string.Format(ReportResource.TotalPercentageFormatString, totalNoiseDosage));

                // nice thing: we can put all the objects in the following lines, so we can have
                // a great control of layer sequence...
                newPdfPage.Add(taskTable);
                newPdfPage.Add(reportTitle);
                newPdfPage.Add(statusText);
                newPdfPage.Add(summaryBackground);
                newPdfPage.Add(summary);

                // Info from report input window
                PdfTextArea reportPlant = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                          , new PdfArea(myPdfDocument, 48, 50, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.PlantFormatString, reportInfo.Plant));
                PdfTextArea reportCreatedBy = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                              , new PdfArea(myPdfDocument, 650, 50, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.UserFormatString, reportInfo.CreatedBy));

                PdfTextArea reportProfession = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                               , new PdfArea(myPdfDocument, 48, 65, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.ProfessionFormatString, reportInfo.Group));
                PdfTextArea reportDate = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                         , new PdfArea(myPdfDocument, 650, 65, 595, 60), ContentAlignment.TopLeft, string.Format(ReportResource.DateFormatString, (reportInfo.Date.HasValue) ? reportInfo.Date.Value.ToString("dd.MM.yyyy") : string.Empty));

                PdfTextArea reportComment = new PdfTextArea(new Font("Verdana", 12, FontStyle.Bold), Color.FromRgb(0, 0, 0)
                                                            , new PdfArea(myPdfDocument, 48, 80, 700, 60), ContentAlignment.TopLeft, string.Format(ReportResource.CommentFormatString, reportInfo.Comment));

                newPdfPage.Add(reportPlant);
                newPdfPage.Add(reportCreatedBy);
                newPdfPage.Add(reportProfession);
                newPdfPage.Add(reportDate);
                newPdfPage.Add(reportComment);


                // LAKHA - Add footnotes...
                const int widthOfFootnote = 750;
                Font      footnoteFont    = new Font("Verdana", 9, FontStyle.Regular);
                double    posY            = statusText.PdfArea.BottomRightCornerY + 3;

                foreach (string footNoteText in reportInfo.Footnotes)
                {
                    int heightOfFootnote = 10;

                    if (footNoteText.Length > 380)
                    {
                        heightOfFootnote = heightOfFootnote * 3;
                    }
                    else if (footNoteText.Length > 160)
                    {
                        heightOfFootnote = heightOfFootnote * 2;
                    }

                    PdfArea     pdfAreaForText = new PdfArea(myPdfDocument, 48, posY, widthOfFootnote, heightOfFootnote);
                    PdfTextArea footNote       = new PdfTextArea(footnoteFont, Color.FromRgb(0, 0, 0), pdfAreaForText, ContentAlignment.TopLeft, string.Format("* {0}", footNoteText));
                    newPdfPage.Add(footNote);

                    posY = footNote.PdfArea.BottomRightCornerY + 2;
                }

                // we save each generated page before start rendering the next.
                newPdfPage.SaveToDocument();
            }


            // Finally we save the docuement...
            Stream memoryStream = new MemoryStream();

            myPdfDocument.SaveToStream(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);

            return(memoryStream);
        }
Beispiel #13
0
		/// <summary>
		/// created a new line to put inside a PdfPage
		/// </summary>
		/// <param name="Start">the starting point of the line</param>
		/// <param name="End">the ending point of the line</param>
		/// <param name="Color">the Color of the line</param>
		/// <param name="StrokeWidth">the width of the stroke</param>
		public PdfLine(PdfDocument PdfDocument,PointF Start,PointF End,Color Color,double StrokeWidth)
		{
			this.PdfDocument=PdfDocument;
			if (StrokeWidth<=0) throw new Exception("StrokeWidth must be greater than zero.");
			this.start=Start;
			this.end=End;
			this.color=Color;
			this.strokeWidth=StrokeWidth;
		}
    protected void btndummynoprint_Click(object sender, EventArgs e)
    {
        try
        {
            ArrayList            adddummyarray = new ArrayList();
            Gios.Pdf.PdfDocument mydoc;
            Font Fontbold    = new Font("Book Antiqua", 18, FontStyle.Regular);
            Font fbold       = new Font("Book Antiqua", 18, FontStyle.Bold);
            Font Fontsmall   = new Font("Book Antiqua", 12, FontStyle.Regular);
            Font fontname    = new Font("Book Antiqua", 11, FontStyle.Bold);
            Font fontmedium  = new Font("Book Antiqua", 10, FontStyle.Regular);
            Font fontmediumb = new Font("Book Antiqua", 8, FontStyle.Bold);
            mydoc = new Gios.Pdf.PdfDocument(PdfDocumentFormat.InCentimeters(24, 30));
            Gios.Pdf.PdfPage mypdfpage;
            //  Gios.Pdf.PdfTable table1 = myprovdoc.NewTable(Fontsmall, prov_cnt + 8, 6, 1);
            Gios.Pdf.PdfTable     table;
            Gios.Pdf.PdfTable     table1;
            Gios.Pdf.PdfTablePage myprov_pdfpage1;
            string deptvalue = "";
            Fpspread1.SaveChanges();

            int    prinsheetno   = 0;
            string getmaxsheetno = d2.GetFunction("select isnull(max(sheet_no),'10000') from dummynumber where exam_year='" + ddlYear.SelectedValue.ToString() + "' and exam_month='" + ddlMonth.SelectedValue.ToString() + "' ");
            int    strshetno     = Convert.ToInt32(getmaxsheetno);
            if (Fpspread1.Sheets[0].RowCount > 0)
            {
                for (int row = 0; row < Fpspread1.Sheets[0].RowCount; row++)
                {
                    string getval = Fpspread1.Sheets[0].Cells[row, 2].Tag.ToString();
                    if (getval == "1")
                    {
                        adddummyarray.Add(Convert.ToString(Fpspread1.Sheets[0].Cells[row, 2].Text));
                    }
                    else
                    {
                        adddummyarray.Add(Convert.ToString(Fpspread1.Sheets[0].Cells[row, 3].Text));
                    }
                    string dummyno = Fpspread1.Sheets[0].Cells[row, 3].Tag.ToString();
                    if (dummyno == "")
                    {
                        if ((row % 25) == 0)
                        {
                            strshetno++;
                        }
                        dummyno = strshetno.ToString();
                        string insertval = "update dummynumber set sheet_no='" + dummyno + "' where dummy_no='" + Fpspread1.Sheets[0].Cells[row, 3].Text.ToString() + "'";
                        int    val       = d2.update_method_wo_parameter(insertval, "Text");
                    }
                    if (prinsheetno == 0)
                    {
                        prinsheetno = Convert.ToInt32(dummyno);
                    }
                    Fpspread1.Sheets[0].Cells[row, 3].Tag = dummyno;
                }
            }
            Fpspread1.SaveChanges();
            string month = Convert.ToString(ddlMonth.SelectedItem.Text);
            string year  = Convert.ToString(ddlYear.SelectedItem.Text);
            string dept  = "";
            if (chklstbranch.Items.Count > 0)
            {
                for (int ros = 0; ros < chklstbranch.Items.Count; ros++)
                {
                    if (chklstbranch.Items[ros].Selected == true)
                    {
                        dept = Convert.ToString(chklstbranch.Items[ros].Text);
                    }
                }
            }
            string course = Convert.ToString(Fpspread1.Sheets[0].Cells[0, 4].Text);
            deptvalue = Convert.ToString(Fpspread1.Sheets[0].Cells[0, 5].Text);
            string semval      = Convert.ToString(Fpspread1.Sheets[0].Cells[0, 4].Tag);
            string subjectname = ddlsubject.SelectedItem.Text;
            string subjectcode = ddlsubject.SelectedItem.Value;


            PdfTextArea ptc4 = new PdfTextArea(Fontsmall, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 515, 0, 113, 30), System.Drawing.ContentAlignment.MiddleCenter, prinsheetno.ToString());

            PdfTextArea ptc5 = new PdfTextArea(Fontsmall, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 515, 30, 113, 20), System.Drawing.ContentAlignment.MiddleCenter, month + " " + year);

            int y = 48;

            PdfTextArea ptde = new PdfTextArea(fontmedium, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 120, y, 100, 30), System.Drawing.ContentAlignment.MiddleLeft, "" + course + "");

            PdfTextArea ptc = new PdfTextArea(fontmedium, System.Drawing.Color.Black,
                                              new PdfArea(mydoc, 303, y, 350, 30), System.Drawing.ContentAlignment.MiddleLeft, "" + deptvalue + "");

            PdfTextArea psem = new PdfTextArea(fontmedium, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 544, y, 200, 30), System.Drawing.ContentAlignment.MiddleLeft, "" + semval + "");

            y = y + 20;
            PdfTextArea ptc1 = new PdfTextArea(fontmedium, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 120, y, 350, 30), System.Drawing.ContentAlignment.MiddleLeft, "" + subjectname + "");

            PdfTextArea ptc2 = new PdfTextArea(fontmedium, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 544, y, 200, 30), System.Drawing.ContentAlignment.MiddleLeft, "" + subjectcode + "");
            if (adddummyarray.Count > 0)
            {
                int rowcount   = 0;
                int totalcount = adddummyarray.Count;
                while (totalcount > 25)
                {
                    if (rowcount > 24)
                    {
                        prinsheetno++;
                        ptc4 = new PdfTextArea(Fontsmall, System.Drawing.Color.Black,
                                               new PdfArea(mydoc, 515, 2, 113, 30), System.Drawing.ContentAlignment.MiddleCenter, prinsheetno.ToString());
                    }
                    totalcount = totalcount - 25;
                    table      = mydoc.NewTable(Fontsmall, 13, 1, 10);
                    for (int row = 0; row < 13; row++)
                    {
                        string getvalue = Convert.ToString(adddummyarray[rowcount]);
                        table.Cell(row, 0).SetContent(getvalue);
                        table.Cell(row, 0).SetContentAlignment(ContentAlignment.MiddleLeft);
                        table.Cell(row, 0).SetCellPadding(11);
                        rowcount++;
                    }
                    table1 = mydoc.NewTable(Fontsmall, 12, 1, 10);
                    for (int row = 0; row < 12; row++)
                    {
                        string getvalue = Convert.ToString(adddummyarray[rowcount]);
                        table1.Cell(row, 0).SetContent(getvalue);
                        table1.Cell(row, 0).SetCellPadding(11);
                        rowcount++;
                    }
                    mypdfpage       = mydoc.NewPage();
                    myprov_pdfpage1 = table.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 50, 150, 100, 500));
                    mypdfpage.Add(myprov_pdfpage1);

                    myprov_pdfpage1 = table1.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 340, 150, 100, 500));
                    mypdfpage.Add(myprov_pdfpage1);
                    mypdfpage.Add(ptc);
                    mypdfpage.Add(ptc1);
                    mypdfpage.Add(ptc2);
                    mypdfpage.Add(ptc4);
                    mypdfpage.Add(ptc5);
                    mypdfpage.Add(ptde);
                    mypdfpage.Add(psem);
                    mypdfpage.SaveToDocument();
                }
                bool check         = false;
                int  subtotalcount = totalcount;
                int  value         = 0;
                mypdfpage = mydoc.NewPage();
                if (subtotalcount >= 13)
                {
                    value = subtotalcount - 13;
                    check = true;
                }
                if (check == true)
                {
                    prinsheetno++;
                    ptc4 = new PdfTextArea(Fontsmall, System.Drawing.Color.Black,
                                           new PdfArea(mydoc, 515, 2, 113, 30), System.Drawing.ContentAlignment.MiddleCenter, prinsheetno.ToString());

                    table = mydoc.NewTable(Fontsmall, 13, 1, 10);
                    for (int row = 0; row < 13; row++)
                    {
                        string getvalue = Convert.ToString(adddummyarray[rowcount]);
                        table.Cell(row, 0).SetContent(getvalue);
                        rowcount++;
                    }
                    myprov_pdfpage1 = table.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 50, 150, 100, 500));
                    mypdfpage.Add(myprov_pdfpage1);
                }
                else
                {
                    prinsheetno++;
                    ptc4 = new PdfTextArea(Fontsmall, System.Drawing.Color.Black,
                                           new PdfArea(mydoc, 515, 2, 113, 30), System.Drawing.ContentAlignment.MiddleCenter, prinsheetno.ToString());
                    table = mydoc.NewTable(Fontsmall, subtotalcount, 1, 10);
                    for (int row = 0; row < subtotalcount; row++)
                    {
                        string getvalue = Convert.ToString(adddummyarray[rowcount]);
                        table.Cell(row, 0).SetContent(getvalue);
                        rowcount++;
                    }
                    myprov_pdfpage1 = table.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 50, 150, 100, 500));
                    mypdfpage.Add(myprov_pdfpage1);
                }
                if (value != 0)
                {
                    table1 = mydoc.NewTable(Fontsmall, value, 1, 10);
                    for (int row = 0; row < value; row++)
                    {
                        string getvalue = Convert.ToString(adddummyarray[rowcount]);
                        table1.Cell(row, 0).SetContent(getvalue);
                        rowcount++;
                    }
                    myprov_pdfpage1 = table1.CreateTablePage(new Gios.Pdf.PdfArea(mydoc, 340, 170, 100, 500));
                    mypdfpage.Add(myprov_pdfpage1);
                }
                mypdfpage.Add(ptc);
                mypdfpage.Add(ptc1);
                mypdfpage.Add(ptc2);
                mypdfpage.Add(ptc4);
                mypdfpage.Add(ptc5);
                mypdfpage.Add(ptde);
                mypdfpage.Add(psem);
                mypdfpage.SaveToDocument();
                string appPath = HttpContext.Current.Server.MapPath("~");
                if (appPath != "")
                {
                    string szPath = appPath + "/Report/";
                    string szFile = "Dummy.pdf";
                    mydoc.SaveToFile(szPath + szFile);
                    Response.ClearHeaders();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + szFile);
                    Response.ContentType = "application/pdf";
                    Response.WriteFile(szPath + szFile);
                }
            }
        }
        catch
        {
        }
    }
		/// <summary>
		/// creates a new rectangle
		/// </summary>
		/// <param name="RectangleArea"></param>
		/// <param name="BorderColor"></param>
		/// <param name="FillingColor"></param>
		public PdfRectangle(PdfDocument PdfDocument,PdfArea RectangleArea,Color BorderColor,Color FillingColor)
		{
			this.PdfDocument=PdfDocument;
			this.rectangleArea=RectangleArea;
			this.BorderColor=BorderColor;
			this.FillingColor=FillingColor;
			this.filled=true;
			this.strokeWidth=1;
		}