python - converting from svg to pdf -


I am trying to replace a svg file with the following code in PDF, but got an error

src> svglib.svglib import srg2rlg from reportlab.graphics import renderPDF drawing = svg2rlg ("test.svg") renderPDF.drawToFile (drawing, "test.pdf") < P> error:

  pydev debugger: start traceback (most recent call final): file "c: \ user \ stone \ .clipse \ org.eclipse.platform_4 .3.0_1709980481_win32_win32_x86 \ Plugins \ org.pythth_thumb_dev_2.8.2.2013090511 \ pysrc \ pydevd.py ", line 1446, & lt; Module & gt; Debugger.run (Setup ['File'], None, None) File "C: \ User \ Stone. Eclipse \ org.eclipse.platform_4.3.0_1709980481_win32_win32_x86 \ plugins \ org.pythczDev_2.8.2.2013090511 \ pysrc \ Pydevd.py ", line 1092, run pydev_imports.execfile (file, world, local) # script file" c: \ user stone \ document \ fastdown \ src \ beagle \ proven and test \ test_renderpdf.py "," line 9 , & Lt; module & gt; drawing = svglib.svg2rlg ("test.svg") file "C: \ Python27 \ lib \ site-packages \ svglib \ svglib.py", line 1178, svg2rlg svgRenderer.render (svg) In the file "C: \ Python27 \ Lib \ site-pa Ckages \ svglib \ svglib.py ", line 511, in the render self.render (child, self.mainGroup) file" C: \ Python27 \ lib \ site-packages \ svglib \ svglib.py ", line 534, render items = In the self.renderG (n) file, the render G item = self.render (child, parent = gr) in the file "C: \ Python 27 \ lib \ site-packages \ svglib \ svglib.py", line 626, "C: \ Python27 \ lib \ site-packages \ svglib \ svglib.py ", line 534, in the render item = self.renderG (n) the file" C: \ Python27 \ lib \ site-packages \ svglib \ svglib.py ", line 626 , In the rendering item = self.render (child, parent = gr) the file "C: \ Python27 \ lib \ site-packages \ svglib \ svglib.py", line 534, render item = self.renderg (n) file " C: \ Python27 \ lib \ site-packages \s In vglib \ svglib.py ", line 626, renderG item = self.render (child, parent = gr) file" C: \ Python27 \ lib \ site-packages \ Svglib \ svglib.py ", in line 554, r in Anderson Size = getattr (self.shapeConverter, methodName) (n) The file "C: \ Python27 \ lib \ site-packages \ svglib \ svglib.py", line 875, convert path in pathway = normalization text (D) file "C: \" Error named Python27 \ lib \ site-packages \ svglib \ svglib.py ", line 146, SvgPath a = string.replace (a, 'e-', 'ee') in general: global name 'string' is not defined  

In addition I avoid hard files and a temporary svg / Want to use StringIO to create a pdf file, but I think svg2rlg only accepts one path as input.

The hand was edited to me for this work:

 < Code> / user / & lt; MY_USER & gt; / .virtualenvs / & lt; MY_VENV & gt; /lib/python2.7/site-packages/svglib/svglib.py  

and adding this missing

import string


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -