| Issue 188: | Error when trying to use an svg image in a pdf | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? 1. Follow the steps on this page http://lateral.netmanagers.com.ar/stories/BBS52.html#id6 2. Run '/usr/local/bin/rst2pdf slides.txt -b1 -s slides.style' this shows the error below. 3. Remove the "background" : "background.svg", line from slides.style and rerun the rst2pdf command. This time the pdf will come out as expected but with no background of course. What is the expected output? What do you see instead? The expected outcome is to have a 4 page pdf with a background image as shown on the page listed in step 1. What version of the product are you using? On what operating system? I am running on Ubuntu Jaunty with rst2pdf installed by easy_install and python 2.6 Please provide any additional information below. This is what the error looks like. /usr/local/bin/rst2pdf slides.txt -b1 -s slides.style /usr/lib/python2.6/dist-packages/uniconvertor/app/utils/locale_utils.py:9: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module. from popen2 import popen2 Traceback (most recent call last): File "/usr/local/bin/rst2pdf", line 8, in <module> load_entry_point('rst2pdf==0.11', 'console_scripts', 'rst2pdf')() File "/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11-py2.6.egg/rst2pdf/createpdf.py", line 1651, in main compressed=options.compressed) File "/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11-py2.6.egg/rst2pdf/createpdf.py", line 1297, in createPdf pdfdoc.multiBuild(elements) File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 855, in multiBuild self.build(tempStory, filename, canvasmaker) File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 774, in build self.clean_hanging() File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 412, in clean_hanging self.handle_flowable(self._hanging) File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 659, in handle_flowable f.apply(self) File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 118, in apply getattr(doc,arn)(*args) File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 435, in handle_pageBegin self.pageTemplate.beforeDrawPage(self.canv,self) File "/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11-py2.6.egg/rst2pdf/createpdf.py", line 1404, in beforeDrawPage self.styles.pw, self.styles.ph) File "/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11-py2.6.egg/rst2pdf/svgimage.py", line 55, in __init__ self.doc = load.load_drawing(filename) File "/usr/lib/python2.6/dist-packages/uniconvertor/app/io/load.py", line 364, in load_drawing return load_drawing_from_file(file, filename) File "/usr/lib/python2.6/dist-packages/uniconvertor/app/io/load.py", line 316, in load_drawing_from_file line = file.readline() AttributeError: 'unicode' object has no attribute 'readline' |
|
,
Sep 07, 2009
I took the same background.svg file and exported it as a png and used it in the slides.style file and it worked find. I was able to see the background in the pdf output. The issue seems to be only with svgs. |
|
,
Sep 07, 2009
In fact, it seems to be a bug in uniconvertor or its interface with rst2pdf. I'll take a lok at it tomorrow. |
|
,
Sep 07, 2009
I can't reproduce it, but it may be a problem with 0.11. Could you try with latest SVN? It's not too hard to install. |
|
,
Sep 08, 2009
I pulled down the latest svn copy and installed it on a different ubuntu jaunty
machine and got the following error.
elake@jaunty:~$ rst2pdf slides.txt -b1 -s slides.style
/usr/lib/python2.6/dist-packages/uniconvertor/app/utils/locale_utils.py:9:
DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
from popen2 import popen2
Cannot list directory /home/elake/.uniconvertor:[Errno 2] No such file or directory:
'/home/elake/.uniconvertor'
ignoring it in font_path
Traceback (most recent call last):
File "/usr/local/bin/rst2pdf", line 8, in <module>
load_entry_point('rst2pdf==0.11.dev-r997', 'console_scripts', 'rst2pdf')()
File
"/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11.dev_r997-py2.6.egg/rst2pdf/createpdf.py",
line 2197, in main
compressed=options.compressed)
File
"/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11.dev_r997-py2.6.egg/rst2pdf/createpdf.py",
line 1749, in createPdf
pdfdoc.multiBuild(elements)
File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line
855, in multiBuild
self.build(tempStory, filename, canvasmaker)
File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line
774, in build
self.clean_hanging()
File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line
412, in clean_hanging
self.handle_flowable(self._hanging)
File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line
659, in handle_flowable
f.apply(self)
File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line
118, in apply
getattr(doc,arn)(*args)
File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line
435, in handle_pageBegin
self.pageTemplate.beforeDrawPage(self.canv,self)
File
"/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11.dev_r997-py2.6.egg/rst2pdf/createpdf.py",
line 1878, in beforeDrawPage
self.styles.pw, self.styles.ph)
File
"/usr/local/lib/python2.6/dist-packages/rst2pdf-0.11.dev_r997-py2.6.egg/rst2pdf/svgimage.py",
line 55, in __init__
self.doc = load.load_drawing(filename)
File "/usr/lib/python2.6/dist-packages/uniconvertor/app/io/load.py", line 364, in
load_drawing
return load_drawing_from_file(file, filename)
File "/usr/lib/python2.6/dist-packages/uniconvertor/app/io/load.py", line 316, in
load_drawing_from_file
line = file.readline()
AttributeError: 'unicode' object has no attribute 'readline'
|
|
,
Sep 08, 2009
Ok, I will try to reproduce it again then. versions of uniconvertor and reportlab, please? |
|
,
Sep 08, 2009
python-reportlab Version: 2.3-0ubuntu11 python-uniconvertor Version: 1.1.3-4ubuntu1 |
|
,
Sep 08, 2009
I took a look at the /usr/local/lib/python2.6/dist-packages/rst2pdf-0.11-py2.6.egg/rst2pdf/svgimage.py code and I saw that svglib is the prefered way to work with the svg files. I have since installed svglib and now the 'rst2pdf slides.txt -b1 -s slides.style' works fine. The only output messages are about using subprocess instead of popen2. /usr/lib/python2.6/dist-packages/uniconvertor/app/utils/locale_utils.py:9: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module. from popen2 import popen2 I still see this as a possible issue in uniconvertor. On a side note I ran 'uniconvertor background.svg background.pdf' and it was able to make the pdf with no problem. |
|
,
Sep 08, 2009
Lastly ... the stuff above was done using the 0.11 version installed from easy_install -U rst2pdf not from svn. |
|
,
Sep 17, 2009
I just can't reproduce it :-( I wonder why there are several errors that *only* happen on Ubuntu. |
|
,
Sep 17, 2009
Ok, just guessing here, but it seems the problem is line 350 in uniconvertor's load.py: if type(filename) == StringType: It's checking that filename is a str. It *may* be rst2pdf is sending unicode. So, I am now encoding the filename as a utf-8 string (r1046), but this really looks like a uniconvertor bug, and have reported it at their forum: http://sk1project.org/forum/viewthread.php?thread_id=48 I am marking it as fixed. Could you please check if it works correctly after r1046, with uniconvertor, without svglib?
Status: Fixed
|
|
,
Sep 17, 2009
I will be happy to test it. Is it already in svn? If so then I will update my checkout and give it a go tonight. |
|
,
Sep 17, 2009
Yes, revision 1046 or higher. Thanks! |
|
,
Sep 17, 2009
Just tried with uniconvertor and svn co 1048. Seems to be working however the resulting pdf does not look as good with uniconvertor as it does with svglib. You can see what I mean in the attached files. The first one was done without svglib installed. I then installed svglib and ran the same command to create the pdf as before using the same files. |
|
,
Sep 17, 2009
Indeed svglib looks much better. Ayway, verified that it works now :-)
Status: Verified
|
|
|
|