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

# Tutorial: a food label with a barcode and best-before date

> Build a jam label your customers fill in: a packing date, a best-before date worked out from it, an EAN-13 barcode with its check digit, and an allergen warning that only shows when it's ticked.

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/11-customer-filled.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=05dfbeddb2a173884d34c64dce3e39fc)

What your customer gets: a short form, and a label that fills itself in.

Your customer types the product name, weight, packing date, batch and barcode number, and ticks **Contains nuts** if it applies. The label does the rest:

* it works out the best-before date, 18 months after packing;
* it adds the barcode's check digit, and says so if a number is wrong;
* it shows the nuts warning only when the box is ticked;
* it drops the batch line when the batch is left empty.

You'll use [fields](https://print.app/docs/guides/designs/data-sources.md#fields), a [worked-out field](https://print.app/docs/guides/designs/data-sources.md#formulas), a barcode and two [show rules](https://print.app/docs/guides/designs/data-sources.md#connect-an-item-to-data). It takes about 15 minutes in the PrintFx editor.

**1. Start the label**

Create a design 100 × 70 mm, with 2 mm bleed and a 3 mm safe margin (see [Create a design](https://print.app/docs/guides/designs/create-a-design.md)). Add the background and the brand name as you normally would. Anything you don't connect to data stays exactly as you designed it.

**2. Product name and weight**

1. Add a text and type `{Product name}`. Add another and type `{Net weight} g`.
2. Select each text, then go to **Object → Data → Content** and choose **Customer fills it in**. A word in curly brackets becomes a field. The rest of the text, like the "g", stays as you typed it.
3. Go to **Design → Data Sources** and click **Product name**. Set **Starts with** to *Strawberry Jam*, and switch on **Required**.
4. Click **Net weight**. Set **Input** to *Number* and **Starts with** to *340*.

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/03-field-product-name.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=c7bd62abbcdf4ea435c6e82877dbb60e)

**3. The packing date**

1. Add a text, `Packed {Packed on}`, and make it **Customer fills it in** as before.
2. In **Data Sources**, click **Packed on**. Set **Input** to *Date* and **Date format** to `DD/MM/YYYY`.

The customer gets a date picker, and the label prints the date in your format.

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/04-field-packed-on.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=1e5f4cefe0c88705bc66271b709c2b02)

**4. The best-before date, worked out**

1. Add a text, `Best before {Best before}`, and make it **Customer fills it in**.
2. In **Data Sources**, click **Best before** and choose **Worked out**. Type this formula:

   ```text wrap theme={null}
   format_date(date_add([Packed on], 18, "months"), "D MMM YYYY")
   ```

   `date_add` adds 18 months to the packing date, and `format_date` writes the result as *24 May 2028*. **Insert field** puts `[Packed on]` in for you.
3. **Try it** shows the result for a sample date.

The customer never sees this field. It changes whenever they change the packing date.

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/05-field-best-before.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=14b04e02d7a305439adcc60fac3a32fd)

**5. The barcode**

1. Click the QR code button in the top bar (**Add a QR code or barcode**), then choose the barcode.
2. In **Object → Barcode**, keep **Type** at *EAN-13* and type a sample number. Type 12 digits: the 13th, the check digit, is worked out for you.

   ![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/06-barcode-settings.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=32035216b2b5d1ca9036f960d4d1a843)
3. Still on the **Object** tab:

   * type *Barcode* in the name box at the top; it becomes the label in the customer's form;
   * under **Hint**, type *12 digits: the check digit is added for you*;
   * in **Data**, click **Content** and choose **Customer fills it in**.

   ![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/07a-barcode-data.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=e32798da3e05dce48c8873a4f82fa279)

> [!TIP]
>
> Keep an EAN-13 at least 30 mm wide so shop scanners can read it.

**6. A warning that shows only when it's ticked**

1. In **Data Sources**, click **Add a field** and name it *Contains nuts*. Choose **Customer enters it** and set **Input** to *Yes / No*.

   ![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/08-field-contains-nuts.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=f77bb9ea10f1c20281beb2c8a0933f4a)
2. Add a text, `CONTAINS NUTS`. Select it, then go to **Object → Data → Shows** and choose **Only when…**. Set **Field** to *Contains nuts* and **Condition** to *is ticked*.

   ![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/09-shows-nuts.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=3da4e6e309ba4882c6df6b86dd2091da)

The warning disappears from the design straight away. "Hidden now" means its rule isn't met by the current values.

**7. A batch line that disappears when it's empty**

Add a text, `Batch {Batch}`, and make it **Customer fills it in**. Then go to **Shows → Only when…** and set **Field** to *Batch* and **Condition** to *isn't empty*.

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/10-shows-batch.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=b7d2044aab6bf61e441680e49508714d)

**8. Check it as a customer**

**Design → Data Sources** now lists 7 fields and 2 rules.

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/02-data-sources.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=476c0ac4630b9d3ca0d6b1db233852a8)

Save, then open the design as a customer and try each part:

* change the packing date: the best-before date follows;
* tick **Contains nuts**: the warning appears;
* type a barcode number with a wrong last digit:

![](https://mintcdn.com/printapp/bBebEb8tlRiks9Yw/images/tutorials/food-label/12-customer-barcode-check.png?fit=max\&auto=format\&n=bBebEb8tlRiks9Yw\&q=85\&s=8b299420d54050bbf31e0e561a3fbe26)

Hidden items are left out of the print file too.

## Why it works

Every word in curly brackets is a **field**: a named value the customer fills in once, used wherever the design needs it. A **worked-out field** is a formula over other fields, so the best-before date can never disagree with the packing date. A **show rule** is a condition on a field, so the warning is on the label exactly when it should be.

## Take it further

* **One label per flavour:** keep your flavours, weights and barcodes in a table, and look them up from a single **Flavour** choice. See [Data Sources and fields](https://print.app/docs/guides/designs/data-sources.md#example-an-office-on-a-business-card).
* **Long product names:** turn on **Shrink to Fit** for the name. See [Long values](https://print.app/docs/guides/designs/data-sources.md#long-values).
* **More formulas:** see [the full list](https://print.app/docs/guides/designs/data-sources.md#formulas).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.