将颜色添加到PDF格式的div标签(从aspx页面导出数据) [英] Add color to div tag which is in PDF(Exporting data from aspx page)

查看:78
本文介绍了将颜色添加到PDF格式的div标签(从aspx页面导出数据)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用entrystyle为div中的div添加颜色并使用exitstyle结束样式。但是当我使用exit样式时颜色不显示,也使用颜色不仅仅适用于整个的条目样式那个特定的div。



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.

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();
    }





我的问题是我想使用特定div的颜色并关闭。因为标签之间有一些内容。我想要为网格中的div和内容标题鞋色。



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.

推荐答案

从设计页面添加其工作方式。来自设计页面的设计在导出后反映在PDF文档上......
Added style from design page its working. The designs which are from design page is reflecting on PDF document after exporting...


这篇关于将颜色添加到PDF格式的div标签(从aspx页面导出数据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆