Fetch fresh calibration on every print

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-05 14:08:11 +03:30
parent 9f38a02797
commit 13135b5999
4 changed files with 76 additions and 34 deletions

View File

@@ -53,32 +53,26 @@ Because the application prints dynamic text directly over your physical, pre-pri
Follow these steps to calibrate the alignment for your specific printer:
### 1. Print the Calibration Sheet
1. Open the application and navigate to the **Calibrate** tab in the top menu.
2. Load a **blank** piece of A4 paper into your printer.
3. Click the "Print Calibration Sheet" button to print it out.
### 1. Open the Calibrate tab
1. Open the application and navigate to **Calibrate** in the top menu.
2. You will see a live A4 preview (2×2 slips) and a control panel with millimeter positions.
### 2. Check the Alignment
1. Take your printed blank calibration sheet.
2. Place it perfectly behind one of your **actual pre-printed label sheets**.
3. Hold them both up to a light source (like a window or lamp).
4. Look for the crosshairs (`┼`). They should align perfectly inside the target boxes (Batch, Date, Next Control, and Weight).
### 2. Print and check the alignment
1. Load a **blank** piece of A4 paper into your printer.
2. Click **Print** on the calibrate page.
3. Place the printed sheet perfectly behind one of your **actual pre-printed label sheets**.
4. Hold them both up to a light source (window or lamp).
5. The crosshairs (`┼`) should sit inside the target boxes (Batch, Date, Next Control, and Weight).
### 3. Adjusting the Millimeters (If Necessary)
If the text is printing slightly too high, too low, or too far to a side, you can adjust the CSS margins in the codebase to shift the text.
### 3. Adjust positions in the UI
If text is too high, low, or off to the side, nudge it in the panel — no code edits or Docker restart needed.
1. Open the file: `slips/templates/slips/print_page.html`
2. Scroll to the `<style>` block at the top, and find the `.var-field` CSS section.
3. You will see absolute positioning values in millimeters (`mm`), for example:
```css
.val-batch { top: 15mm; left: 40mm; }
```
4. **Adjust the numbers**:
- To move text **DOWN**: Increase the `top` value (e.g., `15mm` -> `17mm`).
- To move text **RIGHT**: Increase the `left` value (e.g., `40mm` -> `42mm`).
5. Save the file.
6. Restart the Docker container so the changes take effect:
```bash
docker compose restart app
```
7. Print a new calibration sheet and test again until perfect!
1. Use **+/−** (or type a value) for each field’s `top` / `left` (and font if needed).
- Move **DOWN**: increase `top`.
- Move **RIGHT**: increase `left`.
2. Click a crosshair on the preview to jump to that field’s controls; arrow keys also nudge the selection.
3. Click **Save** when it looks right. Values are stored in `data/calibration.json` (same persistent data volume as the database).
4. Print a new calibration sheet and overlay again until perfect.
5. **Reset defaults** restores the built-in starting positions.
Order print pages load the latest saved calibration automatically when you open Print (no hard refresh required).