Portre & Manzara Yönelimi
from ironpdf import *
 
# For NEW PDF Documents use PdfPaperOrientation
# PdfPaperOrientation: To choose Landscape or Portrait Orientation in a new PDF document
renderer = ChromePdfRenderer()
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape

new_pdf_from_html = renderer.RenderHtmlAsPdf("<h1> Hello World! </h1>")
new_pdf_from_html_file = renderer.RenderHtmlFileAsPdf("example.html")
new_pdf_from_url = renderer.RenderUrlAsPdf("https://ironpdf.com")

# For EXISTING PDFs use PageRotation
# PageRotation: To rotate a PDF page and all of its contents
existing_pdf = PdfDocument.FromFile("old_report.pdf")

# Get rotation value
get_rotation_first_page = existing_pdf.Pages[0].PageRotation

# Rotate specified page
existing_pdf.SetPageRotation(PageIndex=0, Rotation=PdfPageRotation.Clockwise90)

# Rotate ALL pages
existing_pdf.SetAllPageRotations(PdfPageRotation.Clockwise270)
pip install ironpdf
Portre & Manzara Yönelimi

Portre & Manzara Yönelimi

IronPDF for Python, yeni PDF'ler için hem Yatay hem de Dikey sayfa yönlendirmesini destekler ve mevcut belgeler için sayfa başına döndürme kontrolü sağlar.

Başlarken

Yeni PDF'ler için, herhangi bir renderlama yöntemi çağrılmadan önce RenderingOptions.PaperOrientation ayarlayın. Mevcut PDF'ler için, @@SetPageRotation veya SetAllPageRotations bir yüklenmiş PdfDocument üzerinde bireysel sayfaları veya tüm belgeyi döndürmek için kullanın.

Kodu Anlama

Yeni PDF'ler

  • PaperOrientation = PdfPaperOrientation.Landscape: PDF'yi yatay yönde işler. Varsayılan dikey düzenine dönmek için Portrait kullanın.
  • RenderHtmlAsPdf, RenderHtmlFileAsPdf ve RenderUrlAsPdf ile çalışır.

Mevcut PDF'ler

  • PdfDocument.FromFile(path): Mevcut bir PDF dosyasını yükler.
  • Pages[0].PageRotation: İlk sayfanın (sıfır tabanlı indeks) mevcut dönüş açısını okur.
  • SetPageRotation(PageIndex, Rotation): Belirtilen açıyı tek bir sayfaya uygular.
  • SetAllPageRotations(Rotation): Aynı dönme açısını belgedeki her sayfaya uygular.

Döndürme Değerleri

PdfPageRotation enumerasyonu dört seçenek sağlar:

DeğerDereceler
None0°
Clockwise9090°
Clockwise180180°
Clockwise270270°
IronPDF for Python ile PDF düzenini nasıl özelleştireceğinizi öğrenin!

Başlamaya Hazır mısınız?

Sürüm:2026.10yeni yayınlandı