0

Web ページでitextsharpを使用して、ラベルや GridView などのデータを含むパネルを PDF に印刷しようとしています。しかし、スタイルを GridView に適用できない場合。

手伝って頂けますか??

css と html の両方のスタイルを使用して、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();

Panel の Gridview にスタイルを追加するにはどうすればよいですか??

パネル ID は pnl_print です

GridView ID は gv1

あなたは私を助けることができます ??

4

1 に答える 1

0

itextsharp を使用して外部の css を pdf に追加できるかどうかはわかりませんが、このようなものを使用して、itextsharp css クラスのスタイルを書き換えて、itextsharp によって提供された関数で css をいつでも作成できます。

StyleSheet styles = new StyleSheet();
styles.LoadTagStyle("p", "size", "10pt");
styles.LoadTagStyle("p", "color", "#0000ff");     
于 2012-08-23T05:47:41.177 に答える