---
title: "file.exportBytes: Export as Bytes — Layout kit command — Kition"
description: "Answers the document as a PDF, PNG, JPEG, HTML, IDML or EPUB file in base64 without writing it; the host writes it as a new file."
canonical: "https://developer.kition.ai/docs/kits/layout/commands/file.exportBytes"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/layout/commands/file.exportBytes](https://developer.kition.ai/docs/kits/layout/commands/file.exportBytes)

# file.exportBytes

**Export as Bytes.** Answers the document as a PDF, PNG, JPEG, HTML, IDML or EPUB file in base64 without writing it; the host writes it as a new file.

- Kit: Layout 0.1.0 (.klayout); reference: [Layout kit commands](https://developer.kition.ai/docs/kits/layout.md)
- Changes the document: no

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `author` | `any` | no |  |
| `background` | `"paper" \| "transparent"` | no | PNG |
| `bleed` | `boolean` | no |  |
| `compressImages` | `boolean` | no | PDF: images as JPEG |
| `cover` | `boolean` | no | EPUB |
| `embedImages` | `boolean` | no | IDML |
| `fixedLayout` | `boolean` | no | EPUB |
| `format` | `"pdf" \| "png" \| "jpg" \| "html" \| "idml" \| "epub"` | no |  |
| `language` | `any` | no |  |
| `marks` | `any` | no | bool \| {crop?: bool, bleed?: bool, pageInfo?: bool} (PDF printer's marks); PDF printer's marks |
| `pages` | `any` | no | "1-3,5" \| [1,3] (PDF, PNG, JPEG: 1-based; pictures default to the first page); PDF, PNG, JPEG: 1-based; pictures default to the first page |
| `ppi` | `integer` | no | PNG, JPEG |
| `quality` | `integer` | no | 1 to 100; JPEG |
| `spreads` | `boolean` | no | PDF: each spread on one sheet |
| `standard` | `"none" \| "x4" \| "a2b"` | no | PDF/X-4, PDF/A-2b |
| `tagged` | `boolean` | no | PDF |
| `title` | `string` | no |  |

## Call through layout_run

```text
layout_run {
  "path": "<file>.klayout",
  "steps": [{ "command": "file.exportBytes" }]
}
```

The required parameters, with placeholders for their types: not a tested example. Optional: `author`, `background`, `bleed`, `compressImages`, `cover`, `embedImages`, `fixedLayout`, `format`, `language`, `marks`, `pages`, `ppi`, `quality`, `spreads`, `standard`, `tagged`, `title`. layout_run answers the step’s result in `completed[i].result`.

## Result

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `bytes` | `number` | no |  |
| `data` | `string` | no |  |
| `files` | `object[]` | no |  |
| `format` | `string` | no |  |

```json
{
  "additionalProperties": true,
  "properties": {
    "bytes": {
      "type": "number"
    },
    "data": {
      "type": "string"
    },
    "files": {
      "items": {
        "additionalProperties": true,
        "properties": {
          "data": {
            "type": "string"
          },
          "page": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "format": {
      "type": "string"
    }
  },
  "type": "object"
}
```

## Parameter schema

```json
{
  "additionalProperties": false,
  "properties": {
    "author": {},
    "background": {
      "description": "PNG",
      "enum": [
        "paper",
        "transparent"
      ],
      "type": "string"
    },
    "bleed": {
      "type": "boolean"
    },
    "compressImages": {
      "description": "PDF: images as JPEG",
      "type": "boolean"
    },
    "cover": {
      "description": "EPUB",
      "type": "boolean"
    },
    "embedImages": {
      "description": "IDML",
      "type": "boolean"
    },
    "fixedLayout": {
      "description": "EPUB",
      "type": "boolean"
    },
    "format": {
      "enum": [
        "pdf",
        "png",
        "jpg",
        "html",
        "idml",
        "epub"
      ],
      "type": "string"
    },
    "language": {},
    "marks": {
      "description": "bool | {crop?: bool, bleed?: bool, pageInfo?: bool} (PDF printer's marks); PDF printer's marks"
    },
    "pages": {
      "description": "\"1-3,5\" | [1,3] (PDF, PNG, JPEG: 1-based; pictures default to the first page); PDF, PNG, JPEG: 1-based; pictures default to the first page"
    },
    "ppi": {
      "default": 72,
      "description": "PNG, JPEG",
      "type": "integer"
    },
    "quality": {
      "description": "1 to 100; JPEG",
      "type": "integer"
    },
    "spreads": {
      "description": "PDF: each spread on one sheet",
      "type": "boolean"
    },
    "standard": {
      "description": "PDF/X-4, PDF/A-2b",
      "enum": [
        "none",
        "x4",
        "a2b"
      ],
      "type": "string"
    },
    "tagged": {
      "description": "PDF",
      "type": "boolean"
    },
    "title": {
      "type": "string"
    }
  },
  "returns": "{format, data, bytes, files?: [{page, data}] (pictures of several pages)}",
  "type": "object"
}
```

Generated from the command list of @kition/layout-darwin-arm64@0.1.0 and the kit itself (layout_commands through @kition/cli@0.1.1, built from KitionAI/kition-layout@8767a18).
