# Prepare and paginate data sheets from master pages

Use this workflow when each product needs a sequence of reusable sections:
product overview, technical data, variants, accessories, drawings and delivery
information. EasyCatalog populates the designs with the selected product data
and flows them through the destination pages. A data sheet may occupy one or
several pages as its content grows.

Composition Plans are a new EasyCatalog feature. This guide covers data sheets
built with `masterPage` sections. Use it with [START-HERE](START-HERE.md), the
[AI Authoring Guide](Composition%20Plan%20AI%20Authoring%20Guide.md), the
[JSON Reference](Composition%20Plan%20JSON%20Reference.md#master-page-sections)
and a fresh manifest from the actual document and data selection. Confirm
that the installed manifest advertises `masterPage` before authoring a plan.

## 1. Organize the data for one sheet

Decide what identifies a data sheet before designing its pages.

- Select a single record when it represents a complete product.
- For a product with variants, select the product group and include its child records.

Prepare a representative selection containing a small product and a product
with enough variants or text to require continuation. Confirm that linked
fields, images, grouping and sort order give the expected content with normal
EasyCatalog population before creating the plan.

Within a plan, `selectionRoot` represents the supplied data.
`data: {"source":"selectionRoot","result":"self"}` passes the wrapper
to a section; it does not repeat the section for every descendant record.
A native container's own content rules and population settings determine how
its records and groups repeat. Do not add a record loop around every section
of a product sheet: that can repeat the overview and other product-level
content unnecessarily.

## 2. Prepare one source master page per section

Create source master (parent) pages in the same document that will receive the
output. Use clear names,
for example:

| Source design | Suitable top-level item | Typical contents |
| --- | --- | --- |
| Product overview | Group | Product title, linked image and introductory text. |
| Technical description | Text frame | Linked flowing text. |
| Variant specifications | EasyCatalog container | Existing table or record formatting rules. |
| Accessories | EasyCatalog container | Repeated accessory designs and their labels. |
| Measurement drawing | Group | Drawing, caption and linked measurements. |

Names in this table are examples. In the JSON, use the exact master
spread name, including its prefix, and a one-based page index within the spread.
That index is not a document page number or a left/right designation.

Each referenced source page must contain **exactly one top-level item**. Group
several page items to make one design when appropriate. A group counts as one
item. If a native container should retain its population behavior, keep the
container itself as the top-level item. Similarly, keep a text frame as the
top-level item when it should use text-frame fitting and threading.

The source item determines the section behavior:

- An EasyCatalog container uses `templateContainer` behavior.
- A text frame uses `textFrame` behavior, including a frame containing a table.
- Other artwork or a group uses `formattingRule` behavior.

A group of text and graphics is handled as grouped artwork; grouping a text
frame does not make the whole group a threadable text-frame section.

These masters supply live templates. Creating the plan does not turn them
into saved formatting rules or apply each source master to an output page.
Use a separate destination parent for repeating page furniture such as logos,
page numbers or fixed headers. Keep its reserved space outside the content
area, or explicitly reserve that space in the plan.

## 3. Set margins and source positions

For a conventional data sheet, start with `insideMargins: true`. Give the source
masters useful page margins and design the content for the destination's
available width.

Place the top of each source design at its source top margin when it should
follow the previous section without an additional source-position gap. Its
left position relative to the source left margin controls its horizontal
indent. Do not arrange independent source masters as if they were successive
positions on a finished sheet: their source Y offsets contribute to spacing
when the sections flow.

With inside-margins placement, the first section on a fresh destination starts
at the destination top margin plus its source margin-relative Y offset. Later
sections start below the preceding rendered content, adding:

1. The preceding section's `spaceAfter`.
2. The thread's `gutter`.
3. The next source item's Y offset from its source top margin.

For example, a next item 8 pt below its source top margin follows a preceding
section with `spaceAfter: 6` by 14 pt when the thread gutter is zero. JSON
measurements are in points; 1 mm is approximately 2.83465 pt.

Content extending outside a source margin retains that edge's outset, including
negative offsets. The extension belongs to that section and does not enlarge
the normal area for later sections. Check such designs against destination
furniture and page edges.

Set `insideMargins: false` when the intended target represents the full page.
This uses source page-relative positions, including the source margin offsets.
An item at a 12 mm source top margin has a Y offset of 12 mm in outside mode,
and zero in inside mode. For a destination container, positions are relative to
its content origin; choose the mode matching the area that container represents.
Explicit area constraints still apply.

## 4. Configure fitting, limits and keeps

Set the source items' EasyCatalog settings before writing or testing the
plan. For native containers, also check the content formatting rules, their
record/group usage and the container's fill direction and gutters.

| Setting | How to use it for a data sheet |
| --- | --- |
| Vertical Auto-Fit | Allow descriptions or populated containers to grow and shrink with content. |
| Horizontal Auto-Fit | Enable only when the design should change width; otherwise preserve the authored width. |
| Minimum height | Reserve a meaningful minimum footprint, such as a drawing panel or short description. |
| Maximum height | Limit growth only when the limit is intentional and the content has a valid continuation or complete-fit strategy. |
| Minimum/maximum width | Keep a design within its intended column or page width. |
| Threadable | Allow supported text/container content to continue. A non-threadable text section must fit completely in one available area. |
| Keep With Next | Keep a heading or introductory section with the following section. Avoid keeping an entire long sheet together unintentionally. |

Master text-frame sections inherit container-data auto-fit flags, minimum and
maximum dimensions, Threadable and Keep With Next. Native container sections
inherit their corresponding authored settings. Active pagination fitting
attributes can enable text-frame fitting and override positive height limits;
unspecified fitting limits retain the container-data limits. Zero size limits
do not impose a positive minimum or maximum. Explicit properties in the plan
JSON override the inherited section properties.

Auto-fit and threading serve different purposes. Allowing a frame to grow does
not by itself grant permission to split it across pages. Test long text, large
tables and kept sections against a fresh empty target as well as the remainder
of a partly filled page.

## 5. Create the composition plan

Add one `masterPage` section to the thread’s `content` array for each design,
in reading order. Set `master` to the exact master spread name, including its
prefix, and `page` to the page index within that spread, starting at 1.
Set `insideMargins` for each design and use `spaceAfter` to add trailing space
in points.

For example, this plan flows two source designs for the current product:

```json
{
  "schema": "easycatalog-composition-plan/1",
  "threads": [
    {
      "name": "data-sheet",
      "direction": "top to bottom",
      "crossAxis": "start",
      "gutter": 0,
      "content": [
        {
          "type": "masterPage",
          "name": "product-overview",
          "master": "CP-Overview",
          "page": 1,
          "insideMargins": true,
          "data": { "source": "selectionRoot", "result": "self" },
          "overflow": "continue",
          "spaceAfter": 12
        },
        {
          "type": "masterPage",
          "name": "product-specifications",
          "master": "CP-Specifications",
          "page": 1,
          "insideMargins": true,
          "data": { "source": "selectionRoot", "result": "self" },
          "overflow": "continue",
          "spaceAfter": 0
        }
      ]
    }
  ]
}
```

Replace both example master names with the actual names in the document. This
is an authoring example, not a validated plan for an arbitrary document. The
source designs determine their subtype and inherited fitting behavior. Do not
add `asset`, `ruleSet`, `sections` or `plan` to a `masterPage` section.

## 6. Check and populate the data sheet

Select a destination container. In the Containers panel menu, choose **Composition Plan (Beta) →
Edit Composition Plan...** and paste the saved JSON. Its content bounds provide the target area. Select one representative
product in the data view and choose **Composition Plan (Beta) → Check Composition Plan...** from the
Containers panel. Review the fit results and any remaining content.

Populate the container with that product and inspect each section. Test a
product with enough variants to require continuation. Check that the heading
stays with its content and that all variants appear in the intended order.

## 7. Give an AI the right inputs

Choose **Reports → Composition and Scripting Manifest…** from the
EasyCatalog Data View panel menu with the actual document open and representative product data selected.
Supply the AI with:

- The fresh manifest, this guide, START-HERE and the JSON Reference.
- The master spread names, page indices and section order, or a plan containing those references.
- Which record or grouping field defines a sheet, and the required sort order.
- The page/spread/container target and inside/outside-margins choice.
- Required spacing, optional sections, keeps and sheet-start/page-break policy.
- Diagnostics from validation or trial pagination and a description of the
  expected versus actual output.

A suitable request is:

```text
Use the attached live manifest and example masterPage plan to prepare
product data sheets. Keep the exact master names and page indices.
Each sheet receives one product group. Pass selectionRoot to its native
sections so they can populate the variants in that group.
The container covers the area inside the page margins. Use the supplied reading order. Retain
inherited fitting and keep settings unless a stated requirement needs an
override. Set the requested spaceAfter values in points. State whether
successive products share a page or require a new page, and implement the
specified policy using the installed contract.
Return one composition-plan JSON object and identify any missing resources.
Use only features advertised by the manifest. Check structure, bindings and
physical fit when tools are available; otherwise list the checks still needed.
```

For optional sections, use the supported `when` condition with the exact fields
and expression syntax from the installed contract. A condition omits content;
it does not remove a physical document page. The referenced source master must
still exist and contain one top-level item because it resolves at compilation.

## 8. Diagnose and maintain the template

| Symptom | First checks |
| --- | --- |
| A section cannot fit in an empty area | Compare its authored width, height limits, offsets and outsets with the destination. Check keeps and continuation permission. A one-page spread offers only that page's area. |
| A large unexpected vertical gap | Add the preceding `spaceAfter`, thread gutter and next source Y offset. Check minimum height and unused space inside grouped artwork. |
| Only one variant appears, or the whole sheet repeats per variant | Check the selected product group, its hierarchy and native content-rule record/group usage before adding loops. |
| A heading is left behind | Check Keep With Next on the top-level source item and explicit JSON overrides. Test whether the kept pair fits in an empty target. |
| Text overflows or a table cannot continue | Check section Threadable, height limits, container continuation and the actual target capacity. |
| A master cannot be resolved | Keep its exact name and page index valid in the destination document and ensure it has exactly one top-level item. |

Source artwork, margins and inherited settings are read again on compilation.
Editing them does not require recreating an existing `masterPage` plan. Explicit
JSON overrides continue to take precedence, so inspect them when a source edit
appears ineffective. Changing which masters participate or their order requires
updating the thread’s content array.

Keep the referenced masters and any saved formatting rules used by their
native containers with the destination document. Exporting the JSON alone does
not package those resources. Refresh the manifest after resource changes and
repeat the representative-product checks. A bounded layout check or successful
JSON validation does not replace inspection of the completed data sheets.
