HTML Dosyalarını PDF'ye Dönüştürme
Convert an entire HTML file into a pixel-perfect PDF with IronPDF for Python’s RenderHtmlFileAsPdf method.
Başlarken
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. Bu nesne, web tarayıcısında görüntülenmiş gibi, HTML dosyasının içeriğini barındırır. HTML'nizin geçerli bir işaretleme içerdiğinden emin olunuz, aksi takdirde render sorunları oluşabilir.
İşte bu yöntemin nasıl kullanılacağına basit bir örnek:
Kodu Anlamak
ChromePdfRenderer: Bu nesne, render süreci ile etkileşim noktası olur. Başlıklar, altbilgiler ve daha fazlası gibi özellikleri ayarlayarak PDF çıktısını ayarlamaya olanak tanır.
ChromePdfRenderer: This method takes a path to an HTML file and converts it into aPdfDocument. Oluşturulan PDF, web tarayıcısında yer alan HTML dosyasına yakın bir eşleşme olacaktır.save_as: This method saves the newly created PDF document to the specified path on your file system.
PDF Çıktısını Özelleştirme
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.






