mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix weasyprint version (#3539)
* Pin weasyprint version - Revert to 54.3 - Fixes https://github.com/inventree/InvenTree/issues/3528 * Simplify label printing for multiple pages * Simplify PDF generation for multiple report outputs * Add content wrapper div for base label template - Allows more extensibility
This commit is contained in:
parent
00dbf00eb9
commit
87e7112326
@ -158,16 +158,12 @@ class LabelPrintMixin:
|
|||||||
|
|
||||||
pages = []
|
pages = []
|
||||||
|
|
||||||
if len(outputs) > 1:
|
for output in outputs:
|
||||||
# If more than one output is generated, merge them into a single file
|
doc = output.get_document()
|
||||||
for output in outputs:
|
for page in doc.pages:
|
||||||
doc = output.get_document()
|
pages.append(page)
|
||||||
for page in doc.pages:
|
|
||||||
pages.append(page)
|
|
||||||
|
|
||||||
pdf = outputs[0].get_document().copy(pages).write_pdf()
|
pdf = outputs[0].get_document().copy(pages).write_pdf()
|
||||||
else:
|
|
||||||
pdf = outputs[0].get_document().write_pdf()
|
|
||||||
|
|
||||||
inline = common.models.InvenTreeUserSetting.get_setting('LABEL_INLINE', user=request.user)
|
inline = common.models.InvenTreeUserSetting.get_setting('LABEL_INLINE', user=request.user)
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
margin: 0mm;
|
margin: 0mm;
|
||||||
color: #000;
|
color: #000;
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
|
page-break-before: always;
|
||||||
|
page-break-after: always;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
@ -22,14 +24,23 @@
|
|||||||
image-rendering: pixelated;
|
image-rendering: pixelated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
width: 100%;
|
||||||
|
break-after: always;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
{% block style %}
|
{% block style %}
|
||||||
|
/* User-defined styles can go here */
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% block content %}
|
<div class='content'>
|
||||||
<!-- Label data rendered here! -->
|
{% block content %}
|
||||||
{% endblock %}
|
<!-- Label data rendered here! -->
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -233,17 +233,12 @@ class ReportPrintMixin:
|
|||||||
pages = []
|
pages = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
for output in outputs:
|
||||||
|
doc = output.get_document()
|
||||||
|
for page in doc.pages:
|
||||||
|
pages.append(page)
|
||||||
|
|
||||||
if len(outputs) > 1:
|
pdf = outputs[0].get_document().copy(pages).write_pdf()
|
||||||
# If more than one output is generated, merge them into a single file
|
|
||||||
for output in outputs:
|
|
||||||
doc = output.get_document()
|
|
||||||
for page in doc.pages:
|
|
||||||
pages.append(page)
|
|
||||||
|
|
||||||
pdf = outputs[0].get_document().copy(pages).write_pdf()
|
|
||||||
else:
|
|
||||||
pdf = outputs[0].get_document().write_pdf()
|
|
||||||
|
|
||||||
except TemplateDoesNotExist as e:
|
except TemplateDoesNotExist as e:
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ rapidfuzz==0.7.6 # Fuzzy string matching
|
|||||||
sentry-sdk # Error reporting (optional)
|
sentry-sdk # Error reporting (optional)
|
||||||
setuptools # Standard depenedency
|
setuptools # Standard depenedency
|
||||||
tablib[xls,xlsx,yaml] # Support for XLS and XLSX formats
|
tablib[xls,xlsx,yaml] # Support for XLS and XLSX formats
|
||||||
|
weasyprint==54.3 # PDF generation
|
||||||
|
|
||||||
# Fixed sub-dependencies
|
# Fixed sub-dependencies
|
||||||
py-moneyed<2.0 # For django-money # FIXED 2022-06-18 as we need `moneyed.localization`
|
py-moneyed<2.0 # For django-money # FIXED 2022-06-18 as we need `moneyed.localization`
|
||||||
|
@ -230,8 +230,10 @@ urllib3==1.26.11
|
|||||||
# sentry-sdk
|
# sentry-sdk
|
||||||
wcwidth==0.2.5
|
wcwidth==0.2.5
|
||||||
# via blessed
|
# via blessed
|
||||||
weasyprint==56.1
|
weasyprint==54.3
|
||||||
# via django-weasyprint
|
# via
|
||||||
|
# -r requirements.in
|
||||||
|
# django-weasyprint
|
||||||
webencodings==0.5.1
|
webencodings==0.5.1
|
||||||
# via
|
# via
|
||||||
# bleach
|
# bleach
|
||||||
|
Loading…
Reference in New Issue
Block a user