From 35e969bb34c0aa6841ab0b01d7c95e7b4b9e3962 Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Thu, 6 Feb 2025 03:05:38 +0100 Subject: [PATCH 1/3] Replace pdflatex with lualatex and latexmk --- README.md | 2 +- creme/billing/exporters/latex.py | 7 ++++--- .../templates/billing/export/latex/FR/fr_FR/clear/base.tex | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 00d57e27b3..aa8974fc3b 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ virtual env, in order to keep the old one working). If you want PDF export, you can use : - xhtml2pdf (default) - weasyprint (easy to install on Linux ; harder on Windows) - - you can also use the binary "pdflatex" (Ubuntu package 'texlive-latex-base'). + - you can also use the binary "latexmk" with "lualatex" (Ubuntu packages 'latexmk' and 'texlive-latex-base'). Installation with 'pip': - You should probably use "virtualenv". diff --git a/creme/billing/exporters/latex.py b/creme/billing/exporters/latex.py index 9c043b5177..322b6c2280 100644 --- a/creme/billing/exporters/latex.py +++ b/creme/billing/exporters/latex.py @@ -57,9 +57,10 @@ def generate_pdf(self, *, content, dir_path, basename): # NB: return code seems always 1 even when there is no error... subprocess.call( [ - 'pdflatex', - '-interaction=batchmode', - '-output-directory', dir_path, + 'latexmk', + '-lualatex', + '-quiet', + '-cd', latex_file_path, ] ) diff --git a/creme/billing/templates/billing/export/latex/FR/fr_FR/clear/base.tex b/creme/billing/templates/billing/export/latex/FR/fr_FR/clear/base.tex index ae60b2f2da..284bcb2dbb 100644 --- a/creme/billing/templates/billing/export/latex/FR/fr_FR/clear/base.tex +++ b/creme/billing/templates/billing/export/latex/FR/fr_FR/clear/base.tex @@ -7,8 +7,6 @@ \documentclass[french,11pt]{article} \usepackage[french]{babel} \usepackage[french]{layout} -\usepackage[T1]{fontenc} -\usepackage[utf8]{inputenc} \usepackage[a4paper]{geometry} \usepackage{units} \usepackage{bera} From 83add2600a4645c2d224fd4688b9c039c6c60a3f Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Thu, 6 Feb 2025 03:48:35 +0100 Subject: [PATCH 2/3] Updated tests for lualatex and latexmk --- creme/billing/tests/test_export.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/creme/billing/tests/test_export.py b/creme/billing/tests/test_export.py index c52efe85b2..2d71b96574 100644 --- a/creme/billing/tests/test_export.py +++ b/creme/billing/tests/test_export.py @@ -53,7 +53,7 @@ ) from .fake_exporters import OnlyInvoiceExportEngine -pdflatex_not_installed = which('pdflatex') is None +latex_not_installed = which('lualatex') is None or which('latexmk') is None try: import weasyprint # NOQA @@ -360,7 +360,7 @@ def test_flavour(self): self.assertEqual('it_IT', flavour4.language) self.assertEqual('theme/with/odd/name', flavour4.theme) - @skipIf(pdflatex_not_installed, '"pdflatex" is not installed.') + @skipIf(latex_not_installed, '"lualatex" and "latexmk" is not installed.') @override_settings(BILLING_EXPORTERS=['creme.billing.exporters.latex.LatexExportEngine']) def test_exporter_latex(self): engine1 = LatexExportEngine(Quote) @@ -885,7 +885,7 @@ def test_export_error04(self): @skipIfCustomInvoice @skipIfCustomProductLine - @skipIf(pdflatex_not_installed, '"pdflatex" is not installed.') + @skipIf(latex_not_installed, '"lualatex" and "latexmk" is not installed.') @override_settings(BILLING_EXPORTERS=['creme.billing.exporters.latex.LatexExportEngine']) def test_export_invoice_latex(self): user = self.login_as_root_and_get() @@ -1322,7 +1322,7 @@ def test_export_invoice_xls02(self): @skipIfCustomQuote @skipIfCustomServiceLine - @skipIf(pdflatex_not_installed, '"pdflatex" is not installed.') + @skipIf(latex_not_installed, '"lualatex" and "latexmk" is not installed.') @override_settings(BILLING_EXPORTERS=['creme.billing.exporters.latex.LatexExportEngine']) def test_export_quote_latex(self): user = self.login_as_root_and_get() @@ -1524,7 +1524,7 @@ def test_export_credentials(self): self.assertGET403(self._build_export_url(invoice)) - @skipIf(pdflatex_not_installed, '"pdflatex" is not installed.') + @skipIf(latex_not_installed, '"lualatex" and "latexmk" is not installed.') @override_settings(BILLING_EXPORTERS=['creme.billing.exporters.latex.LatexExportEngine']) @skipIfCustomInvoice def test_export_latex_credentials01(self): @@ -1550,7 +1550,7 @@ def test_export_latex_credentials01(self): ).update(engine_id=LatexExportEngine.id) self.assertGET403(self._build_export_url(invoice)) - @skipIf(pdflatex_not_installed, '"pdflatex" is not installed.') + @skipIf(latex_not_installed, '"lualatex" and "latexmk" is not installed.') @override_settings(BILLING_EXPORTERS=['creme.billing.exporters.latex.LatexExportEngine']) @skipIfCustomInvoice def test_export_latex_credentials02(self): From 031661396798e76efad4ebc6d5befa67b054851c Mon Sep 17 00:00:00 2001 From: Patrick Baus Date: Thu, 6 Feb 2025 03:50:15 +0100 Subject: [PATCH 3/3] Changed pdflatex to lualatex in the documentation of the exporters --- creme/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creme/settings.py b/creme/settings.py index 5bf7fbf08c..b742f0d1c8 100644 --- a/creme/settings.py +++ b/creme/settings.py @@ -1330,7 +1330,7 @@ 'creme.billing.exporters.xls.XLSExportEngine', 'creme.billing.exporters.xhtml2pdf.Xhtml2pdfExportEngine', - # You needed to install LateX on the server (the command "pdflatex" is run). + # You needed to install LateX on the server (the command "latexmk" and "lualatex" is run). # Some extra packages may be needed to render correctly the themes # (see FLAVOURS_INFO in 'creme/billing/exporters/latex.py') # 'creme.billing.exporters.latex.LatexExportEngine',