You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Document format conversion
PPT file conversion
Copy page
Download PDF
PPT file conversion

Operator introduction

Description

PPT conversion processor, supports converting PPT/PPTX to PDF and per-page images

Main features

  • Supports converting PPT/PPTX documents to PDF files
  • Supports converting PPT/PPTX to PNG images split by page
  • Automatically handles downloading and uploading for local paths and remote paths (such as TOS/HTTP)
  • Provides conversion timeout control and basic failure fallback

Applicable scenarios

  • Batch convert presentations to PDF for preview or archiving
  • Convert presentations to per-page images for online display or content review

Notes

  • Depends on LibreOffice (soffice command) being installed on the local machine
  • If pdf2image is not installed, the system's pdftoppm tool will be used for image conversion as a fallback
  • Currently supports generating PNG/JPG image formats

Daft invocation

Operator parameters

Input

Input column name

Description

files

Array of input file paths, supports tos, http(s), and local paths.

Output

Outputs an array of processed path strings, corresponding one-to-one with the input; if a single item fails, the corresponding position returns an empty string.

Parameters

If a parameter does not have a default value, it is required

Parameter name

Type

Default value

Description

target_format

str

Target format: "pdf" means only generate PDF, "images" means generate per-page images and return the image folder path.

output_dir

str

Output path, must be provided, can be a local path or TOS path.

convert_time_out

int

600

Conversion timeout (seconds), used to control the execution time of soffice / pdftoppm.

image_dpi

int

200

DPI resolution for image conversion, only effective when target_format="images".

image_format

str

png

Image format, currently supports "png", "jpg", and "jpeg"; only effective when target_format="images".

Examples

The following code demonstrates how to use Daft (for distributed scenarios) to execute the PPT conversion operator.

# Copyright (c) Beijing Volcano Engine Technology Ltd.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.doc import PPTConvert
from daft.las.functions.udf import las_udf

if __name__ == "__main__":
    # The converted files will be saved to the specified TOS path, so you need to set environment variables to ensure write permissions to TOS, including: ACCESS_KEY, SECRET_KEY, TOS_ENDPOINT, TOS_REGION, TOS_TEST_DIR
    TOS_DIR = os.getenv("TOS_DIR", "tos_bucket")
    output_tos_dir = f"tos://{TOS_DIR}/doc/ppt_convert"

    if os.getenv("DAFT_RUNNER", "native") == "ray":
        import logging

        import ray

        def configure_logging():
            logging.basicConfig(
                level=logging.INFO,
                format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
                datefmt="%Y-%m-%d %H:%M:%S.%s".format(),
            )
            logging.getLogger("tracing.span").setLevel(logging.WARNING)
            logging.getLogger("daft_io.stats").setLevel(logging.WARNING)
            logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING)
            logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING)

        ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging})
        daft.set_runner_ray()
    daft.set_execution_config(actor_udf_ready_timeout=600)
    daft.set_execution_config(min_cpu_per_task=0)

    tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com")
    samples = {"pptx": [f"https://{tos_dir_url}/public/shared_doc_dataset/sample.pptx"]}
    df = daft.from_pydict(samples)

    constructor_kwargs = {"target_format": "pdf", "output_dir": output_tos_dir}

    df = df.with_column(
        "pdf",
        las_udf(PPTConvert, construct_args=constructor_kwargs, concurrency=1)(col("pptx")),
    )

    constructor_kwargs = {"target_format": "images", "output_dir": output_tos_dir, "image_format": "jpg"}
    df = df.with_column(
        "images",
        las_udf(PPTConvert, construct_args=constructor_kwargs, concurrency=1)(col("pptx")),
    )
    df.show()

    # ╭────────────────────────────────┬────────────────────────────────┬────────────────────────────────╮
    # │ pptx                           ┆ pdf                            ┆ images                         │
    # │ ---                            ┆ ---                            ┆ ---                            │
    # │ String                         ┆ String                         ┆ String                         │
    # ╞════════════════════════════════╪════════════════════════════════╪════════════════════════════════╡
    # │ https://las-cn-beijing-public… ┆ tos://las-ai-qa-online/qa/tes… ┆ tos://las-ai-qa-online/qa/tes… │
    # ╰────────────────────────────────┴────────────────────────────────┴────────────────────────────────╯
Last updated: 2026.05.12 19:06:37