Learn how to convert an HTML string to a PDF in C# : https://blog.aspose.com/html/convert-html-string-to-pdf-in-csharp/
The following topics are covered in this article:
Learn how to convert an HTML string to a PDF in C# : https://blog.aspose.com/html/convert-html-string-to-pdf-in-csharp/
The following topics are covered in this article:
// This code example demonstrates how to convert an HTML string to a PDF document. | |
string htmlString = @"<h1>Convert HTML to PDF!</h1><br/><h2>This is Sample Heading!</h2><p>This is first paragraph.</p>"; | |
// Initialize PdfSaveOptions | |
var options = new PdfSaveOptions(); | |
// Set the background color | |
options.BackgroundColor = Color.LightSkyBlue; | |
// Invoke the ConvertHTML method to convert the HTML code to PDF | |
Converter.ConvertHTML(htmlString, ".", options, @"C:\Files\Output.pdf"); |