In this video I am going to show how can Convert HTML to PDF with SQL Data in C# dynamically. Using iText7 library we can Generate PDF document from SQL very easily.
Subscribe for more code samples and tutorials like this:
#htmltopdf
#CodeSample
#pdffromsql
In this tutorial I have used the following tools
1. Visual Studio 2019 Community Edition
2. itext7 HTML to PDF NuGet library
Download Source
…(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
Thanks for the tutorial. Can you guide how to add watermark through program and how to change PDF page size and orientation?
Hello! What if I have much more data rows on view? How can I divide them to multiple pages? Thank you
Hi guys, literally tried to execute and got this error back:
HtmlConverter.ConvertToPdf(html, new FileStream(destination, FileMode.Create), cp);
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'C:SQLTOPDFSQLTOPDFReport8dbd1958-0712-4410-821a-7c50c31d364e.pdf'.'
This exception was originally thrown at this call stack:
[External Code]
pdf2.pdf.CreatePDFFromDatabase(string, string, string) in pdf.aspx.cs
pdf2.pdf.btnPDF_Click(object, System.EventArgs) in pdf.aspx.cs
[External Code]
Thank u very much for ur explanation.
How can store the PDF in custom URL ?
like currently it is saving in local server and i want to save in a specific folder of hosting site.
Can we do that?
Thanks in advance.
Hello! I used the same code for my project but I'm getting "Object reference not set to an instance of an object." error at HtmlConverter.ConvertToPdf(html, new FileStream(file, FileMode.Create), cp); line, could you please help me with this?
Hi there, Could you share the code please ?
Thank you for the video. Very useful. If we want to add headers and footers?