2012-10-11 67 views
0

我需要从.aspx页面创建pdf。在.aspx页面中,用户将在文本框和gridview中输入如此多的值。它也有一些不同部分的标签。我曾使用iTextSharp创建简单的pdf。但在这里,我需要从页面获取值,并需要阅读选项卡控件。所以是可以使用iTextSharp或是否有任何可用于将.aspx转换为pdf的开源DLL ..如何把.aspx页转换成pdf?

给我一些想法吗?

谢谢..

+0

有用的链接 http://stackoverflow.com/questions/8504415/how-to-convert-aspx-to-pdf-using-c –

回答

3

通过使用iTextSharp的图书馆,这可以通过使用HTMLWorker完成:

首先创建字符串构建;

private StringBuilder sb; 

然后添加PDF从文本框的值标题为:

sb.Append("<p style=\"text-align: center;font-size:" + fontSize + "px;font-weight:" + (bold ? "bold" : "normal") + ";\">" + txtHeading + "</p>"); 

然后从文本框的值加受PDF格式为:

sb.Append("<table><tr valign=\"top\"><td>Subj:</td><td style=\"font-size:" + fontSize + "px;font-weight:bold;text-decoration:underline;\">" + txtSubject.text + "</td></tr></table><br />"); 

然后从文本框的值增加的段落:

sb.Append("<p style=\"text-align: left;font-size:" + fontSize + "px;font-weight:" + (bold ? "bold" : "normal") + ";\">" + txtParagraph + "</p><br/>"); 

for tab乐创作取值在String []数组

sb.Append("<table width=\"100%\" cellspacing=\"0\" cellpadding=\"3\" border=\"0.5\"><thead><tr align=\"center\" valign=\"top\">"); 
      foreach (string str in StringArray) 
      { 
       sb.Append("<th><strong>" + str + "</strong></th>"); 
      } 
      sb.Append("</tr></thead>"); 

所以on.You可以创建aspx页面的文本框值的PDF。

0

iText的夏普很容易。关于标签,我不知道,可能是它会工作,因为它适用于传呼,我的意思是所有的营养物质转化的分页,在一个单一的PDF Click Here For Example