ModaTransform

Documentation / API overview

Generate

Create PDF, PPTX, and DOCX files from structured document descriptions.

Input

A JSON or XML document description

Output

One PDF, PPTX, or DOCX file

Define the document

Your application supplies the content and structure in JSON or XML and selects an output format. Generate produces the document file from that description; it does not require an existing source document.

Output formats

  • PDF for distributing a rendered document.
  • PPTX for an editable PowerPoint presentation.
  • DOCX for an editable Word document.

Request and response

Proposed API contract

Submit the document’s content and structure directly. This example uses JSON; XML is an alternate document representation. Select pdf, pptx, or docx as the output format.

RequestcURL
curl https://api.moda.app/v1/documents/generate \
  -H "Authorization: Bearer $MODA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "pdf",
  "document": {
    "title": "Quarterly report",
    "blocks": [
      {
        "type": "heading",
        "level": 1,
        "text": "Quarterly report"
      },
      {
        "type": "paragraph",
        "text": "Revenue increased by 12% this quarter."
      }
    ]
  }
}'

The request starts a job. Poll the returned poll_url until the status is completed or failed. See the shared job lifecycle.

Completed jobJSON
{
  "id": "job_generate_example",
  "status": "completed",
  "result": {
    "file": {
      "url": "https://files.example.com/report.pdf",
      "format": "pdf"
    },
    "warnings": []
  }
}

Fields

to
The output file format.
document
A JSON document description; this example contains a title and ordered blocks.
document.blocks
The content to render. Here, a heading followed by a paragraph.
result.file
The generated document’s download URL and format.

Example workflow

  1. Collect the content for a report in your application.
  2. Describe the report as JSON or XML.
  3. Select PDF, PPTX, or DOCX and generate the file.

Use Generate when structured input defines a new document. Use Convert when you start with a PDF, HTML, or raster document and need another representation.