Hi All, we 've made lot of research to make this super useful function in c# to convert HTML to PDF,
with help of fantastic free library iTextSharp:
https://sourceforge.net/projects/itextsharp/
With only 6 rows it's done!
Warning!: HTML code must be very clear, simple and clean(CSS was not fully supported, is better use attributes to element if exists)
Example:
<!--lwebcode:inside yout html code-->
<div style='font-size:15px;text-align:left;'>Title Of Page<br/></div> ==> Works
<td align='center' style='width:15%' >cell content</td> ==> DOESN'T Works
<td align='center' width='15%' >cell content</td> ==> Works
//lwebcode:inside *.cs file
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using iTextSharp.tool.xml;
//lwebcode:inside your class lwebcode
private void ConvertHtmlToPdf(string sHTML)
{
Document document = new Document();
PdfWriter.GetInstance(document, new FileStream(Server.MapPath("~/OutPath/TargetName.pdf"), FileMode.Create));
document.Open();
iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
hw.Parse(new StringReader(sHTML));
document.Close();
}
iTextSharp is a good C# HTML to PDF Converter for html to pdf conversion.
ReplyDeleteiDiTect.Converter is another great tool to convert html to pdf in c#
ReplyDeleteThanks for sharing, I also found a good pdf to text C# sdk, which contains HTML to PDF features, a free trial version and a more powerful official version.
ReplyDeletefree html to pdf converterHTML to PDF Converter | Convert from html to pdf online, using SelectPdf web to pdf convert
ReplyDeletehtml to pdfHTML to PDF Converter | Convert from html to pdf online, using SelectPdf web to pdf convert
ReplyDeletehtml to pdf converterHTML to PDF Converter for .NET | Select.Pdf offers a powerful html to pdf converter that can be used in any .NET application to convert any web page or raw html string to pdf
ReplyDeletepdf libraryCreate high quality PDFs with SelectPdf Html To Pdf Converter from the best PDF library. HTML to PDF API also available
ReplyDeletefree html to pdf converter
ReplyDeleteHTML to PDF Converter | Convert from html to pdf online, using SelectPdf web to pdf convert
https://selectpdf.com/category/html-to-pdf/
Html to pdf converter
ReplyDeleteSelectPdf Free Html To Pdf Converter Samples for C# / ASP.NET. Pdf Library for .NET with full sample code in C# and VB.NET.
to get more - https://selectpdf.com/html-to-pdf/demo/