TIFF to PDF with Multi-Page Support
IronPDF for Python's ImageToPdfConverter
class supports the conversion of TIFF files into PDF documents. When using ImagePdfConverter.ImageToPdf
with a TIFF containing multiple frames, it will place each frame of the TIFF on separate pages.
Here is an example of how you can use the ImageToPdfConverter
to convert a multi-frame TIFF image into a PDF document:
Explanation of the Code
Importing Modules:
PdfDocument
andImageToPdfConverter
are imported from theironpdf
package 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 Instance:
- An instance of
ImageToPdfConverter
is created to utilize itsimage_to_pdf
method for conversion.
- An instance of
PDF Conversion:
- 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
- Saving the PDF:
- The converted PDF is saved using the
save
method of thePdfDocument
class at the specified path.
- The converted PDF is saved using the
Replace 'path/to/your/tiff_file.tiff'
and 'path/to/output/pdf_document.pdf'
with your actual file paths to perform the conversion.