Error while converting text from Latex to SVG

Bug #1734624 reported by yoram zarai on 2017-11-27
30
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Inkscape
Undecided
Unassigned
pstoedit (Debian)
New
Unknown

Bug Description

Performing the following steps: Extensions -> Tex text -> then typing, for example "$1$" and clicking Ok yields the following error:

=========================================================================
Traceback (most recent call last):
  File "textext.py", line 210, in cb_ok
    self.callback(self.text, self.preamble_file, self.scale_factor)
  File "textext.py", line 369, in <lambda>
    converter_cls, old_node))
  File "textext.py", line 387, in do_convert
    new_node = converter.convert(text, preamble_file, scale_factor)
  File "textext.py", line 751, in convert
    self.pdf_to_svg()
  File "textext.py", line 849, in pdf_to_svg
    + pstoeditOpts)
  File "textext.py", line 596, in exec_command
    % (' '.join(cmd), p.returncode, out + err))
RuntimeError: Command pstoedit -f plot-svg /var/folders/h5/ggrnw90x4cjfl4jzs4r1rq080000gn/T/tmpR4wSDt/tmp.pdf /var/folders/h5/ggrnw90x4cjfl4jzs4r1rq080000gn/T/tmpR4wSDt/tmp.svg -dt -ssp -psarg -r9600x9600 failed (code 1): pstoedit: version 3.70 / DLL interface 108 (built: Oct 9 2017 - release build - g++ 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37) - 64-bit) : Copyright (C) 1993 - 2014 Wolfgang Glunz

 *** WARNING - the DELAYBIND command has been deprecated, and will be
               removed in the next version. For now you can restore
               the behaviour by using -dREALLYDEALYBIND but if you
               require continued use of this command you should contact
               the Ghostscript developers. Commercial customers of
               Artifex should email their support contact, free users
               are encouraged to talk to us on the #ghostscript IRC
               channel on irc.freenode.net.

Unrecoverable error: undefined in DELAYBIND
PostScript/PDF Interpreter finished. Return status 65280 executed command : /opt/local/bin/gs -q -dDELAYBIND -dWRITESYSTEMDICT -dNODISPLAY -dNOEPS -r9600x9600 /var/folders/h5/ggrnw90x4cjfl4jzs4r1rq080000gn/T//psinHSNohC
The interpreter seems to have failed, cannot proceed !
=========================================================================================

I have MAC running OS 10.13.1. Inkscape version 0.92.2.

In ~/.config/inkscape/extensions/ I have the files textext.py and textext.inx. (in textext.py I have changed "pdflatex" to "/Library/Tex/texbin/pdflatex".

I also tried it with Inkscape version 0.91 and I am getting the same behavior.

==============

The same thing happens on Ubuntu 18.04 with the Render/LaTeX extension.

Alvin Penner (apenner) wrote :

- thank you for submitting this report.
- as far as I can tell, the files textext.py and textext.inx are not part of the standard Inkscape installation. Could you indicate where you got these files, or could you attach them for testing purposes?
- also, have you ever been able to successfully run this extension on earlier versions of Inkscape (which version)?

yoram zarai (yoramzar) wrote :

Thank you for the quick reply.

I have downloaded both files (version 0.4.4) from https://pav.iki.fi/software/textext/. I also tried separately the files in https://bitbucket.org/pitgarbe/textext (version 0.6.1) but got the same behavior. I am attaching the files.

I indeed was able to use textext in previous version of Inkscape (been using this feature extensively).

yoram zarai (yoramzar) wrote :
Alvin Penner (apenner) wrote :

thanks for the files. I was not able to reproduce the problem since I do not have the appropriate software installed. The best I could do is the error message below.

since this extension is not part of the standard Inkscape distribution, it is not likely that you will get much of a response from this report. I would suggest you contact the original developers of the extension at https://pav.iki.fi/software/textext/ to see if their extension is compatible with recent Inkscape versions.

.............................................
Traceback (most recent call last):

  File "textext.py", line 306, in <module>

    raise RuntimeError("Neither pygtk nor Tkinter is available!")

RuntimeError: Neither pygtk nor Tkinter is available!

yoram zarai (yoramzar) wrote :

Thank you. Will do.

yoram zarai (yoramzar) wrote :

One more piece of information: I have removed the two files from ~/.config/inkscape/extensions/ and tried: Extensions -> Render -> Latex ... In the dialog box I wrote $1$ and clicked Ok. This yielded the following error:
=========================================================================
 *** WARNING - the DELAYBIND command has been deprecated, and will be

               removed in the next version. For now you can restore

               the behaviour by using -dREALLYDEALYBIND but if you

               require continued use of this command you should contact

               the Ghostscript developers. Commercial customers of

               Artifex should email their support contact, free users

               are encouraged to talk to us on the #ghostscript IRC

               channel on irc.freenode.net.

Unrecoverable error: undefined in DELAYBIND

PostScript/PDF Interpreter finished. Return status 65280 executed command : /opt/local/bin/gs -q -dDELAYBIND -dWRITESYSTEMDICT -dNODISPLAY -dNOEPS /var/folders/h5/ggrnw90x4cjfl4jzs4r1rq080000gn/T//psin7kg5iX

The interpreter seems to have failed, cannot proceed !

Traceback (most recent call last):
  File "eqtexsvg.py", line 160, in <module>
    e.affect()
  File "/Applications/Inkscape_0922.app/Contents/Resources/share/inkscape/extensions/inkex.py", line 283, in affect
    self.effect()
  File "eqtexsvg.py", line 154, in effect
    svg_open(self, svg_file)
  File "eqtexsvg.py", line 81, in svg_open
    doc = inkex.etree.parse(filename)
  File "src/lxml/lxml.etree.pyx", line 3427, in lxml.etree.parse (src/lxml/lxml.etree.c:79801)
  File "src/lxml/parser.pxi", line 1782, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:115995)
  File "src/lxml/parser.pxi", line 1808, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:116345)
  File "src/lxml/parser.pxi", line 1712, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:115233)
  File "src/lxml/parser.pxi", line 1115, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:109930)
  File "src/lxml/parser.pxi", line 573, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:103404)
  File "src/lxml/parser.pxi", line 683, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:105058)
  File "src/lxml/parser.pxi", line 613, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:103967)
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1

===================================================================

This is now without using the textext extension. It seems that the issue in ghostscript now..?

Patrick Storz (ede123) wrote :

I'd say this is a compatibility issue of pstoedit with newer versions of Python as the warning messages try to explain:
- ghostscript has deprecated (or rather) removed the DELAYBIND command
- pstoedit uses said DELAYBIND command when calling ghostscript

So you should carry this upstream to pstoedit developers who "for now you can restore the behavior by using -dREALLYDEALYBIND". If they "require continued use of this command [they] should contact the Ghostscript developers."
As a workaround you could attempt to downgrade ghostscript locally.

Patrick Storz (ede123) wrote :

Sorry, typo above (and I still hate launchpad for not being able to edit posts):
-> compatibility issue of pstoedit with newer versions of *GHOSTSCRIPT*

yoram zarai (yoramzar) wrote :

Thank you for the help.

yoram zarai (yoramzar) wrote :

Closing...

Alvin Penner (apenner) wrote :

just some further info:
problem not reproduced on Windows XP, Inkscape 0.92.2 (unknown), built on Aug 23, 2017.

I used the command Extensions->Render->Latex and it appears to work correctly.

pstoedit: version 3.70
Ghostscript 9.00

Patrick Storz (ede123) on 2017-12-05
Changed in inkscape:
status: New → Invalid
Changed in pstoedit (Debian):
status: Unknown → New
Changed in pstoedit (Debian):
status: New → Fix Released
Changed in pstoedit (Debian):
status: Fix Released → New
Hachmann (marenhachmann) wrote :

This issue regains relevancy for Inkscape again due to Ubuntu 18.04 shipping with an incompatible ghostscript/pstoedit version.

Is there anything we can do?

https://askubuntu.com/questions/1034894/render-latex-is-not-working-in-inkscape-after-installing-to-18-04

And could we keep this open until it's resolved, so users can more easily find the report, and learn how to solve the issue if they need the extension?

Hachmann (marenhachmann) wrote :
description: updated
Hachmann (marenhachmann) wrote :

For the TexText extension, someone has taken up development again. I've linked them to this report - and now I'll link the report back to them:
https://inkscape.org/en/~jcwinkler/%E2%98%85textext?c=1807

There may be a workaround for TexText, but probably not for the extension that comes with Inkscape.

Jan Winkler (jcwinkler) wrote :

Because of this ghostscript+pstoedit incompatibility I implemented the pdf2svg backend in TexText.

TexText first tries to use pdf2svg for the pdf->svg conversion. If this fails, it falls back to pstoedit+ghostscript. If this fails, too, TexText gives up.

The installation instructions for TexText recommend to use pdf2svg on Linux, see point 4 in

https://github.com/textext/textext/wiki/Installation-specific-instructions-for-Linux-systems

So it is the responsibility of the user to ensure that the correct packages are installed. Not the best solution, of course...

I don't see a workaround "outside" of pstoedit because the DELAYBIND command is compiled into pstoedit. So best is to upgrade pstoedit to 3.71 or downgrade gs to 9.20 or upgrade to 9.23...

Hachmann (marenhachmann) wrote :

Jan, can you clarify which versions exactly are incompatible?

Is the following correct?

pstoedit <= 3.70 works with gs <= 9.20 and as well as with gs >= 9.23
pstoedit >= 3.71 works with all versions of gs

Hachmann (marenhachmann) wrote :

We could add the info to the error message in Inkscape's Render/LaTeX extension (which could check for the versions).

Jan Winkler (jcwinkler) wrote :

I did so in TexText:

# Exec pstoedit: pdf -> svg
try:
result = exec_command(['pstoedit', '-f', 'plot-svg',
                                   self.tmp('pdf'), self.tmp('svg')]
                                   + pstoeditOpts)
        except RuntimeError as excpt:
            # Process rare STATUS_DLL_NOT_FOUND = 0xC0000135 error (DWORD)
            if "-1073741515" in excpt.message:
                add_log_message("Call to pstoedit failed because of a STATUS_DLL_NOT_FOUND error. "
                                "Most likely the reason for this is a missing MSVCR100.dll, i.e. you need "
                                "to install the Microsoft Visual C++ 2010 Redistributable Package "
                                "(search for vcredist_x86.exe or vcredist_x64.exe 2010). "
                                "This is a problem of pstoedit, not of TexText!!", LOG_LEVEL_ERROR)
            raise RuntimeError(latest_message())
        if not os.path.exists(self.tmp('svg')) or os.path.getsize(self.tmp('svg')) == 0:
            # Check for broken pstoedit due to deprecated DELAYBIND option in ghostscript
            if "DELAYBIND" in result:
                result += "Ensure that a ghostscript version < 9.21 is installed on your system!\n"
            add_log_message("pstoedit didn't produce output.\n%s" % (result), LOG_LEVEL_ERROR)
            raise RuntimeError(latest_message())

Jan Winkler (jcwinkler) wrote :

Forget the post above! (How can I delete /edit it?)

Correct version:

# Exec pstoedit: pdf -> svg
try:
 result = exec_command(['pstoedit', '-f', 'plot-svg',
                               self.tmp('pdf'), self.tmp('svg')] + pstoeditOpts)
except RuntimeError as excpt:
        # some other stuff here
        # ...
        #
 raise RuntimeError(latest_message())
if not os.path.exists(self.tmp('svg')) or os.path.getsize(self.tmp('svg')) == 0:
 # Check for broken pstoedit due to deprecated DELAYBIND option in ghostscript
 if "DELAYBIND" in result:
  result += "Ensure that a ghostscript version < 9.21 is installed on your system!\n"
 add_log_message("pstoedit didn't produce output.\n%s" % (result), LOG_LEVEL_ERROR)
 raise RuntimeError(latest_message())

=======================

Would you like me to implement a similar thing into the LaTeX extension?

Hachmann (marenhachmann) wrote :

I would like that very, very much, Jan! It would help people understand what's going wrong.

For the message, I'd suggest to also include a short reason, and the updating options, too, (or the full hint about which versions are incompatible), then users have the full picture.

There are three places for this:

- the master branch on gitlab:
https://gitlab.com/inkscape/inkscape/tree/master

- the 0.92.x branch on gitlab:
https://gitlab.com/inkscape/inkscape/tree/0.92.x

- the externalized extensions repo on gitlab (it's not clear to me when, or if, that will become the 'real' extensions place some day, but there are plans for it):
https://gitlab.com/inkscape/extensions

(I think it's only possible to hide one's own posts (not by Email, on the web page at launchpad). Editing is not possible for comments here, only for report texts.)

Jan Winkler (jcwinkler) wrote :

OK, I will implement it.

W.r.t. to the versions I did some further tests (and have to partially correct my assumptions):

pstoedit 3.70 + gs <= 9.21 or gs == 9.23 --> OK
pstoedit 3.71 with any gs version --> OK (theoretically, see comment below)

pstoedit 3.70 + gs 9.22 --> NOT OK

History:
========

gs 9.21 was released on 2017-03-16

The gs team deprecated DELAYBIND in the following commit on 2017-06-17:
http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=8f796773b5aae90362ec500d942dc38e6a1f0f6b

This went into gs 9.22, released on 2017-10-04

The gs team re-introduced DELAYBIND in the following commit on 2017-11-16:
http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=fa499a5809aab45b2891b5c8b2363d1bca890757
(see last paragraph of commit message)

This went into gs 9.23, released on 2018-03-21

=========================================
The pstoedit people on the other hand side introduced the following in pstoedit 3.71:

(in pstoeditoptions.h:)
-----------------------
// with support for -DREALLYDELAYBIND - needed for gs9.22
#define WITHRDB 1

#if WITHRDB
OptionT < bool, BoolTrueExtractor > reallydelaybindversion ;//= false;
// use REALLYDELAYBIND instead of DELAYBIND which not supported in gs 9.22
#endif

(in pstoedit.cpp:)
------------------
#if WITHRDB
   }
   else if (options.reallydelaybindversion) {
      commandline.addarg("-dREALLYDELAYBIND");
#endif
   }
   else {
      commandline.addarg("-dDELAYBIND");
   }

=========================================
So this clearly explains the observations mentioned above. However, under Windows pstoedit 3.71 fails on gs 9.22 despite what is found in the source code :-(

Anyway, since gs 9.22 throws a precise error message we can catch it and give advice to the user.

Hachmann (marenhachmann) wrote :

Whoah, that's a lot of investigation that you've done there (and even on different systems, that's awesome :) )

Thank you!

Jan Winkler (jcwinkler) wrote :

I implemented a first try for the more detailed error message, see

https://gitlab.com/jcwinkler/inkscape/commit/a5cce8af6a1c7b48ca3378d935bd3fab9fc883e2

Of course we should agree on a message. What do you think about the current version? Should we link to the Inkscape FAQ (where an entry has to be written) or somewhere else ?

Currently I did only tests on Ubuntu 18.04. More thorough tests will follow if we finally agree what to display to the user and how to proceed.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.