Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

Updated Wiki: Documentation

$
0
0
Cross framework, Multipurpose, 100% managed (C#), High performance HTML Rendering library.

Navigation

Quick start

Install

Download the latest release zip, worth having around for the Demo application.
Either reference the proper DLL's from the downloaded release zip: HtmlRenderer.dll and one of: HtmlRenderer.WinForms.dll, HtmlRenderer.WPF.dll, HtmlRenderer.PdfSharp.dll. Note: add the targeted framework dlls you are targeting in your project, for PdfSharp you will also need to download PdfSharp dll.
Or, simply install the proper NuGet package using Visual Studio or command line:

WinForms HtmlPanel

In form (Form1) add the following:
publicpartialclass Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        TheArtOfDev.HtmlRenderer.WinForms.HtmlPanel htmlPanel = new TheArtOfDev.HtmlRenderer.WinForms.HtmlPanel();
        htmlPanel.Text = "<p><h1>Hello World</h1>This is html rendered text</p>";
        htmlPanel.Dock = DockStyle.Fill;
        Controls.Add(htmlPanel);
    }
}

WPF HtmlPanel

In window (Window1) XAML add the following:
<Windowx:Class="Window1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="Window1"Height="300"Width="300"xmlns:wpf="clr-namespace:TheArtOfDev.HtmlRenderer.WPF;assembly=HtmlRenderer.WPF"><Grid><wpf:HtmlPanelText="&lt;p&gt; &lt;h1&gt; Hello World &lt;/h1&gt; This is html rendered text&lt;/p&gt;"/></Grid></Window>

Generate Image

Add the following snippet in your main method: (for more advance usage see Image generation)
class Program
{
    privatestaticvoid Main(string[] args)
    {
        Image image = TheArtOfDev.HtmlRenderer.WinForms.HtmlRender.RenderToImage("<p><h1>Hello World</h1>This is html rendered text</p>");
        image.Save("image.png", ImageFormat.Png);
    }
}

Generate PDF

Add the following snippet in your main method: (for more advance usage see PDF generation)
class Program
{
    privatestaticvoid Main(string[] args)
    {
        PdfDocument pdf = PdfGenerator.GeneratePdf("<p><h1>Hello World</h1>This is html rendered text</p>", PageSize.A4);
        pdf.Save("document.pdf");
    }
}

Demo application


Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>