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

# Tuning Output

> Learn what each request parameter does and how to get the best results.

This page explains the most important `GenerateRequest` parameters used by both `/generate` and `/preview`.

If you prefer a complete field-by-field schema, see the **API Reference** tab (generated from OpenAPI).

## Text input

* `text` supports:
  * `\\n` for a new line
  * `\\n\\n` for a paragraph break
* The API normalizes whitespace **per line** (multiple spaces are collapsed), then trims the final text.

## Sizing & layout

### Page size, orientation, and DPI

* `page_size`: `a4`, `letter`, `postcard_us`, `envelope_10`, etc. (see [Page Sizes & DPI](page-sizes-dpi))
* `orientation`: `portrait` or `landscape`
* `dpi`: `300` or `600`

### DPI scaling rule (critical)

All pixel parameters are defined at a **300 DPI baseline**.

If you set `dpi: 600`, the service scales margins/font size/spacing so the physical output stays the same.

### Font sizing

* `font_size`:
  * `"auto"` (default) auto-fits the text to the available content area
  * an integer `12–400` (manual size)
* `max_auto_font_size`: caps the font size used by auto-fit (useful for short text on large pages)

### Margins (pixels @ 300 DPI)

* `margin_left`, `margin_right`, `margin_top`, `margin_bottom`
* Defaults are `240px` which is roughly **20mm** at 300 DPI.

### Line layout

* `line_height_multiplier` (default `2.0`): bigger numbers increase line spacing
* `line_break_spacing` (optional): extra spacing between paragraphs; `null` lets the server choose

### Word spacing

* `word_spacing` adds extra pixels between words (useful for “looser” handwriting).

## Visual effects

All effects are optional and off by default (except kerning).

<Note>
  Effects like word rotation, natural variation, and random indentation are intentionally non-deterministic. Combined with different font metrics (each font has different letter spacing and line geometry), some font/effect combinations can occasionally render closer to the margins than expected or clip near edges on a single page. Always validate your exact `font_id` + settings using `/preview` before production.
</Note>

### Kerning

* `kerning` (default `true`) adjusts letter pairs (e.g., “AV”, “To”) for more natural spacing.

### Rotation

* `enable_word_rotation` enables subtle word rotation
* `word_rotation_range` controls max rotation angle (degrees)

### Natural handwriting variation

* `enable_natural_variation` applies smooth, elastic-like distortion
* `natural_variation_alpha` controls intensity (typical: `10–40`)
* `natural_variation_sigma` controls smoothness (typical: `3–8`)

### Random indentation

* `enable_random_indentation` adds random horizontal indentation to lines
* `indentation_range` controls the max indentation

### Ink flow

* `enable_ink_flow` adds ink fading/flow artifacts
* `ink_flow_intensity` controls strength (`0–3`)

## Color and alignment

* `text_alignment`: `left` or `center`
* `text_color`: `[R, G, B]` (e.g., `[0, 0, 0]` for black)
