This question is very similar to that found here: moodle.sty does not insert graphics in xml output file (though as I'm a new user I can't comment on the original question). I'm using Windows, MiKTeX (edit: this was wrong, it's actually TeX Live 2018) and Texmaker, and I'd like to build quizzes efficiently in Moodle for a precalculus course. I'm quite new with LaTeX, only having worked with it for a year.

I'm currently trying to use a .png graphic located in the same directory as the .tex file. When I run PDFLaTeX, I get the following warning "Package ifplatform Warning:shell escape is disabled, so I can only detect \ifwindows"

Warning Output "Package ifplatform Warning:shell escape is disabled, so I can only detect \ifwindows"

This was after adjusting the Configuration of PDFLaTeX to include --shell-escape=true as Gustavo did in the original post:

Configuration of PDFLaTeX to include --shell-escape=true

For reference, here is the section of the log that I think is showing how moodle.sty is managing the graphic:

<map1.pdf, id=1, 361.35pt x 216.81pt>
File: map1.pdf Graphic file (type pdf)
<use map1.pdf>
Package pdftex.def Info: map1.pdf  used on input line 29.
(pdftex.def)             Requested size: 170.71652pt x 102.43002pt.
LaTeX Font Info:    Try loading font information for U+msa on input line 29.

File: umsa.fd 2013/01/14 v3.01 AMS symbols A
LaTeX Font Info:    Try loading font information for U+msb on input line 29.

File: umsb.fd 2013/01/14 v3.01 AMS symbols B
moodle.sty: Processing \includegraphics[width=6cm]{map1.pdf} for HTML...
moodle.sty: Converting 'map1.pdf' to PNG...
command is: convert map1.pdf -resize 243 map1.pdf.png
runsystem(convert map1.pdf -resize 243 map1.pdf.png)...executed.

command is: openssl enc -base64 -in map1.pdf.png -out map1.pdf.enc
runsystem(openssl enc -base64 -in map1.pdf.png -out map1.pdf.enc)...executed.

command is: openssl enc -base64 -in map1.pdf.png -out map1.pdf.enc
moodle.sty: Reading base64 file 'map1.pdf.enc'...
moodle.sty: <IMG> tag inserted.

{c:/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map} <./map1.pdf>]
(./circles.aux) ) 

Finally, here is the section of the .xml where the decoded base64 image should be:

  <questiontext format="html">
    <text><![CDATA[<p>Which equation describes the following map: <BR/> <IMG width=243 SRC="data:image/png;base64,"> </p>]]></text>

Can anyone see what I'm missing?

The only other thing I can notice in the log is:

Package: shellesc 2016/06/07 v0.02a unified shell escape interface for LaTeX
Package shellesc Info: Restricted shell escape enabled on input line 69.

Thanks for your time,


PS If I manually convert the .png to base64 and insert it into the .xml file I can get it to upload into Moodle, but I'd like to make large banks of questions efficiently using gnuplot, LaTeX, and Moodle

Thanks @Ulrike Fischer, here's the full .tex file



\begin{quiz}{Point form Circles}
  \begin{multi}[shuffle=true]{Circle Equation}
    Which equation describes the following map: \\
    \item* $(x + 1)^2 + (y-3)^2 = 4$
    \item $(x-1)^2 + (y + 3)^2 = 4$
    \item $(x-1)^2 + (y-3)^2 = 4$
    \item $(x + 1)^2 + (y + 3)^2 = 4$


Note for @Rmano, here's the result of encrypting the .png after converting manually with ImageMagick:

Success manually encrypting with correct base64 code in the background

Update: Transient Message

Well this is weird... the error "'openssl' is not recognized as an internal or external command, operable program or batch file." only shows up while pdfLaTeX is running (I had to hit "PrntScrn" at just the right time to get it; afterwards it simply shows "No LaTeX errors detected!")

'openssl' is not recognized as an internal or external command, operable program or batch file.

Update: magick convert through openssl cmd prompt.

Thanks again to both of you. Here's what I get when I run pdflatex -shell-escape circles.tex through the OpenSSL Command Prompt, versus what the last bit of the log is saying:

OpenSSL cmd output versus the .log file

Resolved: Thanks to @UlrikeFischer and @Rmano for resolving the issue! Including \imagemagickcommand{magick convert} and running the .tex file through openSSL via `pdflatex -shell-escape file.tex' and everything turns out as it should.

  • 2
    you should show a small complete example, so that one can test your issue. Jun 28 '20 at 18:12
  • well I don't have the moodleshow.tex file and the convert command is called magick convert on my system. If I add \imagemagickcommand{magick convert} to the file I get a png with --shell-escape. I don't have openssl so the next step fails. Jun 28 '20 at 20:42
  • @UlrikeFischer The moodleshow.tex hack (really hack, /blush) is mine and it's here: gist.github.com/Rmano/10c932098553702b722f3a8e0f67a104
    – Rmano
    Jun 28 '20 at 20:48
  • @UlrikeFischer and fcturner: I checked your code on my system and it works ok. All the intermediary files (called mod1.pdf.png and mod1.pdf.enc) are created in the same directory. So it must be some windows peculiarity of both convert and openssl --- and I'm really at a loss here. Try to go to the directory where the .tex here, isuue pdflatex -shell-escape myfile.tex and see if you have errors or a blank .enc file. (I have to shut down now, will try to help more tomorrow)
    – Rmano
    Jun 28 '20 at 20:56
  • The - resize error also is strange. Probably @UlrikeFischer comment above is relevant, pdflatex is running the wrong convert. The other can be a PATH problem...
    – Rmano
    Jun 28 '20 at 21:17

I am not an expert of MikTeX (and the logs you have are from TeXLive, and not miktex), but:

Package ifplatform Warning:shell escape is disabled, so I can only detect \ifwindows
moodle.sty: Processing \includegraphics[width=6cm]{map1} for HTML...
moodle.sty: Converting 'map1' to PNG...
runsystem(convert map1 -resize 243 map1.png)...disabled (restricted).

moodle.sty: Converting 'map1.png' to base64...
runsystem(openssl enc -base64 -in map1.png -out map1.enc)...disabled (restricte

tells you that the shell escape is not enabled.

If you look at the start of your log file, you should see

[romano:~/education … icosGIT/E-F2_19-20] master 7m22s ± pdflatex --shell-escape=true
pdflatex: option '--shell-escape' doesn't allow an argument
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.

So I suppose the problem is that the option is --shell-escape, not --shell-escape=true.

Then you have to check if you have ImageMagick (for convert) and openssl (for the base64 conversion) installed.

And finally, you should use the full name of your graphic file, including the extension. There are patches floating around to correct this, but they are quite tricky...

  • hm, the log snippets above say texlive/2018 not miktex ;-). Jun 28 '20 at 18:07
  • @UlrikeFischer erm... so the OP is confused on the distribution they have... will tell it in the answer.
    – Rmano
    Jun 28 '20 at 18:09
  • Hi Rmano, so I don't get that warning anymore, but even with new installations of OpenSSL from here (slproweb.com/products/Win32OpenSSL.html), ImageMagick from here (imagemagick.org/script/download.php#windows), and GhostScript from here (ghostscript.com/download/gsdnld.html) (for good measure as ImageMagick highly recommended it), I'm still getting a blank where the base64 output should be.
    – fcturner
    Jun 28 '20 at 18:09
  • 1
    Just tried both .png and .pdf after getting gnuplot to generate the plots as .pdf, with no luck. Not sure where to find the intermediate files, but I'll try that out and see where I can get. Thanks @Rmano!
    – fcturner
    Jun 28 '20 at 19:07
  • 1
    Okay, so including @UlrikeFischer 's change of command AND using an OpenSSL cmd window to run pdflatex -shell-escape circles.tex made it run just fine. It must be something with how I have TeXMaker configured. Thanks to both of you!
    – fcturner
    Jun 29 '20 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.