Archivos HTML a PDF
Convert an entire HTML file into a pixel-perfect PDF with IronPDF for Python’s RenderHtmlFileAsPdf method.
Empezando
To convert an HTML file to PDF, you can use the RenderHtmlFileAsPdf method. This method requires only the path to the local HTML file and returns a PdfDocument object. Este objeto contiene el contenido del archivo HTML, renderizado como si se viera en un navegador web. Asegúrate de que tu HTML contenga marcado válido para evitar problemas de renderizado.
He aquí un ejemplo sencillo de cómo utilizar el método:
Entender el código
ChromePdfRenderer: Este objeto sirve como punto de interacción con el proceso de renderizado. Permite ajustes en la salida del PDF configurando propiedades como encabezados, pies de página, y más.
ChromePdfRenderer: This method takes a path to an HTML file and converts it into aPdfDocument. El PDF generado coincidirá estrechamente con el archivo HTML tal como aparece en un navegador web.save_as: This method saves the newly created PDF document to the specified path on your file system.
Personalización de la salida PDF
ChromePdfRenderer comes with various options for customization, including setting headers, footers, margins, backgrounds, page numbers, etc. For more advanced features and customization, see this code example and learn how to customize PDF output.






