class Program
{
static async Task Main(string[] args)
{
var html = "<html><body><h2>Hello World!</h2></body></html>";
await new HtmlConverter().ToImageAsync(html, "test.png");
await new HtmlConverter().ToPdfAsync(html, "test.pdf");
}
}
class Program
{
static async Task Main(string[] args)
{
var html = "<html><body><h2>Hello World!</h2></body></html>";
await new HtmlToPdfConverter().ConvertAsync(html, "test.pdf");
}
}
class Program
{
static async Task Main(string[] args)
{
var html = "<html><body><h2>Hello World!</h2></body></html>";
await new HtmlToImageConverter().ConvertAsync(html, "test.png");
}
}
Setup:
public void ConfigureServices(IServiceCollection services)
{
services.UseWkHtmlConverter();
}
or
public void ConfigureServices(IServiceCollection services)
{
services.UseWkHtmlToImageConverter();
services.UseWkHtmlToPdfConverter();
}
Injection:
public class Test
{
private readonly IHtmlConverter htmlConverter;
public Test(IHtmlConverter htmlConverter)
{
this.htmlConverter = htmlConverter;
}
}
or
public class Test
{
private readonly IHtmlToImageConverter htmlImageConverter;
private readonly IHtmlToPdfConverter htmlPdfConverter;
public Test(IHtmlToImageConverter htmlImageConverter, IHtmlToPdfConverter htmlPdfConverter)
{
this.htmlImageConverter = htmlImageConverter;
this.htmlPdfConverter = htmlPdfConverter;
}
}