gpt4 book ai didi

asp.net-mvc - 如何使用 MVC 截取网站的屏幕截图?

转载 作者:行者123 更新时间:2023-12-02 04:59:30 27 4
gpt4 key购买 nike

我正在努力寻找一种在 MVC4 中截取网站屏幕截图的方法。我见过两种可能的解决方案,它们都不适用于 MVC。

首先是使用WebBrowser,教程找到here ,但这给了我一个 ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment 错误。

另一个正在使用名为 Grabz.It 的第三方, 但我还没有找到将它集成到 MVC 中的方法。

还有其他想法/解决方案吗?

谢谢。

最佳答案

鉴于您的其他详细信息,您应该能够使用任意数量的工具来完成此操作。 CodeCaster 的想法很好,PhantomJS 也提供类似的基于 webkit 的图像生成任意 url ( https://github.com/ariya/phantomjs/wiki/Screen-Capture )。它提供多种输出格式选项,例如 PNG、JPG、GIF 和 PDF。

Since PhantomJS is using WebKit, a real layout and rendering engine, it can capture a web page as a screenshot. Because PhantomJS can render anything on the web page, it can be used to convert contents not only in HTML and CSS, but also SVG and Canvas.

您需要从您的 MVC 应用程序执行 phantomjs.exe 应用程序,或者可能更好的是通过在后台运行的某些服务来处理提交的 url 队列。

关于asp.net-mvc - 如何使用 MVC 截取网站的屏幕截图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17347451/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com