세로 및 가로 방향
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
세로 및 가로 방향

세로 및 가로 방향

IronPDF for Python은 새로운 PDF에 대해 가로 방향 및 세로 방향 페이지 설정을 지원하며, 기존 문서에 대해 페이지별 회전 제어를 제공합니다.

시작하기

새로운 PDFs의 경우, 렌더링 메서드를 호출하기 전에 RenderingOptions.PaperOrientation을(를) 설정하세요. 기존 PDFs의 경우, 개별 페이지 또는 전체 문서를 회전시키려면 로드된 PdfDocument에서 SetPageRotation 또는 SetAllPageRotations을(를) 사용하세요.

코드 이해하기

새로운 PDF

  • PaperOrientation = PdfPaperOrientation.Landscape: PDF를 가로 방향으로 렌더링합니다. 기본 세로 레이아웃으로 돌아가려면 Portrait을(를) 사용하세요.
  • RenderHtmlAsPdf, RenderHtmlFileAsPdf, 그리고 RenderUrlAsPdf와(과) 함께 작동합니다.

기존 PDF

  • PdfDocument.FromFile(path): 기존 PDF 파일을 로드합니다.
  • Pages[0].PageRotation: 첫 번째 페이지의 현재 회전을 읽습니다 (제로 기반 인덱스).
  • SetPageRotation(PageIndex, Rotation): 단일 페이지를 지정된 각도로 회전시킵니다.
  • SetAllPageRotations(Rotation): 문서의 모든 페이지에 동일한 회전을 적용합니다.

회전 값

PdfPageRotation 열거형은 네 가지 옵션을 제공합니다:

값도
None0°
Clockwise9090°
Clockwise180180°
Clockwise270270°
IronPDF for Python을 사용하여 PDF 레이아웃을 맞춤 설정하는 방법을 배우세요!

시작할 준비 되셨나요?

버전:2026.11방금 출시