#18 PDF generation falis

0.43
closed-accepted
3
2011-09-27
2011-06-14
Jay
No

I created a simple invoice. When trying to generate a pdf from it, a dialog tells me that pdf generation failed. The detail button displays: unknown problem. Console-output is:

kraft(2430)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
File "/usr/share/apps/kraft/tools/erml2pdf.py", line 169
elif node.localName=='blockSpan':
^
TabError: inconsistent use of tabs and spaces in indentation

using 0.43 on archlinux (x64) self-compiled

Discussion

  • Jay

    Jay - 2011-07-15

    with the latest svn version there is no more information in the console about what error occurs. In the Document Overview a click on -> show (Document) starts Okular, but okular complains that it cannot find the specific Document in .kde4/share/apps/kraft/archivePdf//1116_1.pdf

    I noticed the double slash after archivePdf and tried to open the document the manual way, the folder contains the pdf file, which has zero size.

    In conclusion, pdf generation fails at some point.

     
  • Klaas Freitag

    Klaas Freitag - 2011-07-17
    • status: open --> closed-invalid
     
  • Klaas Freitag

    Klaas Freitag - 2011-07-17

    Sorry, there must have gone something wrong with the install of your files. erml2pdf.py is python code which requires clean space or tab conventions. Please copy the file again and retry as I can not reproduce that with the upstream file. Reopen if neccessary.

     
  • Thomas Weißschuh

    After checking out rev 1255683 from svn://anonsvn.kde.org/home/kde/trunk/playground/office/kraft
    the file tools/erml2pdf.py contains spaces instead of tabs on line 169.
    ( likethe tarball of 0.4.3)

    python -tt erml2pdf.py yields the same error.

     
  • Thomas Weißschuh

    After playing with test.trml it seems that it's a python2 <-> python3 problem, as archlinux uses python3 as /usr/bin/python

    The error is in fact just a warning.
    It may nevertheless be better to fix the spaces as it could break with future versions of python.
    Changing python to python2 in tools/erml2pdf should work

     
  • Jay

    Jay - 2011-09-26

    with the proposed change to python2 it goes down with:

    kraft(23423)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
    File "/usr/share/apps/kraft/tools/erml2pdf.py", line 334
    raise ValueError, "Not enough space"
    ^
    SyntaxError: invalid syntax

    if case this is related to diskspace, there is plenty available in /tmp, $home & /

     
  • Klaas Freitag

    Klaas Freitag - 2011-09-26

    This error is fired from reportlab if you try to place a 'flowable' on the screen that is too large to fit on the screen. Did you tweak the original template?

     
  • Jay

    Jay - 2011-09-26

    I recently deleted krafts configuration files to start from scratch, in short: I didnt not touch the templates.

     
  • Thomas Weißschuh

    This looks like a syntax error rather then the exception being raised, so it shouldn't be a problem of reportlab

     
  • Thomas Weißschuh

    At last it turned out, to be a python2 <-> python3 error.
    On line 345 the executable named "python" is searched and later executed.
    Changing this to python2 solves the problem.
    Maybe it would be possible to change it shebang in tools/erml2pdf.by and directly call this script as this would prevent some redundancy.

    The other errors/warnings thrown by python are those whitespace/tab issues and the wrong syntax of the exception:
    line 344 of tools/erml2pdf.py should look like:
    raise ValueError("Not enough space")
    as this throws a object of type error rather then a touple of an error and a string.

     
  • Klaas Freitag

    Klaas Freitag - 2011-09-27

    Ok, I did some investigation and ported erml2pdf.py to python3 which was not a big thing. The bigger problem is that the reportlab lib we use for pdf creation does not work with python 3 yet. That means you guys will have to use python 2 anyway. You should check your packaging.

    Assuming that your python2 interpreter is called python2, I will change the Kraft code to first search for the python2 executable and than for the python executable in case python2 was not found. That should work.

    I don't want to go the shebang way btw because I want to avoid a shell dependency as a proper shell is not available on all platforms Kraft will go in some day, namely Windows. So its better to call python directly with the script name.

    What do you think?

    I leave the bug open for now to do the python2 search first in reportgenerator.cpp

     
  • Klaas Freitag

    Klaas Freitag - 2011-09-27
    • assigned_to: nobody --> kfreitag
    • priority: 5 --> 3
    • labels: --> Documents/RML
    • status: closed-invalid --> closed-accepted
     
  • Thomas Weißschuh

    erml2pdf.py being python2 shouldn't be a big deal since python2 won't go away soon.
    But i think other distributions will switch to python3 as their python provider so changing it to python2 in erml2pdf.py, reportenerator.cpp and the erml2pdf helper script will have to come at some time in the future.

    I just checked python on debian and ubuntu and both of them don't hav a python2 binary/link.
    Only python2.X which will lead to hell with different distributions and versions of them.

    Maybe there is a way to check this via cmake or some other way.

    Until then I'll simply continue patching the sources.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks