Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-gists/2c50ea64e10936b2463fedc5129de60b to your computer and use it in GitHub Desktop.
Save aspose-com-gists/2c50ea64e10936b2463fedc5129de60b to your computer and use it in GitHub Desktop.
Convert HTML String to PDF in C# | HTML String to PDF C#
// 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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment