TIFF en PDF avec support multi-pages
La classe ImageToPdfConverter IronPDF for Python prend en charge la conversion des fichiers TIFF en documents PDF. Lorsque vous utilisez ImagePdfConverter.ImageToPdf avec un TIFF contenant plusieurs images, chaque image du TIFF sera placée sur des pages séparées.
Voici un exemple de la façon dont vous pouvez utiliser ImageToPdfConverter pour convertir une image TIFF multi-images en un document PDF :
Explication du code
-
Importation de modules :
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
-
Instance de ImageToPdfConverter :
- An instance of
ImageToPdfConverteris created to utilize itsimage_to_pdfmethod for conversion.
- An instance of
-
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.
- The method
- Sauvegarde du PDF :
- The converted PDF is saved using the
savemethod of thePdfDocumentclass at the specified path.
- The converted PDF is saved using the
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.

