Use jinja to get PDF.js script

This commit is contained in:
Florian Bruhin 2018-09-06 21:47:30 +02:00
parent 3ad7ae2a2c
commit 6665a1348e

View File

@ -67,13 +67,13 @@ def _generate_pdfjs_script(url):
Args: Args:
url: The url of the pdf page as QUrl. url: The url of the pdf page as QUrl.
""" """
return ( return jinja.js_environment.from_string("""
'document.addEventListener("DOMContentLoaded", function() {{\n' document.addEventListener("DOMContentLoaded", function() {
' PDFJS.disableCreateObjectURL = true;\n' PDFJS.disableCreateObjectURL = true;
' PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.info;\n' PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.info;
' (window.PDFView || window.PDFViewerApplication).open("{url}");\n' (window.PDFView || window.PDFViewerApplication).open("{{ url }}");
'}});\n' });
).format(url=javascript.string_escape(url.toString(QUrl.FullyEncoded))) """).render(url=javascript.string_escape(url.toString(QUrl.FullyEncoded)))
SYSTEM_PDFJS_PATHS = [ SYSTEM_PDFJS_PATHS = [