Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

.Net render html as image

I'm getting data back from my server in a SQLDataReader as you see below...
The item coming back is 1 record, one field of data.
It's basically the layout of some HTML for Email Campaigns
(<div style="width:100%;"><Table   etc....)

The table HTML will have varying widths from 500px to 700px

Is there any way to place that HTML string  in a label and set the "viewing scale" to 50%?
When I try lblID.width=300 it just goes to whatever the HTML width is anyway.

'VB CODE TO LOAD LABEL
'=============================================================
Blah...blah...blah...
Dim dR As SqlDataReader
        dR = oCom.ExecuteReader()
        dR.Read()
        If dR.HasRows Then
            lblID.Text = dR("templateHTML")
        Else
\blah...blah...blah...
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

DaveBaldwin:
Thanks.  The email templates have been in place for a year+ and work fine.

What I'm trying to do is give a "preview" of the template on a smaller scale when the campaign is being set up.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
DaveBaldwin:
That's not going to do it either.  We already has 85 templates and many more to come.

I'm thinking that I'll figure out how to do a Telerik radTreeview with a Tooltip like shown at http://demos.telerik.com/aspnet-ajax/tooltip/examples/tooltiptreeview/defaultcs.aspx

Was hoping for something quicker.

If no further comments I'll awrd points to you for your first reply.
I have a less elegant version running on my website.  It's done in javascript ( Simple Image Trail script- By JavaScriptKit.com ) but it still requires the images to be made.
it is much simpler than that
use the DrawToBitmap method of the WebBrowser control
some sample code
just drag a picturebox1 to the form
Public Class Form1
    Private wb As WebBrowser = New WebBrowser

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        wb.Height = 100
        wb.Width = 100
        wb.ScrollBarsEnabled = False
        PictureBox1.BackgroundImageLayout = ImageLayout.Zoom
        AddHandler (wb.DocumentCompleted), AddressOf wb_DocumentCompleted
        wb.Url = New Uri("http://www.google.com")
    End Sub

    Private Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
        wb.Size = wb.Document.Body.ScrollRectangle.Size

        Dim bmp As Bitmap = New Bitmap(wb.Size.Width, wb.Size.Height)
        wb.DrawToBitmap(bmp, New Rectangle(wb.Location.X, wb.Location.Y, wb.Width, wb.Height))
        PictureBox1.BackgroundImage = bmp
    End Sub

End Class

Open in new window

bansidhar:
That code is for a windows form right?  I'm working in a Web Form
Thanks