From 9059188060746c704837c51f775222a7b3a5258e Mon Sep 17 00:00:00 2001 From: nirikash <141118539+nirikash@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:17:15 +0200 Subject: [PATCH] feat: support of pdf_variant parameter (#26) weasyprint CLI supports --pdf-variant parameter, weasyprint service now supports pdf_variant query parameter Refs: DEV-11689 Co-authored-by: e550439 --- app/WeasyprintController.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/WeasyprintController.py b/app/WeasyprintController.py index ba2c6cc..8d0fa74 100644 --- a/app/WeasyprintController.py +++ b/app/WeasyprintController.py @@ -25,6 +25,7 @@ def convert_html(): encoding = request.args.get("encoding", default="utf-8") media_type = request.args.get("media_type", default="print") file_name = request.args.get("file_name", default="converted-document.pdf") + pdf_variant = request.args.get("pdf_variant", default=None) presentational_hints = request.args.get("presentational_hints", default=False) base_url = request.args.get("base_url", default=None) @@ -34,7 +35,7 @@ def convert_html(): html = request.get_data().decode(encoding) html = SvgUtils.process_svg(html) weasyprint_html = weasyprint.HTML(string=html, base_url=base_url, media_type=media_type, encoding=encoding) - output_pdf = weasyprint_html.write_pdf(presentational_hints=presentational_hints) + output_pdf = weasyprint_html.write_pdf(pdf_variant=pdf_variant, presentational_hints=presentational_hints) response = Response(output_pdf, mimetype="application/pdf", status=200) response.headers.add("Content-Disposition", "attachment; filename=" + file_name)