cooltronicpl / Craft-document-helpers

Craft CMS 3 and 4, 5 plugin enabling PDF document generation from template Twig files, code blocks and URLs
Other
13 stars 6 forks source link

Error when using the Securely displaying pdf documents code #17

Closed johnwbaxter closed 1 year ago

johnwbaxter commented 1 year ago

Hi, when I try this code I get the error:

Unknown "version" function.

https://github.com/cooltronicpl/Craft-document-helpers#securely-displaying-pdf-documents-in-the-browser-without-saving-to-the-web-folder

cooltronicpl commented 1 year ago

You can use this:

    {% set pdfOptions = {
        date: entry.dateUpdated|date('U'),
     } %}
                {% header "Content-Type: application/pdf" %}
{{craft.documentHelper.pdf('_pdf/document.twig', 'inline', '../book_example'  ~ '.pdf', entry, pdfOptions)}}

Or install Static Files Autoversioning, because it is a function from this plugin. If it is working fine, please let us know. We used the attached code without an external plugin and version function on the website. This example works now in our test environment.