Cadena HTML a PDF With IronPDF, you can create new PDF documents from simple HTML strings within your .NET project, and IronPDF is able to be used in C#, F#, and VB.NET. Thanks to the use of the ChromePdfRenderer class, you can be sure that any PDF documents you render from HTML strings will come out pixel-perfect. With IronPDF's powerful HTML to PDF conversion features, you create high-quality PDF files tailored to fit your personal needs. The 4 Steps to Converting HTML String to PDF Import the IronPDF library. Initialize a new ChromePdfRenderer object. Use the RenderHtmlAsPdf method. Save the PDF using PdfDocument.SaveAs. See the code example below for more details: The first step to converting an HTML string to a PDF in C# is ensuring that you have the IronPDF library properly set up and working within your project. By including using IronPdf, we make sure we can access the classes needed from the IronPDF library to carry out HTML to PDF conversion. The next line, Installation.EnableWebSecurity = true, is conceptually used to disable local disk access or cross-origin requests, ensuring secure operations. (Note: This line was missing from the example but usually pertains to configuration settings to secure PDF rendering operations.) The example demonstrates how to create an instance of ChromePdfRenderer which handles the conversion of HTML to PDF. The RenderHtmlAsPdf method is used to convert a simple HTML string ("<h1>Hello World</h1>") into a PDF document. This document is saved to the disk using the SaveAs method. In the advanced example, IronPDF is shown to handle HTML content containing external assets such as images, CSS, and JavaScript. To load these assets, the optional BasePath parameter is used, specifying the directory containing the required files. The resulting PDF, which includes the external assets, is saved using the same SaveAs method. This code example highlights IronPDF's ability to handle both basic and complex HTML content, making it an efficient tool for generating PDFs programmatically. Learn to Convert HTML Strings to PDF in C# with IronPDF Ver en GitHub Código https://github.com/iron-software/IronPdf.Examples/tree/main/examples/using-html-to-create-a-pdf Descargar ZIP Tutorial Relacionado Guía de Cómo Hacer Relacionada Documentación de Clase Obtener Paquetes de Idiomas Descargar IronPDF DLL Reportar un problema en esta página ¿Listo para empezar? Nuget Descargas 16,133,208 | Versión: 2025.11 recién lanzado Descarga Gratis de NuGet Descargas totales: 16,133,208 Ver Licencias
Producto completamente funcional Obtén 30 días de producto completamente funcional.Instálalo y ejecútalo en minutos.
Soporte técnico 24/5 Acceso completo a nuestro equipo de soporte técnico durante tu prueba del producto
Producto completamente funcional Obtén 30 días de producto completamente funcional.Instálalo y ejecútalo en minutos.
Soporte técnico 24/5 Acceso completo a nuestro equipo de soporte técnico durante tu prueba del producto