[reportlab-users] Reportlab and IronPython
Benoit Dupraz
dupraz.benoit at gmail.com
Thu Sep 16 03:23:13 EDT 2010
Hi Robin,
Someone give me a solution in order to solve this problem.
Changing the format() method from PDFFile class in pdfdoc.py from :
def format(self, document):
strings = map(str, self.strings) # final conversion, in case
of lazy objects
return string.join(strings, "")
To:
def format(self, document):
# final conversion, in case of lazy objects
strings = []
for s in self.strings:
if not isinstance(s, types.StringTypes):
strings.append(str(s))
else:
strings.append(s)
return "".join(strings)
After that I still have an error (see attached file) that I debug by my own.
The problem append with unicode2T1 function from _rl_accel.pyd
in pdf metrics we have this try except bloc :
try:
from _rl_accel import unicode2T1 #bug sur ironpython?
print 1
except ImportError:
print 2
unicode2T1 = _py_unicode2T1
If i write :
try:
from _rl_accel import unicode2T1 #bug sur ironpython?
print 1
except ImportError:
print 2
unicode2T1 = _py_unicode2T1
unicode2T1 = _py_unicode2T1
I finally get my PDF !
So I thank you for your help !
Benoit Dupraz
+41 (0)78 909 05 94
2010/9/15 Robin Becker <robin at reportlab.com>
> I suspect part of your problem may be that you're using latin1 as an
> encoding for the python.
>
>
> We have made an assumption that all the strings we'll see in the print
> path, ie things that end up on the pdf canvas, will either be unicode
> strings or will be utf8 encoded byte strings. I see the error refers to
> u'\x93', but I don't think that's a legal character.
>
> I did try out IronPython some time ago, but at that time I was unable to
> get it running. I don't think that was because of any of our extensions
> though.
>
> It may be that you can do without the extensions as most of the code will
> run happily (if a bit slower) without them.
>
> There are three main C extensions,
>
> _rl_accel.pyd which provides fast operations for some of the reportlab
> internal operations. If omitted nothing serious should happen.
>
> _renderPM.pyd which implements a canvas like object for drawing
> charts/lines etc etc.
>
> sgmlop.pyd an sgml type parser to be used with paragraph tags; if omitted
> the paragraph xml may become a bit more xml like ie things like naked
> ampersands will not pass without error.
>
> In addition when we use images other than jpg we need to use PIL the Python
> Imaging Library to do conversions of various bitmap formats into simple RGB.
>
>
>
>
>
> On 15/09/2010 13:59, Benoit Dupraz wrote:
>
>> Hello Robin,
>>
>> I'm writing this mail because I read that you help someone having troubles
>> with reportlab like me.
>> Here is my story :
>>
>> I'm a french beginner dev and I would like to use Reporlab under
>> IronPython
>> I'm using Reportlab 2.4 for Python 2.6 and IronPython 2.6.
>> I've done a basic installation of reportlab (with .exe) as it is explain
>> on
>> this page (Prerequisites too..) :
>> https://www.reportlab.com/software/installation/
>> In order to use Reportlab with IronPython, I'm using ironclad (2.6 or 2.6
>> .NET 4.0 Experimental, both have same errors)
>> If I try to run this code :
>> # -*- coding:Latin-1 -*-
>> import ironclad
>> import sys
>> sys.path.append('C:\\Python26\\DLLs')
>> sys.path.append('C:\\Python26\\Lib')
>> sys.path.append('C:\\Python26\\Lib\\site-packages')
>> import pyRXP
>>
>> import zlib
>> import reportlab
>> from reportlab.pdfgen import canvas
>> c = canvas.Canvas('test.pdf')
>> c.drawString(100,750, "qwertzuiop".encode('ascii'))
>> c.save()
>>
>> Here are the errors : see attached file.
>> Do you have a solution to my problem ? I've been searching on the net and
>> I
>> read many times that it should works (maybe is there a better way than
>> using
>> ironclad...)
>>
>> Thank you, and I hope you can help me solving this problem
>>
> ...........
> --
> Robin Becker
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100916/597e092d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: error2.JPG
Type: image/jpeg
Size: 51644 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100916/597e092d/attachment-0001.jpe>
More information about the reportlab-users
mailing list