TIFF para PDF com suporte a várias páginas
A classe ImageToPdfConverter do IronPDF for Python oferece suporte à conversão de arquivos TIFF em documentos PDF. Ao usar ImagePdfConverter.ImageToPdf com um TIFF contendo vários quadros, cada quadro do TIFF será colocado em páginas separadas.
Aqui está um exemplo de como você pode usar o ImageToPdfConverter para converter uma imagem TIFF com vários quadros em um documento PDF:
Explicação do código
-
Importação de módulos :
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
-
Instância ImageToPdfConverter :
- An instance of
ImageToPdfConverteris created to utilize itsimage_to_pdfmethod for conversion.
- An instance of
-
Conversão para 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
- Salvando o PDF :
- The converted PDF is saved using the
savemethod of thePdfDocumentclass at the specified path.
- The converted PDF is saved using the
Substitua 'path/to/your/tiff_file.tiff' e 'path/to/output/pdf_document.pdf' pelos caminhos reais dos seus arquivos para realizar a conversão.

