[snip]
I have added these header and footer lines and am now one step
further forward. No output is produced (the request results in a 500 code)
and this is the message in the error log:
Req:8283A5722B5111EBA2BB43DC3F926520 2020/11/20 16:57:45 - ERROR - lsmb_legacy::catch {...} /var/www/ledgersmb/bin/../old/bin/old-handler.pl (175) -- 'Template error: latex error - pdflatex exited with errors:\nfailed to open /tmp/latexdrv1709_0/latexdoc.log for input at /var/www/ledgersmb/lib/LedgerSMB/Template.pm line 564.\n'
Clearly this means that pdflatex is at least being called now. However,
I don't see why it is trying to open a log file for input. The directory
/tmp/latexdrv1709_0/ does not appear to exist so it was either transient
or has never been there.
That's correct: the directory is transient and that makes this a bit hard to diagnose. The reason the log file is being opened for input (by LedgerSMB) is that it tries to establish whether a re-run would be required to resolve any references within the document. This isn't usually the case for invoices, but the driver is a generic LaTeX runner, so for other types of documents this may matter (and we cannot exclude people using documents where it *does* matter).
What I usually do to see what the problem could be, is to download the rendered template which is used as the latex input. (The document without the header and footer lines.) Then I run pdflatex manually on the server with that file as its input. If there is a problem with the template or with the pdflatex setup, running from a terminal shows 90% of the problems.
Just as a side-note, which version of LaTeX::Driver are you using? (`perl -MLaTeX::Driver -e 'print "$LaTeX::Driver::VERSION\n";'` should tell you.)
This similar error occurs if I try with format="ps" in the template instead:
Req:7D89C6262B5311EBA36542DC3F926520 2020/11/20 17:11:56 - ERROR - lsmb_legacy::catch {...} /var/www/ledgersmb/bin/../old/bin/old-handler.pl (175) -- 'Template error: latex error - latex exited with errors:\nfailed to open /tmp/latexdrv1862_0/latexdoc.log for input at /var/www/ledgersmb/lib/LedgerSMB/Template.pm line 564.\n'
Yes. It's expected to fail on 'ps' if it fails on 'pdf' with this error.
The template file ends like this (as hexdump so you can see the newlines)
0000000 655c 646e 647b 636f 6d75 6e65 7d74 3c0a
0000010 6c3f 6d73 2062 4e45 3b44 2d20 3e3f 000a
000001f
Ok. This looks good in terms of the number of newline characters at the end.
I would appreciate any further insight you might have. If there is
up-to-date documentation for the templates that would be good to see also.
The most up-to-date documentation for templating that I have is:
https://github.com/ledgersmb/LedgerSMB/blob/master/doc/templating/templating-guide.tex ; recently I started to collect all available template variables, with the intent to document them. The variables are available (by name) at
https://github.com/ledgersmb/LedgerSMB/wiki/Template-variables.
Let me know where your priorities lie, that'll help focus the effort to the immediately useful.