> ## Documentation Index
> Fetch the complete documentation index at: https://adp-doc.laiye.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 文档转换（同步）

> 将 PDF、DOC/DOCX、XLS/XLSX、PPT/PPTX、OFD 或常见图片转换为页面图片；XLSX 也可能返回原生电子表格结构。file_url 与 file_base64 必须二选一。

当前实现限制输入最大 50 MiB、最多 260 页；同步请求可能在约 120 秒达到服务超时，生产集成优先使用异步创建与查询接口。失败分支可能以 HTTP 200、code=success、data=null 返回，调用方必须确认 data 存在，并检查 task_id、img_detail_list 或电子表格结构字段。返回 URL 当前通常约 1 小时有效，应及时下载。




## OpenAPI

````yaml api-reference/adp-api.yaml POST /open/agentic_doc_processor/{tenant_name}/v1/doc/convert
openapi: 3.1.0
info:
  title: ADP API
  version: 1.0.0
  description: >-
    Laiye ADP 官方 OpenAPI
    接口规范，覆盖文档抽取、解析与转换，抽取应用管理、Webhook、人机协同、积分查询，以及工作流发现、运行、导出和文件管理。
  license:
    name: MIT
    identifier: MIT
servers:
  - url: https://adp.laiye.com
    description: ADP 生产环境
security: []
tags:
  - name: 文档抽取
    description: 从上传的文档中抽取结构化字段。
  - name: 文档解析
    description: 识别上传文档中的文字、版面块和位置信息。
  - name: 文档转换
    description: 将 PDF、Office、OFD 和图片转换为页面图片或电子表格结构。
  - name: 应用管理
    description: 创建、修改、删除和查询抽取应用及配置。
  - name: Webhook
    description: 查询事件目录并管理事件回调。
  - name: 账户
    description: 查询账户积分和使用情况。
  - name: 工作流
    description: 查询业务工作流模板、运行工作流应用并查询执行结果。
  - name: 工作流文件
    description: 上传和管理工作流应用使用的文件。
  - name: 人机协同
    description: 配置审核触发规则，查询协同任务并提交人工修正。
paths:
  /open/agentic_doc_processor/{tenant_name}/v1/doc/convert:
    post:
      tags:
        - 文档转换
      summary: 文档转换（同步）
      description: >
        将 PDF、DOC/DOCX、XLS/XLSX、PPT/PPTX、OFD 或常见图片转换为页面图片；XLSX
        也可能返回原生电子表格结构。file_url 与 file_base64 必须二选一。


        当前实现限制输入最大 50 MiB、最多 260 页；同步请求可能在约 120
        秒达到服务超时，生产集成优先使用异步创建与查询接口。失败分支可能以 HTTP 200、code=success、data=null
        返回，调用方必须确认 data 存在，并检查 task_id、img_detail_list 或电子表格结构字段。返回 URL 当前通常约 1
        小时有效，应及时下载。
      operationId: convertDocument
      parameters:
        - $ref: '#/components/parameters/TenantName'
      requestBody:
        $ref: '#/components/requestBodies/DocumentConvertRequest'
      responses:
        '200':
          $ref: '#/components/responses/DocumentConvertResponse'
        '422':
          $ref: '#/components/responses/ValidationError'
      security:
        - ApiKeyAuth: []
components:
  parameters:
    TenantName:
      name: tenant_name
      in: path
      required: true
      description: 租户名称，默认 laiye。
      schema:
        type: string
        default: laiye
  requestBodies:
    DocumentConvertRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DocumentConvertRequest'
          examples:
            fileUrl:
              value:
                file_url: https://example.com/invoice.pdf
                scale: 1
                first_convert_page: 1
                last_convert_page: 5
                result_mode: url
            fileBase64:
              value:
                file_base64: JVBERi0xLjQKJcfs...
                result_mode: base64
  responses:
    DocumentConvertResponse:
      description: 文档转换结果。处理中或失败时可能返回空结果或 data=null。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/DocumentConvertResponse'
          example:
            code: success
            message: ''
            tips: null
            data:
              task_id: task_abc123
              img_detail_list:
                - page_num: 1
                  img_base64: ''
                  img_url: https://example.com/temp/task_abc123/page-1.png
                  width: 1240
                  height: 1754
                  preprocess: {}
              total_num: 1
              metadata: {}
              file_type: pdf
              source_file_type: pdf
              spreadsheet_manifest_file_id: ''
              spreadsheet_manifest_url: ''
              view_type: ''
              page_count: 1
              sheet_count: 0
              logical_unit_count: 0
              document_contents: []
              document_details: []
              warnings: []
              billing: {}
    ValidationError:
      description: 参数校验错误。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HTTPValidationError'
          example:
            detail:
              - type: greater_than
                loc:
                  - query
                  - limit
                msg: Input should be greater than 0
                input: 0
                ctx:
                  gt: 0
  schemas:
    DocumentConvertRequest:
      type: object
      additionalProperties: false
      oneOf:
        - title: 使用文件 URL
          required:
            - file_url
        - title: 使用 Base64 文件
          required:
            - file_base64
      properties:
        file_url:
          type: string
          format: uri
          maxLength: 2048
          description: 待转换文件的公网 HTTPS URL。不要传入内网地址或带长期凭证的 URL。
        file_base64:
          type: string
          format: byte
          description: 待转换文件的 Base64 内容。解码后最大 50 MiB。
        scale:
          type: number
          exclusiveMinimum: 0
          default: 1
          description: 页面缩放比例。服务端当前未设置稳定上限，建议使用默认值。
        first_convert_page:
          type: integer
          minimum: 1
          description: 转换起始页，从 1 开始；省略表示从第一页开始。
        last_convert_page:
          type: integer
          minimum: 1
          description: 转换结束页，从 1 开始且不能小于起始页；省略表示到最后一页。
        result_mode:
          type: string
          enum:
            - url
            - base64
          default: url
          description: 页面图片返回方式。URL 为临时结果；Base64 会显著增加响应体。
    DocumentConvertResponse:
      allOf:
        - $ref: '#/components/schemas/SimpleResponse'
        - type: object
          properties:
            data:
              oneOf:
                - $ref: '#/components/schemas/DocumentConvertData'
                - type: 'null'
    HTTPValidationError:
      type: object
      description: FastAPI/Pydantic 请求参数校验错误。
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
      required:
        - detail
    SimpleResponse:
      type: object
      properties:
        code:
          oneOf:
            - type: string
            - type: integer
          description: 业务码。成功通常为 success 或 200。
        message:
          type: string
          description: 返回信息。
        tips:
          type:
            - string
            - 'null'
          description: 详细信息，默认为空。
    DocumentConvertData:
      type: object
      properties:
        task_id:
          type: string
        img_detail_list:
          type: array
          items:
            $ref: '#/components/schemas/DocumentConvertImage'
        total_num:
          type: integer
          minimum: 0
        metadata:
          type: object
          additionalProperties: true
        file_type:
          type: string
          description: 转换结果类型，例如 pdf、image 或 spreadsheet。
        source_file_type:
          type: string
          description: 检测到的源文件扩展类型。
        spreadsheet_manifest_file_id:
          type: string
        spreadsheet_manifest_url:
          type: string
          description: Excel 原生预览 Manifest 临时下载地址。
        view_type:
          type: string
          description: Excel 原生解析时为 spreadsheet。
        page_count:
          type: integer
          minimum: 0
        sheet_count:
          type: integer
          minimum: 0
        logical_unit_count:
          type: integer
          minimum: 0
        document_contents:
          type: array
          items:
            type: string
        document_details:
          type: array
          items: {}
        warnings:
          type: array
          items:
            type: object
            additionalProperties: true
        billing:
          type: object
          additionalProperties: true
      required:
        - task_id
        - img_detail_list
        - total_num
        - metadata
        - file_type
        - source_file_type
        - spreadsheet_manifest_file_id
        - spreadsheet_manifest_url
        - view_type
        - page_count
        - sheet_count
        - logical_unit_count
        - document_contents
        - document_details
        - warnings
        - billing
    ValidationErrorItem:
      type: object
      additionalProperties: true
      properties:
        type:
          type: string
          description: 校验错误类型。
        loc:
          type: array
          description: 错误字段在请求中的位置。
          items:
            oneOf:
              - type: string
              - type: integer
        msg:
          type: string
          description: 可读的错误说明。
        input:
          description: 导致校验失败的输入值。
        ctx:
          type: object
          additionalProperties: true
          description: 校验器提供的补充上下文。
        url:
          type: string
          format: uri
          description: Pydantic 错误说明链接。
      required:
        - type
        - loc
        - msg
    DocumentConvertImage:
      type: object
      properties:
        page_num:
          type: integer
          minimum: 0
        img_base64:
          type: string
          description: result_mode=base64 时的页面图片内容，否则通常为空字符串。
        img_url:
          type: string
          description: result_mode=url 时的临时页面地址，否则通常为空字符串。
        width:
          type: integer
          minimum: 0
        height:
          type: integer
          minimum: 0
        preprocess:
          type: object
          additionalProperties: true
      required:
        - page_num
        - img_base64
        - img_url
        - width
        - height
        - preprocess
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: 生产环境 API Key，可在 ADP 平台的「我的 API」中查看。请确保 API Key 有效且属于生产环境。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.