我想使用可以將Html轉換爲PDF的組件將aspx頁面轉換爲PDF。是否有可能在回發期間重定向aspx頁面的輸出並將其作爲流或字符串發送到HtmlToPdf方法?從aspx下載劫持輸出
0
A
回答
2
protected override void Render(HtmlTextWriter writer)
{
// setup a TextWriter to capture the page markup
TextWriter tw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(tw);
// render the page into our surrogate TextWriter
base.Render(htw);
// convert the TextWriter markup to a string
string pageSource = tw.ToString();
if (convertToPDF)
{
// convert the page markup to a pdf
// eg, byte[] pdfBytes = HtmlToPdf(pageSource);
}
// write the page markup into the output stream
writer.Write(pageSource);
}
0
您是否嘗試發送從「HttpContext.Current.Response.OutputStream;」返回的值在回發中?
0
嗨我認爲這樣做的方法是使用Reponse.Filter屬性來攔截和更改發送到頁面的HTML。
還有視頻教程和示例代碼中都VB.net和C#的ASP.net網站上的此頁面上:
0
你會寫是連接請求的HttpFilter。這是在ASP.NET頁面的Render步驟寫入後可以更改輸出的代碼。
This article顯示瞭如何做到這一點(它們將輸出從HTML更改爲有效的XHTML,但想法相同)。
相關問題
- 1. 劫持CKeditor輸入字段
- 2. 從aspx頁面下載PDF
- 3. Waypoints劫持e.clientY
- 4. 劫持.__ proto__
- 5. RAD中的簽出與劫持文件
- 6. 是否有可能劫持標準出
- 7. 劫持刷新鍵
- 8. 如何劫持String.class
- 9. UiTabBar劫持點擊
- 10. TCP連接劫持
- 11. 從WebClient對象下載.aspx文件
- 12. jsPDF輸出PDF下載
- 13. 下載rpivotTable輸出閃亮
- 14. 將FTP下載到輸出
- 15. 停止會話劫持
- 16. 會話劫持和PHP
- 17. 什麼是dll劫持?
- 18. 會話劫持安全
- 19. 如何避免json劫持
- 20. 點擊劫持漏洞
- 21. 設計劫持401響應
- 22. 劫持React處理函數
- 23. linux內核中斷劫持
- 24. 會話劫持或攻擊?
- 25. jquery自動完成輸入鍵(劫持?)vs firefox
- 26. 如何在ssh會話中劫持tty1的輸入流?
- 27. WPF - 拖拽期間劫持鼠標輸入?
- 28. 從TOleContainer.SaveAsDocument加載輸出
- 29. 從Casperjs中彈出下載
- 30. ClearCase:脫機劫持文件,然後檢出/合併
坦克盧克。這正是我正在尋找的。 – Sanjo 2009-02-12 06:39:46