I have requirement to convert .html file to PDF format to load in browser.
I have created .HTML file using asp.net C# , I need render that HTML to PDF format in default.aspx page.
How i can convert HTML page to PDF format rendered this PDF format in defualt aspx page with out using any third party controls.

Jayraj ChhayaRank #304 · 8.2K reputationPosted Feb 5, 2024, 7:54 AM EST
To convert an HTML file to PDF format in a Dot Net application, you can use the iTextSharp library. iTextSharp is a free and open-source library that allows you to create and manipulate PDF documents in Dot Net.
Here's an example of how you can use iTextSharp to convert an HTML file to PDF:
using iTextSharp.text; using iTextSharp.text.pdf; using System.IO; // Create a new PDF document Document document = new Document(); // Create a new PDF writer PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("output.pdf", FileMode.Create)); // Open the PDF document document.Open(); // Create an HTMLWorker to parse the HTML file HTMLWorker htmlWorker = new HTMLWorker(document); // Read the HTML file using (TextReader reader = new StreamReader("input.html")) { // Parse the HTML file and add it to the PDF document htmlWorker.Parse(reader); } // Close the PDF document document.Close();You can customize this example to suit your specific requirements, such as specifying the input and output file paths, adding headers and footers, or applying styles to the PDF document.
Leon DRank #851 · 2.6K reputationPosted Feb 6, 2024, 1:22 AM EST
Check this:
https://www.e-iceblue.com/Tutorials/Spire.PDF/Spire.PDF-Program-Guide/Convert-HTML-to-PDF-Customize-HTML-to-PDF-Conversion-by-Yourself.html
Dhiraj PoojaryRank #1,039 · 1.9K reputationPosted Feb 7, 2024, 4:33 AM EST
You may find helpful information regarding HTML to PDF conversion in the following link:
https://stackoverflow.com/questions/564650/convert-html-to-pdf-in-net#:~:text=EDIT%3A%20New%20Suggestion%20HTML%20Renderer%20for%20PDF%20using%20PdfSharp
Abhishek YadavRank #217 · 11.3K reputationPosted Feb 8, 2024, 7:29 AM EST
To convert an HTML page to PDF format in C#, you can make use of the iTextSharp library.
Here's a step-by-step guide on how to do it:
Install the iTextSharp library using NuGet Package Manager or download it from the iText website.
Add a reference to the iTextSharp library in your C# project.
Create a new PDF document using the Document class from the iTextSharp library.