带多页支持的TIFF转PDF
IronPDF for Python 的 ImageToPdfConverter 类支持将 TIFF 文件转换为 PDF 文档。 在使用 ImagePdfConverter.ImageToPdf 处理包含多个帧的 TIFF 时,每个 TIFF 的帧将放置在单独的页面上。
以下是使用 ImageToPdfConverter 将多帧 TIFF 图像转换为 PDF 文档的示例:
代码解释
导入模块:
PdfDocumentandImageToPdfConverterare imported from theironpdfpackage to handle the PDF conversion.
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).
- This function takes a TIFF file (via
ImageToPdfConverter 实例:
- An instance of
ImageToPdfConverteris created to utilize itsimage_to_pdfmethod for conversion.
- An instance of
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.
- The method
- 保存 PDF:
- The converted PDF is saved using the
savemethod of thePdfDocumentclass at the specified path.
- The converted PDF is saved using the
将 'path/to/your/tiff_file.tiff' 和 'path/to/output/pdf_document.pdf' 替换为实际的文件路径以执行转换。






