gpt4 book ai didi

asp.net-mvc - 如何使用 MVC 对网站进行截图?

转载 作者:行者123 更新时间:2023-12-02 21:58:31 26 4
gpt4 key购买 nike

我正在努力寻找一种在 MVC4 中截取网站屏幕截图的方法。我看到了两种可能的解决方案,但它们都不适合 MVC。

第一个是使用WebBrowser,教程找到here ,但这给了我一个ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2'无法实例化,因为当前线程不在单线程单元错误。

另一个正在使用名为 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/

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