I'm working on an application where the requirements call for the app to produce a TIFF image of an HTML document for storage in a document management system. I'm using ASP.NET MVC 3 and am curious if anyone else has run into similar requirements, and if so, how did you address?
Thanks!
This particular solution wasn't suggested in @Select0r's comment above and I believe it's worth mentioning.
I recently ran into this library on CodePlex. It's written completely in managed code without and dependencies and provides HtmlRenderer.Render() function which renders to a Graphics object.
You can use it to render some HTML onto a Bitmap and save it as a TIFF image.
However, this library still isn't perfect and only supports simple layouts.
This article can be help fully to you.
http://www.converthtmltoimage.com/Convert-html-to-tiff-in-vb.net.html
Following sample code shows you how to render html to image (JPG, PNG, TIF, GIF and BMP)
Dim _Obj As New WebsitesScreenshot.WebsitesScreenshot
Dim _Result As WebsitesScreenshot.WebsitesScreenshot.Result
With _Obj
_Result = .CaptureWebpage("http://www.WebsitesScreenshot.com")
If _Result = WebsitesScreenshot.WebsitesScreenshot. _
Result.Captured Then
.ImageFormat = WebsitesScreenshot. _
WebsitesScreenshot.ImageFormats.TIF
.SaveImage("c:\test.tif")
End If
End With
_Obj.Dispose()
Alternate idea: It may be posible to use word automation to save an html document to a PS or PDF printer driver, then convert it to a tiff from there. It may also be useful having a PDF within the document storage system.
来源:https://stackoverflow.com/questions/5249002/render-html-to-tiff