amagical-net / rails-latex

rails-latex is a renderer for rails which allows tex files with erb to be turned into an inline pdf
MIT License
141 stars 48 forks source link

Can't execute xelatex with -output-driver? #64

Closed astecker closed 3 years ago

astecker commented 3 years ago

switching to Textlive 2021 i had to add the parameter -output-driver="xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E" to my xelatex call. (https://www.tug.org/texlive/bugs.html , dvipdfmx)

while this testrun on the console works:

xelatex -etex -shell-escape -interaction=batchmode -output-driver="xdvipdfmx -i dvipdfmx-unsafe.cfg -E" eti2.tex

changing my rails-latex config to

    LatexToPdf.config.merge!  :recipe => [
        {
            :command => 'xelatex',
            :arguments => ['-etex', '-shell-escape', '-interaction=batchmode', '-output-driver="xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E"'],
            :extra_arguments => [],
            :parse_runs => 2
        }
    ]

results in the following error:

Rendered lagerplatzs/etikettendruck.pdf.erb within layouts/lageretikett (38.4ms)
Running 'xelatex -etex -shell-escape -interaction=batchmode -output-driver="xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E" input' in /home/lithos/lithos/tmp/rails-latex/397210-3798617907125015791 2 times...
-etex only works with -ini
sh: 1: /usr/local/texlive/2021/bin/x86_64-linux/xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E: not found
Completed 500 Internal Server Error in 2302ms (ActiveRecord: 24.4ms)

the produced log file is incomplete (looks like it aborted in the middle of the run). running with the -output-driver parameter seems to omit the output on the console as well. maybe gets forked or something?

baierjan commented 3 years ago

I do not have Texlive 2021 in my repositories, however I was able to reproduce that in Texlive 2020 as well. Your problem is related to argument escaping. You need to do a little change in your code and remove the unnecessary quotes. In your case, the correct line would be:

:arguments => ['-etex', '-shell-escape', '-interaction=batchmode', '-output-driver=xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E'],

Please, let me know if that helps.

astecker commented 3 years ago

that works! thank you very much. i copied the line with the " over from the texlive bug list and thought those ".." maybe needed to keep it together as one parameter, not interpreting the following -i as a parameter to the xelatex call. but what do i know :)