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 a PdfDocument. 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.

Bu Eğitimle HTML'yi PDF'ye Dönüştürmeyi Öğrenin!

Başlamaya Hazır mısınız?
Sürüm: 2026.4 yeni yayınlandı
Still Scrolling Icon

Hala Kaydiriyor musunuz?

Hızlı bir kanit mi istiyorsunuz?
bir örnek çalıştır HTML'nizin PDF olduğunu izleyin.