constructor-igor / TechSugar

Tech. Sugar seminars
7 stars 7 forks source link

Convert html to pdf. #250

Closed constructor-igor closed 7 years ago

constructor-igor commented 7 years ago

http://stackoverflow.com/questions/564650/convert-html-to-pdf-in-net

constructor-igor commented 7 years ago
public static Byte[] PdfSharpConvert(String html)
{
    Byte[] res = null;
    using (MemoryStream ms = new MemoryStream())
    {
        var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4);
        pdf.Save(ms);
        res = ms.ToArray();
    }
    return res;
}
constructor-igor commented 7 years ago

iTextSharp sample: http://stackoverflow.com/questions/2822843/itextsharp-html-to-pdf