TIFF en PDF avec support multi-pages

La classe ImageToPdfConverter d'IronPDF pour Python prend en charge la conversion de fichiers TIFF en documents PDF. Lorsque vous utilisez ImagePdfConverter.ImageToPdf avec un TIFF contenant plusieurs images, il placera chaque image du TIFF sur des pages séparées.

Voici un exemple de la façon dont vous pouvez utiliser le ImageToPdfConverter pour convertir une image TIFF multi-image en un document PDF :

Explication du code

  1. Importation de modules :

    • 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. Instance de ImageToPdfConverter :

    • An instance of ImageToPdfConverter is created to utilize its image_to_pdf method for conversion.
  4. Conversion 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. Sauvegarde du PDF :
    • The converted PDF is saved using the save method of the PdfDocument class at the specified path.

Remplacez 'path/to/your/tiff_file.tiff' et 'path/to/output/pdf_document.pdf' par vos chemins de fichiers réels pour effectuer la conversion.

Apprendre à convertir un PDF en image avec Python

Prêt à commencer?
Version : 2025.9 vient de sortir