Format my label

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Format my label

bryan1709
Hi guys.

I'm trying to format my label i inserted into my pdf. However my label is written within a datareader method in asp.net, c#.

For example this line of code

table.AddCell("Full Name:\r\r" + dr[0].ToString());

I'm trying to bold the word Full Name. Unfortunately after looking through various tutorials, it seems like using chunk doesn't make the word bold as i believe it could be because the label is within a datareader method. Hence i'm wondering if anyone got any idea how to format the label? I have been trying to format the border=0 as well but it doesn't seem to work as the cell is added inside a datareader method. I have pasted my back-end code on converting value into PDF. Any help or assistance are greatly appreciated.

_________________________________________________________________________________________

 protected void btnPDF_Click(object sender, EventArgs e)
        {

            var doc1 = new Document();
            var filename = "MyTestPDF" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".pdf";
            var output = new FileStream(Path.Combine("C:\\Users\\apr12mpsip\\Desktop\\New folder",    filename), FileMode.Create);
            PdfWriter.GetInstance(doc1, output);
            doc1.Open();

            PdfPTable table = new PdfPTable(2);
            table.TotalWidth = 585f;
            table.LockedWidth = true;

            var logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/image/logo.jpg"));
            doc1.Add(logo);

            var titleFont = FontFactory.GetFont("Arial", 18, Font.BOLD);
            doc1.Add(new Paragraph("Official Report. Member Report ID : " + DDLCase.SelectedValue, titleFont));


            SqlConnection con = new SqlConnection("Data Source = localhost; Initial Catalog = project; Integrated Security = SSPI");

            SqlCommand cm = new SqlCommand("Select lro.fullname, lro.contact, mr.typeofcrime, mr.location,mr.crdatetime, pr.policeid,  pr.prdatetime, pr.policereport, mr.citizenreport, aor.officialreport from MemberReport mr, PoliceReport pr, LoginRegisterOthers lro, AdminOfficialReport aor where mr.memberreportid = '" + DDLCase.SelectedValue + "' and mr.memberreportid=pr.memberreportid and pr.policereportid=aor.policereportid", con);
            con.Open();
            SqlDataReader dr;

            dr = cm.ExecuteReader();

            if (dr.Read())
            {
               
                table.AddCell("Full Name:\r\r" + dr[0].ToString());
                table.AddCell("Contact :\r\r " + dr[1].ToString());
                table.AddCell("Type Of Crime :\r\r " + dr[2].ToString());
                table.AddCell("Location :\r\r " + dr[3].ToString());
                table.AddCell("PoliceID :\r\r " + dr[4].ToString());
                table.AddCell("Police Report Date Time :\r\r " + dr[5].ToString());
                table.AddCell("Police Report :\r\r " + dr[6].ToString());
                table.AddCell("Citizen Report :\r\r" + dr[7].ToString());
                table.AddCell("Admin Official Report :\r\r" + dr[8].ToString());
           
            }

            dr.Close();
            doc1.Add(table);
            doc1.Close();
            btnPDF.Enabled = false;
        }
    }
Loading...