# Preview

So you don't have to check your customizations by first creating a real document, the plugin offers a **live preview**. It generates the document as a PDF based on a real order and opens it in a new tab.

## Generating a preview

You will find the preview function in the header area of the document configuration (next to the action buttons), once the configuration has been saved:

1. **Select order** – Use the "Select order (default: latest)" field to choose the order the preview should be generated with. If you make no selection, the **latest order** is used automatically.
2. **Preview** – Click the **Preview** button. The PDF is generated and opened in a new browser tab.

> **Important:** Save your changes before generating the preview. The preview renders the currently saved state of the document.

## Requirements

* There must be **at least one order** in the shop. Otherwise the message appears: *"No order found. At least one order is required to generate a preview."*
* The document configuration must be saved (not a new, unsaved document).

## Troubleshooting

If generation fails, the administration shows an error message with the concrete cause (e.g. a Twig syntax error in your template). Common causes:

| Message / symptom                     | Possible cause & solution                                                  |
| ------------------------------------- | -------------------------------------------------------------------------- |
| Twig/syntax error in the message      | Check your Twig template for unclosed tags or typos                        |
| "The preview could not be generated." | General error – check the template, the selected order and the server logs |
| "No order found."                     | Create at least one order or select a specific order                       |

> **Tip:** The preview is ideal for quickly testing Twig customizations to the line items table and summary, as template errors are shown directly as a message.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hubyte.de/pdf-dokumenten-template-bearbeiten/english-documentation/vorschau.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
