Articles

Affichage des articles associés au libellé c#

How to display Base64 images in HTML with c#

If you need convert image to Data  URL (embedding Image) here the code: Encode to Base64 format public static string GetDataURL ( string imgFile ) { return "<img src=\"data:image/" + Path . GetExtension ( imgFile ). Replace ( "." , "" ) + ";base64," + Convert . ToBase64String ( File . ReadAllBytes ( imgFile )) + "\" />" ; }

Properly Export Html to PDF using iTextsharp c#

iText is a PDF library that allows you to CREATE, ADAPT, INSPECT and MAINTAIN documents in the Portable Document Format (PDF). Export  Html to PDF using iTextsharp Important Note: Make sure, yea, very important make sure that your HTML is well structured and all tags are closed. If not you'll get an error. Usings using System.IO; using iTextSharp.text; using iTextSharp.text.html.simpleparser; using iTextSharp.text.pdf; Create a method called  GetPDF to create PDF stream in memory public static byte[] GetPDF(string pHTML)         {             byte[] bPDF = null;             MemoryStream ms = new MemoryStream();             TextReader txtReader = new StringReader(pHTML);             // 1: create object of a itextsharp document class             Document doc = new Docume...