2012-10-11 66 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