mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-14 08:19:54 +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:
@@ -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 "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 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)
|
- 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)
|
- UI overhaul of parameter management in [#10699](https://github.com/inventree/InvenTree/pull/10699)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -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!
|
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
|
### 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.
|
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.
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class ReportTemplateBase(MetadataMixin, InvenTree.models.InvenTreeModel):
|
|||||||
bytes: PDF data
|
bytes: PDF data
|
||||||
"""
|
"""
|
||||||
html = self.render_as_string(instance, request, context, **kwargs)
|
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
|
return pdf
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user