# PasteToPrint Document Format 2.0

PasteToPrint saves an editable document as a UTF-8 JSON file with the `.ptdf` extension and media type `application/vnd.pastetoprint.ptdf+json`. Its schema identifier is `ptp.document/2`. The published [JSON Schema](api/document-schema/v2/schema.json) describes the fields. The browser and PHP validators also enforce structural and attachment limits.

## Editable document

An editor document contains `title` and `html` alongside `schemaVersion`. It can carry paper settings, margins, title and branding settings, configurator values, formulas and layered drawing projects. The static editor markup in `html` includes the most recent available results. `javascriptDocument.script` holds the source and `javascriptDocument.html` holds the interactive markup and saved input values. Opening a file displays the saved results. A user can review and start the script in the editor.

Embedded images and images stored as PasteToPrint Cloud objects are included in a local export. Imported files used for native re-export can be carried in `originalSources` with their original bytes and the editor mapping. The local file limit is 96 MiB. Original attachments use up to 48 MiB before Base64 encoding. Temporary LIVE requests have a 6 MiB limit, including up to 4 MiB of HTML and up to 3 MiB of editable drawing projects. Other server endpoints apply their own request limits and access rules.

## Creating documents from blocks

An integration can create a PTDF document with `blocks` and optional `title`, `locale`, `paper` and `template`. PasteToPrint renders the blocks into an editable document when it opens them. The next save captures the complete editor state. Here is a minimal request document.

```json
{"schemaVersion":"ptp.document/2","title":"Quote","blocks":[{"type":"paragraph","text":"Consulting services"}]}
```

## Migration and updates

The editor accepts existing PTDF files and PasteToPrint JSON documents. Save as PTDF to write the current version. Cloud and LIVE records acquire the current schema identifier as the application reads and saves them. Historical block documents keep their content when the API emits them with the current identifier.

Use `PATCH /api/v2/documents/{sessionId}` with `documentPatch` to update the title or the customer on a supported quotation. Include the current `If-Match` value to guard against concurrent updates. The `document` member performs a complete replacement. Both request members use the existing session authorization.
