Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to add color to div in PDF by using entrystyle and ending the style by using exitstyle.But when i use exit style the color is not showing,also by using the entry style the color applies to whole not only that specific div.

C#
protected void PDf()
    {
        dt1 = DAL.GetAllData(productID, pdvID, UserID);
       
        ProductInformation.InnerText = "Product Information-Version" + versionName;
        //DataListProductInformation.DataSource = dt1.Tables[];
        //DataListProductInformation.DataBind();
        AuditTrails.InnerText="Audit Trails-Version" + versionName;
        DataListAuditTrails.DataSource = dt1.Tables[1];
        DataListAuditTrails.DataBind();
        Comments.InnerText = "Comments-Version" + versionName;
        DataListComments.DataSource = dt1.Tables[2];
        DataListComments.DataBind();
        SupportDocuments.InnerText = "Support Documents-Version" + versionName;
        DataListSupportDocuments.DataSource = dt1.Tables[3];
        DataListSupportDocuments.DataBind();
        ArtworkDocuments.InnerText = "Artwork Documents-Version" + versionName;
        DataListArtworkDocuments.DataSource = dt1.Tables[4];
        DataListArtworkDocuments.DataBind();
        GPRReports.InnerText = "GPR Report-Version" + versionName;
        DataListGPRReports.DataSource = dt1.Tables[5];
        DataListGPRReports.DataBind();
        Annotations.InnerText = "Annotations-Version" + versionName;
        DataListAnnotations.DataSource = dt1.Tables[6];
        DataListAnnotations.DataBind();

        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
       
        textStyle.ForeColor = Color.Blue;
        hw.WriteLine(Statename);//here im adding div id
        hw.EnterStyle(textStyle, HtmlTextWriterTag.Div);//and adding color to div
        Statename.InnerText = "State-Version" + versionName;
        DataListStatename.DataSource = dt1.Tables[0];
        DataListStatename.DataBind();
       //hw.ExitStyle(textStyle, HtmlTextWriterTag.Div);
        bindpdf.RenderControl(hw);
        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);

        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();
    }


my problem is I wanna use color for particular div and close. because there was some content in between the tags. Exactly I wanna shoe color for heading that is div and content in grid.
Posted
Updated 1-Aug-14 3:52am
v2

1 solution

Added style from design page its working. The designs which are from design page is reflecting on PDF document after exporting...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900