我想在asp.net中截取Div元素的截圖並將其保存到磁盤。我不想使用html2canvas庫或html5 canvas元素。方法可以是服務器端或客戶端。在asp.net中的div截圖
回答
未經檢驗的,但發現這一點:
public Bitmap GenerateScreenshot(string url, int width, int height)
{
// Load the webpage into a WebBrowser control
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
// Set the size of the WebBrowser control
wb.Width = width;
wb.Height = height;
if (width == -1)
{
// Take Screenshot of the web pages full width
wb.Width = wb.Document.Body.ScrollRectangle.Width;
}
if (height == -1)
{
// Take Screenshot of the web pages full height
wb.Height = wb.Document.Body.ScrollRectangle.Height;
}
// Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
return bitmap;
}
http://pietschsoft.com/post/2008/07/c-generate-webpage-thumbmail-screenshot-image.aspx
我已經通過這段代碼....它是一個基於Windows窗體的函數webbrowser類是存在於system.windows.forms命名空間...並在asp.net中使用Windows窗體將是一個壞主意......無論如何感謝回覆...更多的建議,歡迎:)...我是仍然感到困惑omegle是如何做同樣的事情...喜歡這個鏈接[鏈接](http://logs.omegle.com/f1d8ace) – pgmanutd
你幾乎肯定會需要第三方。 http://phantomjs.org/似乎是最好的支持。只需要一個exe文件。 –
有一些線程的考慮,但加載WebBrowser控件在asp.net中工作得很好。我自己也用過類似的東西。 – LouD
- 1. HTML div截圖?
- 2. asp.net截圖
- 3. ASP.NET - 截圖
- 4. 用DIV與PHP中的圖像截圖
- 5. html2canvas DIV元素的截圖?
- 6. ASP.NET截圖頁面
- 7. ASP.NET屏幕截圖
- 8. asp.net c中的網頁截圖#
- 9. Raphael JS和截圖div
- 10. 如何從asp.net中的網頁表單截取網址截圖?
- 11. ASP.NET - 捕獲屏幕截圖
- 12. 在libgdx中截圖
- 13. 在UncaughtExceptionHandler中截圖
- 14. 在asp.net中Div的問題
- 15. Databound在asp.net中的DIV
- 16. 在php中的截圖
- 17. 在Rails中截取屏幕截圖
- 18. div的背景圖像替換爲在linux中的屏幕截圖Firefox
- 19. 在每個div中截斷段落
- 20. 如何使用phantomJS來截圖div
- 21. 截圖本地HTML5網頁/ DIV
- 22. IOS如何在uiimageview中只截取圖片的截圖
- 23. 試圖在XNA中截取Windows Phone的屏幕截圖
- 24. 在另一個div圖像上設置div圖像asp.net
- 25. 在C中使用selenium webdriver截取屏幕截圖時的空白截圖#
- 26. 在asp.net/c#中使用swf截圖頁面
- 27. 在ASP.Net中截斷模型屬性MVC
- 28. 在ASP.Net中攔截HTTP MVC 2
- 29. 在ASP.NET MVC框架中攔截請求
- 30. 在ASP.NET中使用div
你怎麼在DIV持有? –
div包含一些文字和圖片... – pgmanutd
請求訪問者截取屏幕截圖並上傳它不符合您的要求? :-P(只是爲了安全起見) –