带多页支持的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.
  2. 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.
  4. 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 刚刚发布