2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-14 00:09:56 +00:00

Enable input controls in PDF reports (#10969)

* Enable input controls in PDF reports

Modify options passed to WeasyPrint.

* Changelog update for issue #10969.

* Add usage notes for PDF forms to report docs (#10969).
This commit is contained in:
mlam19
2025-12-06 15:35:52 -05:00
committed by GitHub
parent a0cfdd72a5
commit 27fd2bcb8d
3 changed files with 5 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adds "Category" columns to BOM and Build Item tables and APIs in [#10722](https://github.com/inventree/InvenTree/pull/10772)
- Adds generic "Parameter" and "ParameterTemplate" models (and associated API endpoints) in [#10699](https://github.com/inventree/InvenTree/pull/10699)
- Adds parameter support for multiple new model types in [#10699](https://github.com/inventree/InvenTree/pull/10699)
- Allows report generator to produce PDF input controls in [#10969](https://github.com/inventree/InvenTree/pull/10969)
- UI overhaul of parameter management in [#10699](https://github.com/inventree/InvenTree/pull/10699)
### Changed

View File

@@ -13,6 +13,9 @@ We use the powerful [WeasyPrint](https://weasyprint.org/) PDF generation engine
Templates are rendered using standard HTML / CSS - if you are familiar with web page layout, you're ready to go!
HTML form elements (`input`, `select`, `textarea`, `button`) are converted into PDF form controls. Use CSS to limit which elements are converted; refer to the
[WeasyPrint docs](https://doc.courtbouillon.org/weasyprint/stable/common_use_cases.html#include-pdf-forms) for further information.
### Template Language
Uploaded report template files are passed through the [django template rendering framework]({% include "django.html" %}/topics/templates/), and as such accept the same variable template strings as any other django template file. Different variables are passed to the report template (based on the context of the report) and can be used to customize the contents of the generated PDF.

View File

@@ -272,7 +272,7 @@ class ReportTemplateBase(MetadataMixin, InvenTree.models.InvenTreeModel):
bytes: PDF data
"""
html = self.render_as_string(instance, request, context, **kwargs)
pdf = HTML(string=html).write_pdf()
pdf = HTML(string=html).write_pdf(pdf_forms=True)
return pdf