Releases: donhauser/wagtail-pdf
Wagtail 6 support, ViewSets, previewable models
The new update restores compatibility to wagtail 6.
Plenty of code was reworked to unite ViewSet
and PDF-rendering functionallity for models and improvedly adapts the module to the wagtail ecosystem. (Legacy ModelAdmin code is not supported any more.)
The changes bring several enhancements, for example PDF renderable models can now be previewed during creation/editing.
Bugfixes and changes
- Added missing pdfjs files (pdf.mjs, ...)
- separated preview functionality from
RoutablePageMixin
intoMultiplePreviewMixin
-
BasePdfViewMixin
as renamed toBasePdfMixin
-
BasePdfMixin.get_pdf_view()
was reworked, methods likeBasePdfMixin.get_pdf_view_kwargs()
were added to be more similar to wagtail style methods - Parts of
PdfViewPageMixin
were split off intoBasePdfMixin
andBasePreviewablePdfMixin
-
PdfModelMixin
was created based onBasePdfMixin
and wagtail'sPreviewableMixin
to enable pdf servable models - PreviewableViewSetMixin was added for utilizing wagtail's
PreviewableMixin
- Models and Pages now support the specification of separate preview classes through
pdf_view
,preview_pdf_view
, andpreview_panel_pdf_view
. -
PdfViewSetMixin
andPdfAdminViewSetMixin
now replace old ModelAdmin mixins - The 'show live' button in
PdfViewSetMixin
is added to theIndexView
if the models URL could be reversed -
pdf_options
dictionaries from different sources are not merged any more -
register_pdf_view
hook was added to easily create viewable PDF models -
'wagtail_pdf_view.urls'
should now be used to register the modules urls - latex code was moved to a separate app
wagtail_pdf_view_tex
In Panel Preview Update
To support the in panel previews introduced in wagtail 4.0, this module now employs pdf.js as server hosted PDF viewer.
Support
This version supports wagtail 4 and wagtail 5.
Upgrading from 0.2.1
Check whether wagtail_pdf_view is inside INSTALLED_APPS
:
# settings.py
INSTALLED_APPS = [
...
# this is now required!
'wagtail_pdf_view',
'wagtail.contrib.routable_page',
...
]
It is now required to hook in wagtail_pdf_urls.urls
into your projects urls.py:
# urls.py
from wagtail_pdf_view import urls as wagtail_pdf_urls
# this is now required!
urlpatterns = urlpatterns + [
# hook in the 'live'-view PDFs under "pdf/"
path("pdf/", include(wagtail_pdf_urls)),
...
# IMPORTANT: This must be below the "pdf/" include
path("", include(wagtail_urls)),
...
]
Bugfixes and changes
- Fixed the displaying of PDFs inside
<iframe>
, by hosting the PDF viewer on the server, such that container's properties (likescroll
) can be accessed without CORS issues - Updated imports to support wagtail 4 and wagtail 5
- Implemented PDF viewer registry
register_pdf_view()
,register_pdf_admin_view()
,get_pdf_viewer_url()
andget_pdf_admin_view
to replaceDEFAULT_PDF_VIEW_PROVIDER
andDEFAULT_PDF_ADMIN_VIEW_PROVIDER
- Renamed
PdfViewPageMixin.PDF_VIEW_PROVIDER
toPdfViewPageMixin.pdf_view_class
-
get_preview_name()
now just outputs the upper case name (e.g. PDF instead of pdf preview) - Added settings
WAGTAIL_PDF_VIEW
andWAGTAIL_PDF_ADMIN_VIEW
to hook in custom view classes - Added
WAGTAIL_DEFAULT_PDF_OPTIONS
andWAGTAIL_PREVIEW_PANEL_PDF_OPTIONS
to set global options for weasyprint -
WAGTAIL_PDF_VIEWER
to configure a different pdf viewer (instead of pdf.js) in the panel preview - Added
PdfViewPageMixin.pdf_options
,ModelAdminPdfViewMixin.pdf_options
, andModelAdminPdfAdminViewMixin.pdf_options
to set local options for weasyprint - Added pdf.js as server hosted PDF viewer
- Added
serve_sameorigin
to serve the pdf viewer without CORS problems - Added
redirect_request_to_pdf_viewer()
- Added
get_pdf_viewer_url()
- Implemented
PdfViewPageMixin.serve_preview_pdf()
to handle in panel previews - Hook in the server side pdf viewer using
PdfViewPageMixin.make_preview_request()
- Fixed
WagtailCoreExtensionLatex._include_block()
- Added a modified
CheckboxSelectMultiple
for correct checkbox interaction within PDFs - Added some logging if a wrong configuration is detected
Support for latest django-weasyprint
Support for the latest djangp-weasyprint
Bugfixes:
get_css()
needs an additional argument, Issue #7- Fixed
MultipleViewPageMixin
crash forurl=None
ModelAdminPdfAdminViewMixin
was missingpermission_helper_class
PDF Views for Models
Version 0.2 of wagtail-pdf-view
brings support for rendering PDF views of models.
Use-cases include:
- rendering customer invoices
- creating participation lists of members in your organization
- rendering tickets
- and many more!
Since models do not use wagtails draft system, there are no previews for the model PDFs.
Unlike PDF view pages, PDF rendered models are useful for rather simple content, or for generated content.
This version offers you three different ways to include the rendered PDF models in your page
/admin
restricted content, managed byModelAdmin
- public content, managed by
ModelAdmin
- public content, the view is directly embedded in your
urls.py
Version changes:
PdfModelMixin
implements basic functionalities needed to render a model as PDF- New file
modeladmin/mixins.py
:ModelAdminPdfViewMixin
automatically create a public view for the inheriting model (with action 'live')ModelAdminPdfAdminViewMixin
automatically create a/admin
restricted view for the inheriting model (with action 'pdf')ExtendableButtonHelperMixin
allows to append custom buttons toModelAdmin
sButtonHelper
easierCustomActionPermissionHelperMixin
implements generalized permission check functionuser_can_perform_action()
- The new file
urls.py
loads URLs from the new wagtail hookregister_pdf_site_urls
AdminViewMixin
can be used to require view permissions on a modelWagtailTexAdminView
andWagtailWeasyAdminView
implement the restricted views fortex
andWeasyprint
- The more customized class
PDFDetailView
extends the inheritance fromBaseDetailView
in WagtailTexView and WagtailWeasyView - HTTP-Content from
PdfViewPageMixin.serve_pdf()
moved toPDFDetailView
Bugfixes:
- Reversing URLs is now fixed (
MultipleViewPageMixin.__init_subclass__()
was extended)
Support for LaTeX Tables
Wagtail (contrib) Tables --> LaTeX Tables is now supported in version 0.1.3
Credits go to @eeintech
Bugfixes for LaTex and RichtextFields
Minor changes in the code to fix the following
- Bugfix to make
RichtextField
usable in LaTeX mode. - Small changes in
SimpleHtmlToLatexParser
to fix whitespace problems when using<i>
and<b>
0.1.1
Initial project release
This version essentially consists of:
PdfViewPageMixin
for Wagtail pages, configurable withROUTE_CONFIG
and many other options such asstylesheets
andattachment
.- The routing is implemented as
MultipleViewPageMixin
, a very general extension of wagtails routablepage which supports inheritance. - A basic
PdfModelMixin
for regular django models (to make the PDF rendering process for them as similar as possible) - Support for django-weasyprint and django-tex