PDF editor: New text element implementation (#4246)

* draft

* almost working

* Widgth adjustment

* Fix crash on empty text

* Change default layouts

* Fix editor bugs

* Update src/pretix/control/templates/pretixcontrol/pdf/index.html

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Show deprecated text on old text

* lockScalingFlip

* Regroup editor controls

* Update src/pretix/static/pretixcontrol/js/ui/main.js

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Update src/pretix/static/pretixcontrol/js/ui/main.js

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Update src/pretix/static/pretixcontrol/js/ui/main.js

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Update src/pretix/static/pretixcontrol/js/ui/editor.js

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Increase default height even further

* Add a small version warning

* Update src/pretix/control/templates/pretixcontrol/pdf/index.html

Co-authored-by: Richard Schreiber <schreiber@rami.io>

* Update src/pretix/control/templates/pretixcontrol/pdf/index.html

Co-authored-by: Richard Schreiber <schreiber@rami.io>

---------

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2024-08-07 11:26:47 +02:00
committed by GitHub
parent a682eab18e
commit 022f44ad00
7 changed files with 775 additions and 263 deletions

View File

@@ -30,11 +30,11 @@ def _simple_template(w, h):
company_size = name_size - 2
return [
{
"type": "textarea",
"type": "textcontainer",
"page": 1,
"locale": "",
"left": "5.00",
"bottom": "%.2f" % (((h - company_size * 1.5 - name_size) / 2 + company_size * 1.5) / mm),
"bottom": "%.2f" % (h / mm / 2 + 2),
"fontsize": name_size,
"lineheight": "1",
"color": [0, 0, 0, 1],
@@ -42,19 +42,22 @@ def _simple_template(w, h):
"bold": True,
"italic": False,
"width": "%.2f" % (w / mm - 10),
"downward": False,
"height": "%.2f" % (h / mm / 2 - 7),
"content": "attendee_name",
"text": "John Doe",
"text": "Dr John Doe",
"text_i18n": {},
"rotation": 0,
"align": "center",
"verticalalign": "bottom",
"autoresize": True,
"splitlongwords": False,
},
{
"type": "textarea",
"type": "textcontainer",
"page": 1,
"locale": "",
"left": "5.00",
"bottom": "%.2f" % ((((h - company_size * 1.5 - name_size) / 2) + company_size) / mm),
"bottom": "5.00",
"fontsize": company_size,
"lineheight": "1",
"color": [0, 0, 0, 1],
@@ -62,12 +65,15 @@ def _simple_template(w, h):
"bold": False,
"italic": False,
"width": "%.2f" % (w / mm - 10),
"downward": True,
"height": "%.2f" % (h / mm / 2 - 7),
"content": "attendee_company",
"text": "Sample company",
"text_i18n": {},
"rotation": 0,
"align": "center",
"verticalalign": "top",
"autoresize": True,
"splitlongwords": False,
},
]
@@ -94,15 +100,17 @@ TEMPLATES = {
"layout": _simple_template(*pagesizes.portrait(pagesizes.A7)),
},
"82x203butterfly": {
"label": format_lazy(_("{width} x {height} mm butterfly badge"), width=82, height=203),
"label": format_lazy(
_("{width} x {height} mm butterfly badge"), width=82, height=203
),
"pagesize": (82 * mm, 203 * mm),
"layout": [
{
"type": "textarea",
"type": "textcontainer",
"page": 1,
"locale": "",
"left": "5.00",
"bottom": "152.55",
"bottom": "153.00",
"fontsize": "20.0",
"lineheight": "1",
"color": [0, 0, 0, 1],
@@ -110,19 +118,22 @@ TEMPLATES = {
"bold": True,
"italic": False,
"width": "72.00",
"downward": False,
"height": "20.00",
"content": "attendee_name",
"text": "John Doe",
"text": "Dr John Doe",
"text_i18n": {},
"rotation": 0,
"align": "center",
"verticalalign": "bottom",
"autoresize": True,
"splitlongwords": False,
},
{
"type": "textarea",
"type": "textcontainer",
"page": 1,
"locale": "",
"left": "5.00",
"bottom": "144.55",
"bottom": "132.10",
"fontsize": "18.0",
"lineheight": "1",
"color": [0, 0, 0, 1],
@@ -130,19 +141,22 @@ TEMPLATES = {
"bold": False,
"italic": False,
"width": "72.00",
"downward": False,
"height": "20.00",
"content": "attendee_company",
"text": "Sample company",
"text_i18n": {},
"rotation": 0,
"align": "center",
"verticalalign": "top",
"autoresize": True,
"splitlongwords": False,
},
{
"type": "textarea",
"type": "textcontainer",
"page": 1,
"locale": "",
"left": "77.10",
"bottom": "34.68",
"left": "76.97",
"bottom": "10.86",
"fontsize": "20.0",
"lineheight": "1",
"color": [0, 0, 0, 1],
@@ -150,19 +164,22 @@ TEMPLATES = {
"bold": True,
"italic": False,
"width": "72.00",
"downward": False,
"height": "20.00",
"content": "attendee_name",
"text": "John Doe",
"text": "Dr John Doe",
"text_i18n": {},
"rotation": 180,
"rotation": -180,
"align": "center",
"verticalalign": "bottom",
"autoresize": True,
"splitlongwords": False,
},
{
"type": "textarea",
"type": "textcontainer",
"page": 1,
"locale": "",
"left": "77.06",
"bottom": "44.28",
"left": "77.07",
"bottom": "31.76",
"fontsize": "18.0",
"lineheight": "1",
"color": [0, 0, 0, 1],
@@ -170,12 +187,15 @@ TEMPLATES = {
"bold": False,
"italic": False,
"width": "72.00",
"downward": False,
"height": "20.00",
"content": "attendee_company",
"text": "Sample company",
"text_i18n": {},
"rotation": 180,
"rotation": -180,
"align": "center",
"verticalalign": "top",
"autoresize": True,
"splitlongwords": False,
},
],
},
@@ -235,7 +255,9 @@ TEMPLATES = {
"layout": _simple_template(40 * mm, 40 * mm),
},
"88.9x33.87": {
"label": format_lazy(_("{width} x {height} mm label"), width=88.9, height=33.87),
"label": format_lazy(
_("{width} x {height} mm label"), width=88.9, height=33.87
),
"pagesize": (88.9 * mm, 33.87 * mm),
"layout": _simple_template(88.9 * mm, 33.87 * mm),
},