使用iTextSharp的PDF中的GridView的应用样式 [英] Applying Styles in PDF GridView using itextsharp

查看:130
本文介绍了使用iTextSharp的PDF中的GridView的应用样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打印使用,其中包含如标签和GridView数据到PDF面板的 iTextSharp的在我的网页。但是,如果我不能够将样式应用到GridView。

I'm trying to print a panel which contains data like labels and GridView to a PDF using itextsharp in my webpage. But if i'm not able to apply the styles to the GridView.

你能帮助我吗?

我使用CSS和HTML风格样式我GridView的。

I'm using both css and html styles to style my GridView.

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline;filename=" + filename + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
pnl_print.RenderControl(hw);

StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();

sr.Close();
hw.Close();
sw.Close();

我怎样才能在面板??添加样式的GridView

How can I add styles to Gridview in Panel??

面板ID是pnl_print

Panel ID is pnl_print

GridView控件ID是GV1

GridView ID is gv1

您能帮助我?

推荐答案

我不知道,如果有可能的extranal CSS添加到与iTextSharp的pdf的,但你总是可以创建与iTextSharp的使用的东西frovided一个功能的CSS这样,改写了iTextSharp的CSS类的风格。

I am not sure if it possible to add an extranal css to the pdf with itextsharp, but you can always create a css with a functions frovided by itextsharp using something like this, rewriting the style in the itextsharp css class.

StyleSheet styles = new StyleSheet();
styles.LoadTagStyle("p", "size", "10pt");
styles.LoadTagStyle("p", "color", "#0000ff");     

这篇关于使用iTextSharp的PDF中的GridView的应用样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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