Allows to specify resulting format for HTML to Image converting

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfVision (in SautinSoft.PdfVision.dll) Version: 5.1.2.13

Syntax

      
 C#  Visual Basic 
public enum eImageFormat
Public Enumeration eImageFormat

Members

MemberDescription
Jpeg
Jpeg image
Png
Png image
Gif
Gif image
Bmp24
Bitmap 24-bits

Examples

CopyHow to convert HTML file to PNG file in C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Convert HTML to PNG
            SautinSoft.PdfVision v = new SautinSoft.PdfVision();

            // Set "Edge mode" to support all modern CSS.
            SautinSoft.PdfVision.TrySetBrowserModeEdgeInRegistry();

            v.PageStyle.PageOrientation.Portrait();

            string htmlPath = @"http://nationalzoo.si.edu";
            FileInfo pngFile = new FileInfo("result.png");

            int ret = v.ConvertHtmlFileToImageFile(htmlPath, pngFile.FullName, SautinSoft.PdfVision.eImageFormat.Png);

            // 0 - converting successfully
            // 1 - can't open input file, check the input path
            // 2 - can't create output file, check the output path
            // 3 - converting failed
            if (ret == 0)
            {
                // Open produced PNG in default Viewer.
                System.Diagnostics.Process.Start(pngFile.FullName);
            }
        }
    }
}
CopyHow to convert HTML file to PNG file in VB.Net
Imports System.IO

Namespace Sample
    Friend Class Test

        Shared Sub Main(ByVal args() As String)
            ' Convert HTML to PNG
            Dim v As New SautinSoft.PdfVision()

            ' Set "Edge mode" to support all modern CSS.
            SautinSoft.PdfVision.TrySetBrowserModeEdgeInRegistry()

            v.PageStyle.PageOrientation.Portrait()

            Dim htmlPath As String = "http://nationalzoo.si.edu"
            Dim pngFile As New FileInfo("result.png")

            Dim ret As Integer = v.ConvertHtmlFileToImageFile(htmlPath, pngFile.FullName, SautinSoft.PdfVision.eImageFormat.Png)

            ' 0 - converting successfully
            ' 1 - can't open input file, check the input path
            ' 2 - can't create output file, check the output path
            ' 3 - converting failed
            If ret = 0 Then
                ' Open produced PNG in default Viewer.
                System.Diagnostics.Process.Start(pngFile.FullName)
            End If
        End Sub
    End Class
End Namespace

See Also