支援多頁的 TIFF 至 PDF

IronPDF for Python 的ImageToPdfConverter類別支援將 TIFF 檔案轉換為 PDF 文件。 當使用ImagePdfConverter.ImageToPdf處理包含多個幀的 TIFF 檔案時,它會將 TIFF 檔案的每個幀放置在單獨的頁面上。

以下範例展示如何使用ImageToPdfConverter將多幀 TIFF 影像轉換為 PDF 文件:

說明程式碼

1.導入模組

  • PdfDocument and ImageToPdfConverter are imported from the ironpdf package to handle the PDF conversion.
  1. Function convert_tiff_to_pdf(tiff_path: str, pdf_output_path: str):
    • This function takes a TIFF file (via tiff_path) and converts it into a PDF document, saving it to the specified path (pdf_output_path).

3.ImageToPdfConverter實例

  • An instance of ImageToPdfConverter is created to utilize its image_to_pdf method for conversion.
  1. PDF轉換
    • The method image_to_pdf(tiff_path) converts the multi-frame TIFF by placing each frame on a separate page in the resulting PDF.

5.保存 PDF 檔

  • The converted PDF is saved using the save method of the PdfDocument class at the specified path.

'path/to/your/tiff_file.tiff''path/to/output/pdf_document.pdf'替換為您的實際檔案路徑以執行轉換。

學習如何使用 Python 將 PDF 轉換為圖像

準備好開始了嗎?
Version: 2025.9 剛發表