From gherman at darwin.in-berlin.de Mon Dec 1 09:27:11 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Mon, 1 Dec 2008 15:27:11 +0100 Subject: [reportlab-users] BUG: Fontnames with spaces Message-ID: <1334012D-5284-4E9E-B6E9-FD0BA564EEF8@darwin.in-berlin.de> [...] File "/usr/local/lib/python2.5/site-packages/reportlab/pdfbase/ ttfonts.py", line 989, in __init__ self.face = TTFontFace(filename, validate=validate, subfontIndex=subfontIndex) File "/usr/local/lib/python2.5/site-packages/reportlab/pdfbase/ ttfonts.py", line 898, in __init__ TTFontFile.__init__(self, filename, validate=validate, subfontIndex=subfontIndex) File "/usr/local/lib/python2.5/site-packages/reportlab/pdfbase/ ttfonts.py", line 412, in __init__ self.extractInfo(charInfo) File "/usr/local/lib/python2.5/site-packages/reportlab/pdfbase/ ttfonts.py", line 487, in extractInfo raise TTFError, "psName=%r contains invalid character '%s' ie U+ %04X" % (psName,c,ord(c)) reportlab.pdfbase.ttfonts.TTFError: psName='UniversalCondensed Regular' contains invalid character ' ' ie U+0020 Seems like this wasn't fixed in RL 2.2... @RL: Please look up the relevant reports on this list, I don't like to repeat myself... Regards, Dinu From natali at poisson.phc.unipi.it Mon Dec 1 11:20:21 2008 From: natali at poisson.phc.unipi.it (Fabio Natali) Date: Mon, 1 Dec 2008 17:20:21 +0100 Subject: [reportlab-users] Vertical alignment Message-ID: <20081201162021.GA26612@poisson.phc.unipi.it> Dear all, I'm having some alignment/placement troubles. Specifically, I'm using Reportlab to print an invoice. I have a table with a line for each product I've sold. At the end of the page I want to get the total amount. If the table spans across different pages, the sum line will still have to appear at the bottom of the final page. Could you kindly provide me with some tips to get this done? Here comes some example code [0]. Thank you so much, Fabio. [0] http://dpaste.com/95076/ -- Fabio Natali From andy at reportlab.com Mon Dec 1 11:33:09 2008 From: andy at reportlab.com (Andy Robinson) Date: Mon, 1 Dec 2008 16:33:09 +0000 Subject: [reportlab-users] BUG: Fontnames with spaces In-Reply-To: <1334012D-5284-4E9E-B6E9-FD0BA564EEF8@darwin.in-berlin.de> References: <1334012D-5284-4E9E-B6E9-FD0BA564EEF8@darwin.in-berlin.de> Message-ID: <956003ae0812010833l61552b4cydf8314638473d9c4@mail.gmail.com> 2008/12/1 Dinu Gherman : > Seems like this wasn't fixed in RL 2.2... > > @RL: Please look up the relevant reports on this list, > I don't like to repeat myself... I missed this one - looks like it fizzled out without a decision. I have committed your change, which looks sensible to me, and logged it as item 851 (completed) on the tracker. (Do you have such a font file we could use for a test case? We don't need to commit it but I'd like to at least see the code run once. If so, just email direct to me.) Thanks, Andy From park at zes-thailand.com Mon Dec 1 20:22:40 2008 From: park at zes-thailand.com (Park) Date: Tue, 02 Dec 2008 01:22:40 -0000 Subject: [reportlab-users] how to: set image as a background and how to get page number in "onPage" function Message-ID: <1224660045.6241.10.camel@olivia> hi, I have a problem with setting an image as a background. Has reportlab any functions support on that? Do u have any ideas about that? Also, for the page number, with this code: --------------------------------------------------------------------------- doc.addPageTemplates([PageTemplate(id='OneCol',frames=frameT,onPage=foot2), PageTemplate(id='TwoCol',frames=[f1,f2],onPage=foot2)]) def foot2(canvas,doc): canvas.saveState() canvas.setFont('Times-Roman',9) canvas.drawString(inch, 0.75 * inch, "Page %d" % doc.page) a = canvas.getPageNumber() print "**************" print "Page Number = " + str(a) canvas.restoreState() ---------------------------------------------------------------------------- how can I match page number with the contents cuz i wanna do table of contents and I dun have any idea about that. Can i add more 'story' variable into 'foot2' function cuz I'll match the contents with page number there. Thx, Big PS: English is not my mother languages. From arkadi at smartbit.be Wed Dec 3 09:13:38 2008 From: arkadi at smartbit.be (Arkadi Colson) Date: Wed, 03 Dec 2008 15:13:38 +0100 Subject: [reportlab-users] splitting table on multiple pages Message-ID: <49369412.8000306@smartbit.be> Hi all, I'm having a problem with splitting a table on the next page. Following error is generated. reportlab.platypus.doctemplate.LayoutError: Flowable with cell(0,0) containing 'ALGEMEEN TOTAALPERCENTAGE' too large on page 1 Somebody any idea? Thanks a lot. Arkadi Colson From robin at reportlab.com Wed Dec 3 09:38:36 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 03 Dec 2008 14:38:36 +0000 Subject: [reportlab-users] splitting table on multiple pages In-Reply-To: <49369412.8000306@smartbit.be> References: <49369412.8000306@smartbit.be> Message-ID: <493699EC.6070003@chamonix.reportlab.co.uk> Arkadi Colson wrote: > Hi all, > > > I'm having a problem with splitting a table on the next page. Following > error is generated. > > reportlab.platypus.doctemplate.LayoutError: Flowable
-1232790932 1 rows x 6 cols> with cell(0,0) containing > 'ALGEMEEN TOTAALPERCENTAGE' too large on page 1 > > Somebody any idea? > > > Thanks a lot. > Arkadi Colson well it could be that the table is too large. That probably means it's either too wide or one of the rows is too high for the frame it is in. -- Robin Becker From arkadi at smartbit.be Wed Dec 3 09:44:39 2008 From: arkadi at smartbit.be (Arkadi Colson) Date: Wed, 03 Dec 2008 15:44:39 +0100 Subject: [reportlab-users] splitting table on multiple pages In-Reply-To: <493699EC.6070003@chamonix.reportlab.co.uk> References: <49369412.8000306@smartbit.be> <493699EC.6070003@chamonix.reportlab.co.uk> Message-ID: <49369B57.5030704@smartbit.be> The table is in the doc.build() method and not in a frame but... All rows of the table are having a fixed height. When I set them on auto, it seems to work... Is this an option somewhere or maybe a little bug? How can I fix this, maybe with a workaround? Arkadi Robin Becker wrote: > Arkadi Colson wrote: >> Hi all, >> >> >> I'm having a problem with splitting a table on the next page. >> Following error is generated. >> >> reportlab.platypus.doctemplate.LayoutError: Flowable
> -1232790932 1 rows x 6 cols> with cell(0,0) containing >> 'ALGEMEEN TOTAALPERCENTAGE' too large on >> page 1 >> >> Somebody any idea? >> >> >> Thanks a lot. >> Arkadi Colson > > well it could be that the table is too large. That probably means it's > either too wide or one of the rows is too high for the frame it is in. From paul.barrass at safeonlinebilling.com Wed Dec 3 09:50:49 2008 From: paul.barrass at safeonlinebilling.com (Paul Barrass) Date: Wed, 03 Dec 2008 14:50:49 +0000 Subject: [reportlab-users] splitting table on multiple pages In-Reply-To: <49369B57.5030704@smartbit.be> References: <49369412.8000306@smartbit.be> <493699EC.6070003@chamonix.reportlab.co.uk> <49369B57.5030704@smartbit.be> Message-ID: <49369CC9.1010004@safeonlinebilling.com> Arkadi Colson wrote: > The table is in the doc.build() method and not in a frame but... I think the SimpleDocTemplate (or whatever it's called) still uses Frames, but with a single Frame taking up the entire page. > All rows of the table are having a fixed height. > When I set them on auto, it seems to work... Is this an option > somewhere or maybe a little bug? How can I fix this, maybe with a > workaround? If it works on auto, but not when you fix the heights, it sounds like you're fixing the height too big - how big are you setting the rowHeights? > Robin Becker wrote: >> >> well it could be that the table is too large. That probably means >> it's either too wide or one of the rows is too high for the frame it >> is in. > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users Paul. From arkadi at smartbit.be Wed Dec 3 09:58:25 2008 From: arkadi at smartbit.be (Arkadi Colson) Date: Wed, 03 Dec 2008 15:58:25 +0100 Subject: [reportlab-users] splitting table on multiple pages In-Reply-To: <49369CC9.1010004@safeonlinebilling.com> References: <49369412.8000306@smartbit.be> <493699EC.6070003@chamonix.reportlab.co.uk> <49369B57.5030704@smartbit.be> <49369CC9.1010004@safeonlinebilling.com> Message-ID: <49369E91.6@smartbit.be> The row heights are set to 5*mm for each row. The complete table does indeed not fit onto the current page, so it should continue on the next page. Arkadi Paul Barrass wrote: > Arkadi Colson wrote: >> The table is in the doc.build() method and not in a frame but... > > I think the SimpleDocTemplate (or whatever it's called) still uses > Frames, but with a single Frame taking up the entire page. >> All rows of the table are having a fixed height. >> When I set them on auto, it seems to work... Is this an option >> somewhere or maybe a little bug? How can I fix this, maybe with a >> workaround? > If it works on auto, but not when you fix the heights, it sounds like > you're fixing the height too big - how big are you setting the > rowHeights? > > >> Robin Becker wrote: >>> >>> well it could be that the table is too large. That probably means >>> it's either too wide or one of the rows is too high for the frame it >>> is in. >> >> _______________________________________________ >> reportlab-users mailing list >> reportlab-users at reportlab.com >> http://two.pairlist.net/mailman/listinfo/reportlab-users > > Paul. -- Smartbit bvba Hoogstraat 13 B-3670 Meeuwen T: +32 89 46 81 08 F: +32 89 46 81 10 From robin at reportlab.com Wed Dec 3 11:35:00 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 03 Dec 2008 16:35:00 +0000 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <492D8A36.3070302@gmail.com> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> Message-ID: <4936B534.5070503@chamonix.reportlab.co.uk> Dirk Holtwick wrote: > Hi, > > to fix the described error please modify the following function in > "paragraph.py": > > -----------------8<---------------[cut here] > #on UTF8 branch, split and strip must be unicode-safe! > def split(text, delim=None): > if type(text) is str: text = text.decode('utf8') > if type(delim) is str: delim = delim.decode('utf8') > # This fixes   issue and multiple linebraks on splitted page part > if delim is None and text == u'\xa0': > delim = ' ' > return [uword.encode('utf8') for uword in text.split(delim)] > -----------------8<---------------[cut here] ....... I think this works in some special cases particularly when using the   form. However, it still fails to split in the case that u'\xa0' is embedded in the string in a more normal way. eg even using the above >>> split(u'a\nb\xa0\tbbbb') ['a', 'b', 'bbbb'] whereas we presumably don't want \xa0 to be regarded as a split point. The problem lies with python's unicode split which regards the None delim case as being all white space codes. In the C code these seem to be used > u'\u0009', # HORIZONTAL TABULATION > u'\u000A', # LINE FEED > u'\u000B', # VERTICAL TABULATION > u'\u000C', # FORM FEED > u'\u000D', # CARRIAGE RETURN > u'\u001C', # FILE SEPARATOR > u'\u001D', # GROUP SEPARATOR > u'\u001E', # RECORD SEPARATOR > u'\u001F', # UNIT SEPARATOR > u'\u0020', # SPACE > u'\u0085', # NEXT LINE > u'\u00A0', # NO-BREAK SPACE > u'\u1680', # OGHAM SPACE MARK > u'\u2000', # EN QUAD > u'\u2001', # EM QUAD > u'\u2002', # EN SPACE > u'\u2003', # EM SPACE > u'\u2004', # THREE-PER-EM SPACE > u'\u2005', # FOUR-PER-EM SPACE > u'\u2006', # SIX-PER-EM SPACE > u'\u2007', # FIGURE SPACE > u'\u2008', # PUNCTUATION SPACE > u'\u2009', # THIN SPACE > u'\u200A', # HAIR SPACE > u'\u200B', # ZERO WIDTH SPACE > u'\u2028', # LINE SEPARATOR > u'\u2029', # PARAGRAPH SEPARATOR > u'\u202F', # NARROW NO-BREAK SPACE > u'\u205F', # MEDIUM MATHEMATICAL SPACE > u'\u3000', # IDEOGRAPHIC SPACE so I believe we can change split to a better scheme using _WSC=u''.join(( u'\u0009', # HORIZONTAL TABULATION u'\u000A', # LINE FEED u'\u000B', # VERTICAL TABULATION u'\u000C', # FORM FEED u'\u000D', # CARRIAGE RETURN u'\u001C', # FILE SEPARATOR u'\u001D', # GROUP SEPARATOR u'\u001E', # RECORD SEPARATOR u'\u001F', # UNIT SEPARATOR u'\u0020', # SPACE u'\u0085', # NEXT LINE #u'\u00A0', # NO-BREAK SPACE u'\u1680', # OGHAM SPACE MARK u'\u2000', # EN QUAD u'\u2001', # EM QUAD u'\u2002', # EN SPACE u'\u2003', # EM SPACE u'\u2004', # THREE-PER-EM SPACE u'\u2005', # FOUR-PER-EM SPACE u'\u2006', # SIX-PER-EM SPACE u'\u2007', # FIGURE SPACE u'\u2008', # PUNCTUATION SPACE u'\u2009', # THIN SPACE u'\u200A', # HAIR SPACE u'\u200B', # ZERO WIDTH SPACE u'\u2028', # LINE SEPARATOR u'\u2029', # PARAGRAPH SEPARATOR u'\u202F', # NARROW NO-BREAK SPACE u'\u205F', # MEDIUM MATHEMATICAL SPACE u'\u3000', # IDEOGRAPHIC SPACE )) #on UTF8 branch, split and strip must be unicode-safe! def split(text, delim=None): if type(text) is str: text = text.decode('utf8') if type(delim) is str: delim = delim.decode('utf8') if delim is None and u'\xa0' in text: delim = _WSC return [uword.encode('utf8') for uword in text.split(delim)] can you check this against your problem cases? -- Robin Becker From dkuhlman at rexx.com Wed Dec 3 18:08:12 2008 From: dkuhlman at rexx.com (Dave Kuhlman) Date: Wed, 3 Dec 2008 15:08:12 -0800 Subject: [reportlab-users] Future of py2pdf In-Reply-To: <3A314D7C-5CBD-4606-94C6-5308CACF7F28@darwin.in-berlin.de> References: <3A314D7C-5CBD-4606-94C6-5308CACF7F28@darwin.in-berlin.de> Message-ID: <20081203230812.GA18407@cutter.rexx.com> On Wed, Nov 19, 2008 at 11:50:48AM +0100, Dinu Gherman wrote: > Hi, > > I've just looked again at a tool named py2pdf, that I wrote > and that was included in the ReportLab distribution in 2001 > I think (with reportlab 0.92 or so!). AFAIK, the Python Wing > IDE used this module and maybe still does. Dinu - Thank you for a very useful and useable tool. I use pypdf.py frequently to produce displayable sample code for students to whom I'm teaching Python. I hope you will continue to support it. I've made a couple of changes to my copy of py2pdf.py. I'd like to suggest that you consider including these changes. The changes are: 1. I'd like to be able to add the ".pdf" extension to file names rather than replace the ".py" with ".pdf". So I added command line flags to control that. 2. I'd like line numbering to start with 1 rather than 0. I hard-wired that into py2pdf.py. Maybe, if you choose to support this, you would want to add a command line flag, for example, something like --initial-line-number, along with a default of 0 or 1, whichever. I've attached a patch file and the original to which I made my changes. Needless to say, you know py2pdf.py better than I and are likely to know better ways to make these changes. Still, I'm hoping that a patch file will save you some work. Thanks again for a really good tool. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman -------------- next part -------------- *** orig/py2pdf.py Fri Nov 21 16:08:26 2008 --- py2pdf.py Fri Nov 21 16:51:55 2008 *************** *** 42,47 **** --- 42,50 ---- --multiPage generate one file per page (with filenames tagged by 1, 2...), disables PDF outline --noOutline don't generate PDF outline (default: unset) + --outExt output file extension (default: '.pdf') + --appendOutExt append rather than replace output file extension + (default: replace) -v or --verbose set verbose mode Takes the input, assuming it is Python source code and formats *************** *** 356,362 **** 'paperFormat': 'A4', 'landscape' : 0, 'title' : None, ! 'multiPage' : 0}) # Default colors (for color mode), mostly taken from py2html. self.pool.update({'commCol' : HexColor('#1111CC'), --- 359,368 ---- 'paperFormat': 'A4', 'landscape' : 0, 'title' : None, ! 'multiPage' : 0, ! 'outExt': '.pdf', ! 'appendOutExt' : False, ! }) # Default colors (for color mode), mostly taken from py2html. self.pool.update({'commCol' : HexColor('#1111CC'), *************** *** 438,443 **** --- 444,450 ---- lo = 'tabSize= paperFormat= paperSize= landscape stdout title= fontName= fontSize=' lo = lo + ' bgCol= verbose lineNum marcs help multiPage noOutline config= input= mode=' lo = lo + ' commCol= identCol= kwCol= strngCol= paramCol= restCol=' + lo = lo + ' outExt= appendOutExt' longOpts = string.split(lo, ' ') try: *************** *** 509,514 **** --- 516,527 ---- elif name == 'files': self.pool['files'] = value + elif name == 'outExt': + self.pool['outExt'] = value + + elif name == 'appendOutExt': + self.pool['appendOutExt'] = True + else: # Set the value found or 1 for options without values. self.pool[name] = value or 1 *************** *** 542,553 **** self.options = options self.canvas = None self.multiLineStringStarted = 0 ! self.lineNum = 0 # Set a default color and font. o = self.options self.currColor = o.restCol self.currFont = (o.fontName, o.fontSize) ### Helper methods. --- 555,568 ---- self.options = options self.canvas = None self.multiLineStringStarted = 0 ! self.lineNum = 1 # Set a default color and font. o = self.options self.currColor = o.restCol self.currFont = (o.fontName, o.fontSize) + self.outExt = o.outExt + self.appendOutExt = o.appendOutExt ### Helper methods. *************** *** 605,611 **** def begin(self, srcPath, numLines): "Things to do before doing anything else." ! self.lineNum = 0 self.pageNum = 0 self.numLines = numLines self.srcPath = srcPath --- 620,626 ---- def begin(self, srcPath, numLines): "Things to do before doing anything else." ! self.lineNum = 1 self.pageNum = 0 self.numLines = numLines self.srcPath = srcPath *************** *** 616,622 **** self.pdfPath = sys.stdout else: if srcPath != sys.stdin: ! self.pdfPath = os.path.splitext(srcPath)[0] + '.pdf' else: self.pdfPath = sys.stdout --- 631,641 ---- self.pdfPath = sys.stdout else: if srcPath != sys.stdin: ! self.pdfPath, ext = os.path.splitext(srcPath) ! if self.appendOutExt: ! self.pdfPath = '%s%s%s' % (self.pdfPath, ext, self.outExt, ) ! else: ! self.pdfPath = '%s%s' % (self.pdfPath, self.outExt, ) else: self.pdfPath = sys.stdout -------------- next part -------------- A non-text attachment was scrubbed... Name: py2pdf.py Type: text/x-python Size: 45666 bytes Desc: not available Url : From mukkablues at hotmail.it Thu Dec 4 04:13:09 2008 From: mukkablues at hotmail.it (giulia cherubini) Date: Thu, 4 Dec 2008 10:13:09 +0100 Subject: [reportlab-users] rotate page Message-ID: hello! can anyone help me? I'm trying to rotate a page because values I have to print overflow. When i put 'can.rotate(90)' values...go outside paper and disappear. I'm not sure to have correctly understand how to use the rotate method, andwhere exactly put it for rotate the whole page...and see it!!! I attach my little sample (wx_python, postgres) thanx to all!!! giulia _________________________________________________________________ Che tipo sei? Crea la tua animoticon invernale! http://www.messenger.it/test.html -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: stampa_aziende.py Url: From gherman at darwin.in-berlin.de Thu Dec 4 04:40:57 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 4 Dec 2008 10:40:57 +0100 Subject: [reportlab-users] rotate page In-Reply-To: References: Message-ID: <74C96127-D890-4B13-8174-E8FF30B79515@darwin.in-berlin.de> giulia cherubini: > hello! > can anyone help me? > I'm trying to rotate a page because values I have to print overflow. > When i put 'can.rotate(90)' values...go outside paper and disappear. > I'm not sure to have correctly understand how to use the rotate > method, andwhere exactly put it for rotate the whole page...and see > it!!! > I attach my little sample (wx_python, postgres) > thanx to all!!! > giulia Hi Giulia! from your description it seems like you are not rotating the page, but the page *content*. Try Canvas.setPageRotation() instead! Regards, Dinu From mukkablues at hotmail.it Thu Dec 4 04:50:57 2008 From: mukkablues at hotmail.it (giulia cherubini) Date: Thu, 4 Dec 2008 10:50:57 +0100 Subject: [reportlab-users] [reportlab user] rotate page Message-ID: ok!thanx for reply,I'll try this!thax so much!giulia _________________________________________________________________ Vai oltre le parole, scarica il nuovo Messenger! http://download.live.com/?mkt=it-it -------------- next part -------------- An HTML attachment was scrubbed... URL: From arkadi at smartbit.be Thu Dec 4 05:11:12 2008 From: arkadi at smartbit.be (Arkadi Colson) Date: Thu, 04 Dec 2008 11:11:12 +0100 Subject: [reportlab-users] document structure Message-ID: <4937ACC0.7000709@smartbit.be> Hi all, I need some help in choosing the right method for the following document structure. In fact the pdf should contain student results tables with a corresponding header and footer for each student. The problem is that the results table in the middle can grow over more then 1 page. So the footer should then only appear on the last page for that student. The header should repeat itself on both pages. Can somebody suggest a reportlab method? Which templates I should use? Frames...? Thanks in advance, Arkadi Colson From mukkablues at hotmail.it Thu Dec 4 05:41:19 2008 From: mukkablues at hotmail.it (giulia cherubini) Date: Thu, 4 Dec 2008 11:41:19 +0100 Subject: [reportlab-users] rotate page In-Reply-To: <74C96127-D890-4B13-8174-E8FF30B79515@darwin.in-berlin.de> References: <74C96127-D890-4B13-8174-E8FF30B79515@darwin.in-berlin.de> Message-ID: well, i tryied what you suggest, but: ---when i set mycanvas.setPageRotation(90) it disappear ---when i set mycanvas.setPageRotation(180) it's head-down i just wanna to see it written from the smaller margin so values are enough space (i don't know if i'm explain clear, i'm new in reportlab and i dont' speak english so well!) thanx! giulia > From: gherman at darwin.in-berlin.de> To: reportlab-users at reportlab.com> Date: Thu, 4 Dec 2008 10:40:57 +0100> Subject: Re: [reportlab-users] rotate page> > giulia cherubini:> > > hello!> > can anyone help me?> > I'm trying to rotate a page because values I have to print overflow.> > When i put 'can.rotate(90)' values...go outside paper and disappear.> > I'm not sure to have correctly understand how to use the rotate > > method, andwhere exactly put it for rotate the whole page...and see > > it!!!> > I attach my little sample (wx_python, postgres)> > thanx to all!!!> > giulia> > Hi Giulia!> > from your description it seems like you are not rotating the> page, but the page *content*. Try Canvas.setPageRotation()> instead!> > Regards,> > Dinu> > _______________________________________________> reportlab-users mailing list> reportlab-users at reportlab.com> http://two.pairlist.net/mailman/listinfo/reportlab-users _________________________________________________________________ 50 nuovi schemi per giocare su CrossWire! Accetta la sfida! http://livesearch.games.msn.com/crosswire/play_it/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dirk.holtwick at gmail.com Thu Dec 4 08:19:31 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Thu, 04 Dec 2008 14:19:31 +0100 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <4936B534.5070503@chamonix.reportlab.co.uk> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> Message-ID: <4937D8E3.9030501@gmail.com> > _WSC=u''.join(( > u'\u0009', # HORIZONTAL TABULATION > u'\u000A', # LINE FEED > u'\u000B', # VERTICAL TABULATION > u'\u000C', # FORM FEED > u'\u000D', # CARRIAGE RETURN > u'\u001C', # FILE SEPARATOR > u'\u001D', # GROUP SEPARATOR > u'\u001E', # RECORD SEPARATOR > u'\u001F', # UNIT SEPARATOR > u'\u0020', # SPACE > u'\u0085', # NEXT LINE > #u'\u00A0', # NO-BREAK SPACE > u'\u1680', # OGHAM SPACE MARK > u'\u2000', # EN QUAD > u'\u2001', # EM QUAD > u'\u2002', # EN SPACE > u'\u2003', # EM SPACE > u'\u2004', # THREE-PER-EM SPACE > u'\u2005', # FOUR-PER-EM SPACE > u'\u2006', # SIX-PER-EM SPACE > u'\u2007', # FIGURE SPACE > u'\u2008', # PUNCTUATION SPACE > u'\u2009', # THIN SPACE > u'\u200A', # HAIR SPACE > u'\u200B', # ZERO WIDTH SPACE > u'\u2028', # LINE SEPARATOR > u'\u2029', # PARAGRAPH SEPARATOR > u'\u202F', # NARROW NO-BREAK SPACE > u'\u205F', # MEDIUM MATHEMATICAL SPACE > u'\u3000', # IDEOGRAPHIC SPACE > )) > > #on UTF8 branch, split and strip must be unicode-safe! > def split(text, delim=None): > if type(text) is str: text = text.decode('utf8') > if type(delim) is str: delim = delim.decode('utf8') > if delim is None and u'\xa0' in text: > delim = _WSC > return [uword.encode('utf8') for uword in text.split(delim)] > > > > can you check this against your problem cases? I don't think the last line will work like this. I think it should be more like this: -----------------8<---------------[cut here] import re _WSC_RE = re.compile(u"[%s]" % re.escape(_WSC)) def split(text, delim=None): if type(text) is str: text = text.decode('utf8') if type(delim) is str: delim = delim.decode('utf8') if delim is None and u'\xa0' in text: return [uword.encode('utf8') for uword in re.split(_WSC_RE, text)] return [uword.encode('utf8') for uword in text.split(delim)] -----------------8<---------------[cut here] This one worked fine in my version. Dirk From robin at reportlab.com Thu Dec 4 09:31:54 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 04 Dec 2008 14:31:54 +0000 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <4937D8E3.9030501@gmail.com> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> Message-ID: <4937E9DA.6060105@chamonix.reportlab.co.uk> Dirk Holtwick wrote: >> _WSC=u''.join(( >> u'\u0009', # HORIZONTAL TABULATION >> u'\u000A', # LINE FEED >> u'\u000B', # VERTICAL TABULATION >> u'\u000C', # FORM FEED >> u'\u000D', # CARRIAGE RETURN >> u'\u001C', # FILE SEPARATOR >> u'\u001D', # GROUP SEPARATOR >> u'\u001E', # RECORD SEPARATOR >> u'\u001F', # UNIT SEPARATOR >> u'\u0020', # SPACE >> u'\u0085', # NEXT LINE >> #u'\u00A0', # NO-BREAK SPACE >> u'\u1680', # OGHAM SPACE MARK >> u'\u2000', # EN QUAD >> u'\u2001', # EM QUAD >> u'\u2002', # EN SPACE >> u'\u2003', # EM SPACE >> u'\u2004', # THREE-PER-EM SPACE >> u'\u2005', # FOUR-PER-EM SPACE >> u'\u2006', # SIX-PER-EM SPACE >> u'\u2007', # FIGURE SPACE >> u'\u2008', # PUNCTUATION SPACE >> u'\u2009', # THIN SPACE >> u'\u200A', # HAIR SPACE >> u'\u200B', # ZERO WIDTH SPACE >> u'\u2028', # LINE SEPARATOR >> u'\u2029', # PARAGRAPH SEPARATOR >> u'\u202F', # NARROW NO-BREAK SPACE >> u'\u205F', # MEDIUM MATHEMATICAL SPACE >> u'\u3000', # IDEOGRAPHIC SPACE >> )) >> >> #on UTF8 branch, split and strip must be unicode-safe! >> def split(text, delim=None): >> if type(text) is str: text = text.decode('utf8') >> if type(delim) is str: delim = delim.decode('utf8') >> if delim is None and u'\xa0' in text: >> delim = _WSC >> return [uword.encode('utf8') for uword in text.split(delim)] >> >> >> >> can you check this against your problem cases? > > I don't think the last line will work like this. I think it should be > more like this: > > -----------------8<---------------[cut here] > import re > _WSC_RE = re.compile(u"[%s]" % re.escape(_WSC)) > > def split(text, delim=None): > if type(text) is str: text = text.decode('utf8') > if type(delim) is str: delim = delim.decode('utf8') > if delim is None and u'\xa0' in text: > return [uword.encode('utf8') for uword in re.split(_WSC_RE, text)] > return [uword.encode('utf8') for uword in text.split(delim)] > -----------------8<---------------[cut here] > > This one worked fine in my version. > > Dirk you're absolutely right. I keep thinking delim is a set of chars, but it's a string. If the above works for you I guess it'll be fine. Perhaps we could code it a bit more efficiently by using _WSC_RE.split(text) instead of re.split(_WSC_RE, text) or for the hyper speeders _WSC_RE_split = re.compile(u"[%s]" % re.escape(_WSC)).split ....... return [uword.encode('utf8') for uword in _WSC_RE_split(text)] In fact I notice that \s doesn't match \xa0, but I am uncertain if that is intended or accidental. -- Robin Becker From dirk.holtwick at gmail.com Thu Dec 4 09:46:05 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Thu, 04 Dec 2008 15:46:05 +0100 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <4937E9DA.6060105@chamonix.reportlab.co.uk> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> Message-ID: <4937ED2D.20702@gmail.com> > you're absolutely right. I keep thinking delim is a set of chars, but > it's a string. If the above works for you I guess it'll be fine. Perhaps > we could code it a bit more efficiently by using _WSC_RE.split(text) > instead of re.split(_WSC_RE, text) or for the hyper speeders Of course :) > _WSC_RE_split = re.compile(u"[%s]" % re.escape(_WSC)).split > ....... > return [uword.encode('utf8') for uword in _WSC_RE_split(text)] > > > In fact I notice that \s doesn't match \xa0, but I am uncertain if that > is intended or accidental. It depends on the settings, see Python Manual: -----------------8<---------------[cut here] \s When the LOCALE and UNICODE flags are not specified, matches any whitespace character; this is equivalent to the set [ \t\n\r\f\v]. With LOCALE, it will match this set plus whatever characters are defined as space for the current locale. If UNICODE is set, this will match the characters [ \t\n\r\f\v] plus whatever is classified as space in the Unicode character properties database. -----------------8<---------------[cut here] I think to have an explicit rule set as in out code avoids a lot of trouble, since in unicode it is defined as a space as you already mentioned: -----------------8<---------------[cut here] >>> u"\x0a".isspace() True -----------------8<---------------[cut here] Dirk From jason at brucetek.net Thu Dec 4 09:44:45 2008 From: jason at brucetek.net (Jason Galyon) Date: Thu, 04 Dec 2008 08:44:45 -0600 Subject: [reportlab-users] message posting not working for my account? Message-ID: <4937ECDD.6090100@brucetek.net> I receive emails but can't send to the list (or they are just not posting). If we all receive this, please excuse me for the spam. From dirk.holtwick at gmail.com Thu Dec 4 09:51:53 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Thu, 04 Dec 2008 15:51:53 +0100 Subject: [reportlab-users] Python 3000 Message-ID: <4937EE89.4090606@gmail.com> Hi, Python 3000 is out! This leads directly to the question what Reportlab planning about supporting this new major release of Python which is incompatible with Python 2.x? I tried to translate the TRUNK using the new "2to3" tool and the process worked fine without errors. But the a sample I tried did not work because of some errors regarding type checking. I could imagine that this could be quite a big task to get Reportlab compatible with Python3k though. Another problem could be that the PIL modules do not support Python3k yet too. So what are you planning? And what would be the roadmap and the milestones and when to expect them? Did someone already try to migrate and has experiences with this? Cheers, Dirk From gherman at darwin.in-berlin.de Thu Dec 4 09:50:15 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 4 Dec 2008 15:50:15 +0100 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <4937E9DA.6060105@chamonix.reportlab.co.uk> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> Message-ID: <218E3A96-5270-4B16-A6A8-653190402C3A@darwin.in-berlin.de> BTW, I cannot remember having seen (and in fact, cannot find) a section listing/explaining all supported XML entities in the RL docs... If there is, please somebody point me to it! Thanks, Dinu From jason at brucetek.net Thu Dec 4 09:51:25 2008 From: jason at brucetek.net (Jason Galyon) Date: Thu, 04 Dec 2008 08:51:25 -0600 Subject: [reportlab-users] [Fwd: linechart data point labels -- how to display only some and how to overwrite values] Message-ID: <4937EE6D.2020907@brucetek.net> This didn't go through the first time. -- Jason Galyon BruceTek Ranorex US Representative 2691 Nova Park Ct Rockwall, TX 75087 USA email (preferred): jasong at brucetek.net Tel: (+1) 214-774-2669 -------------- next part -------------- An embedded message was scrubbed... From: Jason Galyon Subject: linechart data point labels -- how to display only some and how to overwrite values Date: Tue, 02 Dec 2008 11:03:47 -0600 Size: 1624 Url: From robin at reportlab.com Thu Dec 4 10:02:12 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 04 Dec 2008 15:02:12 +0000 Subject: [reportlab-users] message posting not working for my account? In-Reply-To: <4937ECDD.6090100@brucetek.net> References: <4937ECDD.6090100@brucetek.net> Message-ID: <4937F0F4.5000701@chamonix.reportlab.co.uk> Jason Galyon wrote: > I receive emails but can't send to the list (or they are just not posting). > > If we all receive this, please excuse me for the spam. perhaps you're not getting your own emails, certainly I have that problem via gmail doing the wrong thing. -- Robin Becker From robin at reportlab.com Thu Dec 4 10:05:36 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 04 Dec 2008 15:05:36 +0000 Subject: [reportlab-users] Python 3000 In-Reply-To: <4937EE89.4090606@gmail.com> References: <4937EE89.4090606@gmail.com> Message-ID: <4937F1C0.6000109@chamonix.reportlab.co.uk> Dirk Holtwick wrote: > Hi, > > Python 3000 is out! This leads directly to the question what Reportlab > planning about supporting this new major release of Python which is > incompatible with Python 2.x? > > I tried to translate the TRUNK using the new "2to3" tool and the process > worked fine without errors. But the a sample I tried did not work > because of some errors regarding type checking. I could imagine that > this could be quite a big task to get Reportlab compatible with Python3k > though. Another problem could be that the PIL modules do not support > Python3k yet too. > > So what are you planning? And what would be the roadmap and the > milestones and when to expect them? Did someone already try to migrate > and has experiences with this? ....... There is a branch devoted to this issue, but currently it hasn't been touched for a while and when last I tried I still couldn't get the simplest of pdf documents out. It is a major bind that the base type which we use to output pdf is changed. This wouldn't have broken so much if utf8 had been used instead of unicode, but the plan9's of mice and men gang aft astray as some do opine. -- Robin Becker From jason at brucetek.net Thu Dec 4 10:34:36 2008 From: jason at brucetek.net (Jason Galyon) Date: Thu, 04 Dec 2008 09:34:36 -0600 Subject: [reportlab-users] message posting not working for my account? In-Reply-To: <4937F0F4.5000701@chamonix.reportlab.co.uk> References: <4937ECDD.6090100@brucetek.net> <4937F0F4.5000701@chamonix.reportlab.co.uk> Message-ID: <4937F88C.5080603@brucetek.net> Robin Becker wrote: > Jason Galyon wrote: >> I receive emails but can't send to the list (or they are just not >> posting). >> >> If we all receive this, please excuse me for the spam. > perhaps you're not getting your own emails, certainly I have that > problem via gmail doing the wrong thing. I found out what the problem was. Since I am using an alias jasong but the real email is jason, then I have to make sure the mailserv sees it coming from the right account. I didn't think that would be a problem, but perhaps this can help anyone else using an alias. -- Jason Galyon BruceTek Ranorex US Representative 2691 Nova Park Ct Rockwall, TX 75087 USA email (preferred): jasong at brucetek.net Tel: (+1) 214-774-2669 From robin at reportlab.com Thu Dec 4 12:13:36 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 04 Dec 2008 17:13:36 +0000 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <218E3A96-5270-4B16-A6A8-653190402C3A@darwin.in-berlin.de> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> <218E3A96-5270-4B16-A6A8-653190402C3A@darwin.in-berlin.de> Message-ID: <49380FC0.5060501@chamonix.reportlab.co.uk> Dinu Gherman wrote: > BTW, I cannot remember having seen (and in fact, cannot find) > a section listing/explaining all supported XML entities in the > RL docs... If there is, please somebody point me to it! > > Thanks, > > Dinu ....... so far as I know the dict, greeks, in the source of paraparser is the only official place. That is there mainly to support the adobe character sets. Nothing prevents anyone from inserting their own entries into that dict. -- Robin Becker From robin at reportlab.com Thu Dec 4 12:54:25 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 04 Dec 2008 17:54:25 +0000 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <4937ED2D.20702@gmail.com> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> <4937ED2D.20702@gmail.com> Message-ID: <49381951.4020404@chamonix.reportlab.co.uk> Dirk Holtwick wrote: >> you're absolutely right. I keep thinking delim is a set of chars, but >> it's a string. If the above works for you I guess it'll be fine. >> Perhaps we could code it a bit more efficiently by using >> _WSC_RE.split(text) instead of re.split(_WSC_RE, text) or for the >> hyper speeders > > Of course :) > >> _WSC_RE_split = re.compile(u"[%s]" % re.escape(_WSC)).split >> ....... >> return [uword.encode('utf8') for uword in _WSC_RE_split(text)] >> >> >> In fact I notice that \s doesn't match \xa0, but I am uncertain if >> that is intended or accidental. > ........ yes thanks everyone has now told me :) With your original version I found some slight issues related to multiple space chars resulting in null elements. Can you try this version for size? It basically just adds a + after the charset in the re so that u'a\x\a0b\n\n\nc' splits in 2 elements not 4. _wsc_re_split=re.compile('[%s]+'% re.escape(''.join(( u'\u0009', # HORIZONTAL TABULATION u'\u000A', # LINE FEED u'\u000B', # VERTICAL TABULATION u'\u000C', # FORM FEED u'\u000D', # CARRIAGE RETURN u'\u001C', # FILE SEPARATOR u'\u001D', # GROUP SEPARATOR u'\u001E', # RECORD SEPARATOR u'\u001F', # UNIT SEPARATOR u'\u0020', # SPACE u'\u0085', # NEXT LINE #u'\u00A0', # NO-BREAK SPACE u'\u1680', # OGHAM SPACE MARK u'\u2000', # EN QUAD u'\u2001', # EM QUAD u'\u2002', # EN SPACE u'\u2003', # EM SPACE u'\u2004', # THREE-PER-EM SPACE u'\u2005', # FOUR-PER-EM SPACE u'\u2006', # SIX-PER-EM SPACE u'\u2007', # FIGURE SPACE u'\u2008', # PUNCTUATION SPACE u'\u2009', # THIN SPACE u'\u200A', # HAIR SPACE u'\u200B', # ZERO WIDTH SPACE u'\u2028', # LINE SEPARATOR u'\u2029', # PARAGRAPH SEPARATOR u'\u202F', # NARROW NO-BREAK SPACE u'\u205F', # MEDIUM MATHEMATICAL SPACE u'\u3000', # IDEOGRAPHIC SPACE )))).split def split(text, delim=None): if type(text) is str: text = text.decode('utf8') if type(delim) is str: delim = delim.decode('utf8') if delim is None and u'\xa0' in text: return [uword.encode('utf8') for uword in _wsc_re_split(text)] return [uword.encode('utf8') for uword in text.split(delim)] -- Robin Becker From timr at probo.com Thu Dec 4 12:54:40 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Dec 2008 09:54:40 -0800 Subject: [reportlab-users] rotate page In-Reply-To: References: Message-ID: <49381960.6070309@probo.com> giulia cherubini wrote: > > can anyone help me? > I'm trying to rotate a page because values I have to print overflow. > When i put 'can.rotate(90)' values...go outside paper and disappear. > I'm not sure to have correctly understand how to use the rotate > method, andwhere exactly put it for rotate the whole page...and see it!!! > I attach my little sample (wx_python, postgres) Sometimes I have to draw these things out on a whiteboard so that they make sense. There is a tendency to believe that rotating the canvas also moves the origin, but it does not. In the default case, the origin for a Postscript page is the lower left corner, with X increasing to the right, and Y increasing upwards: +----+ +Y | | | | ^ | | | | | +----+ 0,0 --> +X When you rotate the canvas by 90 degrees, it is rotating it AROUND that origin. So, after a 90 degree rotation, the origin is at the lower right of the page, but it's still set up so that X increases to the right and Y increases upwards. That means that your entire canvas now needs to use negative X coordinates: +---------+ +Y | | | | +---------+ -X <-- 0,0 --> +X So, to get things back to the same condition you had before, you need to move the origin pagewidth units to the left, using canvas.transform, but remember that the new page width is what USED to be the page height! canv.rotate( 90 ) canv.transform( -pagewidth[1], 0 ) (It is possible that I rotated this 90 degrees in the wrong direction, but the same principles apply.) If you just need landscape, the easiest thing is to change the page size: from reportlab.lib.pagesizes import LETTER, landscape canv = canvas.Canvas( 'xxxx.pdf', pagesize = landscape(LETTER) ) This is cheating a little bit, because it doesn't actually change the orientation of the page, but most people run the Acrobat reader with "auto-rotate and center" set, which will automatically set the printer to landscape for printing. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From andy at reportlab.com Thu Dec 4 13:01:36 2008 From: andy at reportlab.com (Andy Robinson) Date: Thu, 4 Dec 2008 18:01:36 +0000 Subject: [reportlab-users] Python 3000 In-Reply-To: <4937EE89.4090606@gmail.com> References: <4937EE89.4090606@gmail.com> Message-ID: <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> 2008/12/4 Dirk Holtwick : > So what are you planning? And what would be the roadmap and the milestones > and when to expect them? Did someone already try to migrate and has > experiences with this? I think the safest statement is "we will do nothing for at least 3 months". That way nobody can criticise us for getting behind ;-) Seriously, anyone wanting to work on it can have SVN access and I am sure Robin will be playing around too. But a production-quality PIL is a prerequisite. And we want to focus our limited time on deployment, docs and other stuff already requested for the next 3 months. Guido wants people to release "compatible" packages. The same code base cannot serve Python 2.3-2.6 and Python 3.0 and we also don't have the time for two major, diverging branches. So the real question is whether we do a "modest" ReportLab 3.0 with the minimum necessary changes; or (my preference) concentrate on creating the best library we can on Python 3000 without the constraints of compatibility with everything written before. It is a rare chance for a break with the past. Opinions most welcome, but my first paragraph is unlikely to change ;-) - Andy From dirk.holtwick at gmail.com Thu Dec 4 13:10:01 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Thu, 04 Dec 2008 19:10:01 +0100 Subject: [reportlab-users] Python 3000 In-Reply-To: <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> Message-ID: <49381CF9.4070509@gmail.com> Hi Andy, I can fully understand your thoughts about this. Python 3000 will need a lot of time to take over from Python 2.x and especially the need of keeping two development versions is bad news for almost all Python projects. Thanks for your clear statement. Dirk Andy Robinson schrieb: > 2008/12/4 Dirk Holtwick : >> So what are you planning? And what would be the roadmap and the milestones >> and when to expect them? Did someone already try to migrate and has >> experiences with this? > > I think the safest statement is "we will do nothing for at least 3 > months". That way nobody can criticise us for getting behind ;-) > > Seriously, anyone wanting to work on it can have SVN access and I am > sure Robin will be playing around too. But a production-quality PIL > is a prerequisite. And we want to focus our limited time on > deployment, docs and other stuff already requested for the next 3 > months. > > Guido wants people to release "compatible" packages. The same code > base cannot serve Python 2.3-2.6 and Python 3.0 and we also don't have > the time for two major, diverging branches. So the real question > is whether we do a "modest" ReportLab 3.0 with the minimum necessary > changes; or (my preference) concentrate on creating the best library > we can on Python 3000 without the constraints of compatibility with > everything written before. It is a rare chance for a break with the > past. > > Opinions most welcome, but my first paragraph is unlikely to change ;-) > > > - Andy > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From timr at probo.com Thu Dec 4 13:47:30 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 04 Dec 2008 10:47:30 -0800 Subject: [reportlab-users] Python 3000 In-Reply-To: <49381CF9.4070509@gmail.com> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <49381CF9.4070509@gmail.com> Message-ID: <493825C2.1070708@probo.com> Dirk Holtwick wrote: > > I can fully understand your thoughts about this. Python 3000 will need > a lot of time to take over from Python 2.x and especially the need of > keeping two development versions is bad news for almost all Python > projects. Yes, but this is true of any incompatible upgrade. I, for one, think the Python 2 -> 3 transition has been handled pretty well. There have been excellent documents on the Python web site for years telling people exactly how the transition was going to go, and suggesting ways to ameliorate the pain. I think it's just amazing that Python 3 was basically conceived, architected, debated, designed, developed, beta tested, and released, while in the same period of time Perl 6 has made almost no measurable progress. (Yes, I know that's not technically correct, but it's a good sound bite. So sue me. ;) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From gherman at darwin.in-berlin.de Thu Dec 4 16:56:50 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 4 Dec 2008 22:56:50 +0100 Subject: [reportlab-users] Python 3000 In-Reply-To: <4937EE89.4090606@gmail.com> References: <4937EE89.4090606@gmail.com> Message-ID: <236E6CE6-9FE2-4C80-B0A9-CDCB81BA6959@darwin.in-berlin.de> Dirk Holtwick: > I tried to translate the TRUNK using the new "2to3" tool and the > process worked fine without errors. But the a sample I tried did not > work because of some errors regarding type checking. I could imagine > that this could be quite a big task to get Reportlab compatible with > Python3k though. Another problem could be that the PIL modules do > not support Python3k yet too. I'm slightly skeptical of PIL becoming an "early adopter" of Python 3, since from looking at /F's announcements and docu- mentation he always seemed to care more about backward com- patibility with Python 1.5.2 rather than forward compatibili- ty with anything > 2.x. Regards, Dinu From alga at pov.lt Fri Dec 5 02:37:32 2008 From: alga at pov.lt (Albertas Agejevas) Date: Fri, 5 Dec 2008 09:37:32 +0200 Subject: [reportlab-users] Python 3000 In-Reply-To: <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> Message-ID: <20081205073732.GA16480@fridge.pov.lt> On Thu, Dec 04, 2008 at 06:01:36PM +0000, Andy Robinson wrote: > Guido wants people to release "compatible" packages. The same code > base cannot serve Python 2.3-2.6 and Python 3.0 and we also don't have > the time for two major, diverging branches. So the real question > is whether we do a "modest" ReportLab 3.0 with the minimum necessary > changes; or (my preference) concentrate on creating the best library > we can on Python 3000 without the constraints of compatibility with > everything written before. It is a rare chance for a break with the > past. Yay, this indeed sounds like a great opportunity to get rid of the cruft accumulated during the years. On the other hand, having one, compatible, trunk is of a great value as well. Perhaps the pre-2.6 versions can be automatically generated out of the 2.6 mainline with a script similar to 2to3 stripping the b prefixes from byte strings. Albertas From dirk.holtwick at gmail.com Fri Dec 5 04:42:22 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Fri, 05 Dec 2008 10:42:22 +0100 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <49381951.4020404@chamonix.reportlab.co.uk> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> <4937ED2D.20702@gmail.com> <49381951.4020404@chamonix.reportlab.co.uk> Message-ID: <4938F77E.5020007@gmail.com> > With your original version I found some slight issues related to > multiple space chars resulting in null elements. Can you try this > version for size? It basically just adds a + after the charset in the re > so that u'a\x\a0b\n\n\nc' splits in 2 elements not 4. I tested it and it works fine. Another suggestion is not to test for "\x0a" any more to profit from the more elaborated whitespace table for usual cases. Here is my modification: -----------------8<---------------[cut here] def split(text, delim=None): if type(text) is str: text = text.decode('utf8') if type(delim) is str: delim = delim.decode('utf8') elif delim is None: return [uword.encode('utf8') for uword in _wsc_re_split(text)] return [uword.encode('utf8') for uword in text.split(delim)] -----------------8<---------------[cut here] Dirk From robin at reportlab.com Fri Dec 5 05:27:38 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 05 Dec 2008 10:27:38 +0000 Subject: [reportlab-users] Python 3000 In-Reply-To: <20081205073732.GA16480@fridge.pov.lt> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> Message-ID: <4939021A.70405@chamonix.reportlab.co.uk> Albertas Agejevas wrote: > On Thu, Dec 04, 2008 at 06:01:36PM +0000, Andy Robinson wrote: >> Guido wants people to release "compatible" packages. The same code >> base cannot serve Python 2.3-2.6 and Python 3.0 and we also don't have >> the time for two major, diverging branches. So the real question >> is whether we do a "modest" ReportLab 3.0 with the minimum necessary >> changes; or (my preference) concentrate on creating the best library >> we can on Python 3000 without the constraints of compatibility with >> everything written before. It is a rare chance for a break with the >> past. > > Yay, this indeed sounds like a great opportunity to get rid of the > cruft accumulated during the years. On the other hand, having one, > compatible, trunk is of a great value as well. Perhaps the pre-2.6 > versions can be automatically generated out of the 2.6 mainline with a > script similar to 2to3 stripping the b prefixes from byte strings. > > Albertas ........ The main problem I found during my early efforts was that we have fairly optimised code for writing out the actual PDF. Unfortunately that code makes lots of assumptions about the various strings that come from the canvas which are broken by having those strings in unicode form. Effectively we need to convert everything to bytes for output and there are a lot of places where it's not obvious what encoding is intended. I think we need a rewrite of the stuff in pdfbase. -- Robin Becker From gherman at darwin.in-berlin.de Fri Dec 5 05:55:04 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Fri, 5 Dec 2008 11:55:04 +0100 Subject: [reportlab-users] Python 3000 In-Reply-To: <4939021A.70405@chamonix.reportlab.co.uk> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> <4939021A.70405@chamonix.reportlab.co.uk> Message-ID: Robin Becker: > The main problem I found during my early efforts was that we have > fairly optimised code for writing out the actual PDF. Unfortunately > that code makes lots of assumptions about the various strings that > come from the canvas which are broken by having those strings in > unicode form. Effectively we need to convert everything to bytes for > output and there are a lot of places where it's not obvious what > encoding is intended. I think we need a rewrite of the stuff in > pdfbase. Maybe there is something to learn from pyPdf which already has an alpha version for Python 3.0? (To be honest, I haven't tested it yet, but I've just added that to my todo list) http://mathieu.fenniak.net/python-30a1-support-in-pypdf-and-pg8000/ The website seems to be pretty slow, though... Regards, Dinu From robin at reportlab.com Fri Dec 5 06:07:31 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 05 Dec 2008 11:07:31 +0000 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <4938F77E.5020007@gmail.com> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> <4937ED2D.20702@gmail.com> <49381951.4020404@chamonix.reportlab.co.uk> <4938F77E.5020007@gmail.com> Message-ID: <49390B73.60604@chamonix.reportlab.co.uk> Dirk Holtwick wrote: ........... > > I tested it and it works fine. Another suggestion is not to test for > "\x0a" any more to profit from the more elaborated whitespace table for > usual cases. Here is my modification: > > -----------------8<---------------[cut here] > def split(text, delim=None): > if type(text) is str: > text = text.decode('utf8') > if type(delim) is str: > delim = delim.decode('utf8') > elif delim is None: > return [uword.encode('utf8') for uword in _wsc_re_split(text)] > return [uword.encode('utf8') for uword in text.split(delim)] > -----------------8<---------------[cut here] > > Dirk ......... unfortunately that version suffers in speed for the common case when no \xa0 is present. Below are my timings for my split and Dirk's (which I called _plit so the names are the same length in case that altered the timing somehow). common case no nbsp > C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from reportlab.platypus.paragraph import split" "split(u'The > difference in default timer function is because on Windows, clock() has microsecond granularity but time()\'s granulari > ty is 1/60th of a second; on Unix, clock() has 1/100th of a second granularity and time() is much more precise. On eith > er platform, the default timer functions measure wall clock time, not the CPU time. This means that other processes run > ning on the same computer may interfere with the timing. The best thing to do when accurate timing is necessary is to r > epeat the timing a few times and use the best time. The -r option is good for this; the default of 3 repetitions is pro > bably enough in most cases. On Unix, you can use clock() to measure CPU time.')" > 10000 loops, best of 3: 173 usec per loop > > C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from reportlab.platypus.paragraph import _plit" "_plit(u'The > difference in default timer function is because on Windows, clock() has microsecond granularity but time()\'s granulari > ty is 1/60th of a second; on Unix, clock() has 1/100th of a second granularity and time() is much more precise. On eith > er platform, the default timer functions measure wall clock time, not the CPU time. This means that other processes run > ning on the same computer may interfere with the timing. The best thing to do when accurate timing is necessary is to r > epeat the timing a few times and use the best time. The -r option is good for this; the default of 3 repetitions is pro > bably enough in most cases. On Unix, you can use clock() to measure CPU time.')" > 1000 loops, best of 3: 233 usec per loop > less common, one nbsp both take about the same time. Dirk's time is faster presumably because the one nbsp reduces the number of matches. > C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from reportlab.platypus.paragraph import split" "split(u'The > difference in default timer function is because on Windows, clock() has microsecond granularity but\xa0time()\'s granul > arity is 1/60th of a second; on Unix, clock() has 1/100th of a second granularity and time() is much more precise. On e > ither platform, the default timer functions measure wall clock time, not the CPU time. This means that other processes > running on the same computer may interfere with the timing. The best thing to do when accurate timing is necessary is t > o repeat the timing a few times and use the best time. The -r option is good for this; the default of 3 repetitions is > probably enough in most cases. On Unix, you can use clock() to measure CPU time.')" > 1000 loops, best of 3: 230 usec per loop > > C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from reportlab.platypus.paragraph import _plit" "_plit(u'The > difference in default timer function is because on Windows, clock() has microsecond granularity but\xa0time()\'s granul > arity is 1/60th of a second; on Unix, clock() has 1/100th of a second granularity and time() is much more precise. On e > ither platform, the default timer functions measure wall clock time, not the CPU time. This means that other processes > running on the same computer may interfere with the timing. The best thing to do when accurate timing is necessary is t > o repeat the timing a few times and use the best time. The -r option is good for this; the default of 3 repetitions is > probably enough in most cases. On Unix, you can use clock() to measure CPU time.')" > 1000 loops, best of 3: 230 usec per loop so I guess we should stick with the test unless there's a compelling reason for removing it. Are you suggesting that our table is more comprehensive than the unicode default argument set? I got it from the C code that implements the unicodectype so I hope it is the same for unicode.split. -- Robin Becker From dirk.holtwick at gmail.com Fri Dec 5 06:17:45 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Fri, 05 Dec 2008 12:17:45 +0100 Subject: [reportlab-users] BUGFIX: Re:   in paragraph In-Reply-To: <49390B73.60604@chamonix.reportlab.co.uk> References: <48E778F6.3010601@gmail.com> <956003ae0810060450m39d20d74pb6e15b9e92e97ff3@mail.gmail.com> <492D8A36.3070302@gmail.com> <4936B534.5070503@chamonix.reportlab.co.uk> <4937D8E3.9030501@gmail.com> <4937E9DA.6060105@chamonix.reportlab.co.uk> <4937ED2D.20702@gmail.com> <49381951.4020404@chamonix.reportlab.co.uk> <4938F77E.5020007@gmail.com> <49390B73.60604@chamonix.reportlab.co.uk> Message-ID: <49390DD9.2040600@gmail.com> Hi Robin, I did not think about speed ;) You are absolutely right that we should just handle the special case regarding u"\xa0" with our own whitespace table. > Are you suggesting that our table is more comprehensive than the unicode > default argument set? I got it from the C code that implements the > unicodectype so I hope it is the same for unicode.split. I don't know, I just trusted your data ;) Another thing I would suggest is to rename the functions "split" and "strip" to something like "split_" or "customSplit" to avoid confusion with the functions from the "string" module. Cheers Dirk Robin Becker schrieb: > Dirk Holtwick wrote: > ........... >> >> I tested it and it works fine. Another suggestion is not to test for >> "\x0a" any more to profit from the more elaborated whitespace table >> for usual cases. Here is my modification: >> >> -----------------8<---------------[cut here] >> def split(text, delim=None): >> if type(text) is str: >> text = text.decode('utf8') >> if type(delim) is str: >> delim = delim.decode('utf8') >> elif delim is None: >> return [uword.encode('utf8') for uword in _wsc_re_split(text)] >> return [uword.encode('utf8') for uword in text.split(delim)] >> -----------------8<---------------[cut here] >> >> Dirk > ......... > > unfortunately that version suffers in speed for the common case when no > \xa0 is present. Below are my timings for my split and Dirk's (which I > called _plit so the names are the same length in case that altered the > timing somehow). > > common case no nbsp >> C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from >> reportlab.platypus.paragraph import split" "split(u'The >> difference in default timer function is because on Windows, clock() >> has microsecond granularity but time()\'s granulari >> ty is 1/60th of a second; on Unix, clock() has 1/100th of a second >> granularity and time() is much more precise. On eith >> er platform, the default timer functions measure wall clock time, not >> the CPU time. This means that other processes run >> ning on the same computer may interfere with the timing. The best >> thing to do when accurate timing is necessary is to r >> epeat the timing a few times and use the best time. The -r option is >> good for this; the default of 3 repetitions is pro >> bably enough in most cases. On Unix, you can use clock() to measure >> CPU time.')" >> 10000 loops, best of 3: 173 usec per loop >> >> C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from >> reportlab.platypus.paragraph import _plit" "_plit(u'The >> difference in default timer function is because on Windows, clock() >> has microsecond granularity but time()\'s granulari >> ty is 1/60th of a second; on Unix, clock() has 1/100th of a second >> granularity and time() is much more precise. On eith >> er platform, the default timer functions measure wall clock time, not >> the CPU time. This means that other processes run >> ning on the same computer may interfere with the timing. The best >> thing to do when accurate timing is necessary is to r >> epeat the timing a few times and use the best time. The -r option is >> good for this; the default of 3 repetitions is pro >> bably enough in most cases. On Unix, you can use clock() to measure >> CPU time.')" >> 1000 loops, best of 3: 233 usec per loop >> > > less common, one nbsp both take about the same time. Dirk's time is > faster presumably because the one nbsp reduces the number of matches. > >> C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from >> reportlab.platypus.paragraph import split" "split(u'The >> difference in default timer function is because on Windows, clock() >> has microsecond granularity but\xa0time()\'s granul >> arity is 1/60th of a second; on Unix, clock() has 1/100th of a second >> granularity and time() is much more precise. On e >> ither platform, the default timer functions measure wall clock time, >> not the CPU time. This means that other processes >> running on the same computer may interfere with the timing. The best >> thing to do when accurate timing is necessary is t >> o repeat the timing a few times and use the best time. The -r option >> is good for this; the default of 3 repetitions is >> probably enough in most cases. On Unix, you can use clock() to >> measure CPU time.')" >> 1000 loops, best of 3: 230 usec per loop >> >> C:\code\reportlab\platypus>python \python\lib\timeit.py -s "from >> reportlab.platypus.paragraph import _plit" "_plit(u'The >> difference in default timer function is because on Windows, clock() >> has microsecond granularity but\xa0time()\'s granul >> arity is 1/60th of a second; on Unix, clock() has 1/100th of a second >> granularity and time() is much more precise. On e >> ither platform, the default timer functions measure wall clock time, >> not the CPU time. This means that other processes >> running on the same computer may interfere with the timing. The best >> thing to do when accurate timing is necessary is t >> o repeat the timing a few times and use the best time. The -r option >> is good for this; the default of 3 repetitions is >> probably enough in most cases. On Unix, you can use clock() to >> measure CPU time.')" >> 1000 loops, best of 3: 230 usec per loop > > so I guess we should stick with the test unless there's a compelling > reason for removing it. > > Are you suggesting that our table is more comprehensive than the unicode > default argument set? I got it from the C code that implements the > unicodectype so I hope it is the same for unicode.split. From andy at reportlab.com Fri Dec 5 06:19:21 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 5 Dec 2008 11:19:21 +0000 Subject: [reportlab-users] Python 3000 In-Reply-To: <4939021A.70405@chamonix.reportlab.co.uk> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> <4939021A.70405@chamonix.reportlab.co.uk> Message-ID: <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> I've been pondering this more. I see 3 possible "branches"... (a) the present codebase running on 2.3 to 2.6. But we aim to remove dead code and examples, document and package a bit better, and make APIs a bit more explicit, so it's clearer what needs porting. (b) a Python 3.0 port which aims to present the same behaviour (and thus the same undocumented mishmash of APIs as we have now), but needing some significant internal rewrites to achieve it (c) a Python 3.0 port which aims to deprecate any stuff we don't need, properly take advantage of the clear distinction between natural-language text and byte-arrays, restructure anything we want to, and maybe catch up a bit with recent PDF specs. This would probably start off by porting just the lowest layers (pdfgen/pdfdoc) and we could try to build it up cleanly with good docco and test coverage as we go, in no rush. Does anyone here think (b) is worth pursuing to production quality, given that we have limited resources, and time spent on it would cut into time spent on (c)? -- Andy From paul.barrass at safeonlinebilling.com Fri Dec 5 06:35:16 2008 From: paul.barrass at safeonlinebilling.com (Paul Barrass) Date: Fri, 05 Dec 2008 11:35:16 +0000 Subject: [reportlab-users] Python 3000 In-Reply-To: <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> <4939021A.70405@chamonix.reportlab.co.uk> <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> Message-ID: <493911F4.8000305@safeonlinebilling.com> Andy Robinson wrote: > > (a) the present codebase running on 2.3 to 2.6. > (b) a Python 3.0 port which aims to present the same behaviour > (c) a Python 3.0 port which aims to deprecate any stuff we don't need [...] in no rush. > > Does anyone here think (b) is worth pursuing to production quality, > given that we have limited resources, and time spent on it would cut > into time spent on (c) For my usage (on an existing project), which I'd think was fairly typical, I'd have thought that any of your time spent working on the (b) option at the expense of the (c) option would be wasted. I'd have thought that, with the backwards-incompatibility of Python itself, it would be better moving from Python 2.x/RL 2.x to Python 3.x/RL 3.x than 2/2 -> 3/2 -> 3/3. Of course, any new projects starting using Python 3.0 would be stuck, unable to use RL3, and there existing no RL2 - so I guess it depends on how long until RL3 is production ready, and how soon the early adopters will want it. I haven't looked at porting my own code yet, so I'm not really in a position to comment on how much work is involved, so my above comments are based on your earlier comments in the list. Paul Barrass. From wilk at flibuste.net Fri Dec 5 07:41:35 2008 From: wilk at flibuste.net (William Dode) Date: Fri, 5 Dec 2008 12:41:35 +0000 (UTC) Subject: [reportlab-users] Python 3000 References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> <4939021A.70405@chamonix.reportlab.co.uk> <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> <493911F4.8000305@safeonlinebilling.com> Message-ID: On 05-12-2008, Paul Barrass wrote: > Andy Robinson wrote: >> >> (a) the present codebase running on 2.3 to 2.6. >> (b) a Python 3.0 port which aims to present the same behaviour >> (c) a Python 3.0 port which aims to deprecate any stuff we don't need [...] in no rush. >> >> Does anyone here think (b) is worth pursuing to production quality, >> given that we have limited resources, and time spent on it would cut >> into time spent on (c) > > For my usage (on an existing project), which I'd think was fairly > typical, I'd have thought that any of your time spent working on the (b) > option at the expense of the (c) option would be wasted. I'd have > thought that, with the backwards-incompatibility of Python itself, it > would be better moving from Python 2.x/RL 2.x to Python 3.x/RL 3.x than > 2/2 -> 3/2 -> 3/3. > > Of course, any new projects starting using Python 3.0 would be stuck, > unable to use RL3, and there existing no RL2 - so I guess it depends on > how long until RL3 is production ready, and how soon the early adopters > will want it. > > I haven't looked at porting my own code yet, so I'm not really in a > position to comment on how much work is involved, so my above comments > are based on your earlier comments in the list. Same for me (b) could be interresting only to help to do (c), but it doesn't seems to be. -- William Dod? - http://flibuste.net Informaticien Ind?pendant From robin at reportlab.com Fri Dec 5 09:11:32 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 05 Dec 2008 14:11:32 +0000 Subject: [reportlab-users] Python 3000 In-Reply-To: References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> <4939021A.70405@chamonix.reportlab.co.uk> <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> <493911F4.8000305@safeonlinebilling.com> Message-ID: <49393694.7020409@chamonix.reportlab.co.uk> William Dode wrote: > On 05-12-2008, Paul Barrass wrote: >> Andy Robinson wrote: >>> >>> (a) the present codebase running on 2.3 to 2.6. >>> (b) a Python 3.0 port which aims to present the same behaviour >>> (c) a Python 3.0 port which aims to deprecate any stuff we don't need [...] in no rush. >>> >>> Does anyone here think (b) is worth pursuing to production quality, >>> given that we have limited resources, and time spent on it would cut >>> into time spent on (c) >> For my usage (on an existing project), which I'd think was fairly >> typical, I'd have thought that any of your time spent working on the (b) >> option at the expense of the (c) option would be wasted. I'd have >> thought that, with the backwards-incompatibility of Python itself, it >> would be better moving from Python 2.x/RL 2.x to Python 3.x/RL 3.x than >> 2/2 -> 3/2 -> 3/3. >> >> Of course, any new projects starting using Python 3.0 would be stuck, >> unable to use RL3, and there existing no RL2 - so I guess it depends on >> how long until RL3 is production ready, and how soon the early adopters >> will want it. >> >> I haven't looked at porting my own code yet, so I'm not really in a >> position to comment on how much work is involved, so my above comments >> are based on your earlier comments in the list. > > Same for me > > (b) could be interresting only to help to do (c), but it doesn't seems > to be. > I think we should aim at b first since the main problem is in the back end which both b and c will need. I'm fairly sure the main problems in the front ends eg platypus, canvas are easy. At the point where we have a mainly compatible working front end a decision can be made as to which features should be killed, added re-arranged etc etc. -- Robin Becker From helmrp at yahoo.com Fri Dec 5 11:00:54 2008 From: helmrp at yahoo.com (The Helmbolds) Date: Fri, 5 Dec 2008 08:00:54 -0800 (PST) Subject: [reportlab-users] Python 3000 and 3 possible 'branches' Message-ID: <554177.73432.qm@web31805.mail.mud.yahoo.com> IMHO half measures utlimately are more trouble and effort than going full-bore to the goal. So I?think your option (b) is significantly less desirable than either of the others. In fact, I favor your option (c) -- even if I have to stick with Python 2.x for a while longer. Message: 6 Date: Fri, 5 Dec 2008 11:19:21 +0000 From: "Andy Robinson" Subject: Re: [reportlab-users] Python 3000 To: "Support list for users of Reportlab software" ??? Message-ID: ??? <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0 at mail.gmail.com> Content-Type: text/plain; charset=UTF-8 I've been pondering this more.? I see 3 possible "branches"... (a) the present codebase running on 2.3 to 2.6.? But we aim to remove dead code and examples, document and package a bit better, and make APIs a bit more explicit, so it's clearer what needs porting. (b) a Python 3.0 port which aims to present the same behaviour (and thus the same undocumented mishmash of APIs as we have now), but needing some significant internal rewrites to achieve it (c) a Python 3.0 port which aims to deprecate any stuff we don't need, properly take advantage of the clear distinction between natural-language text and byte-arrays, restructure anything we want to, and maybe catch up a bit with recent PDF specs.? ? This would probably start off by porting just the lowest layers (pdfgen/pdfdoc) and we could try to build it up cleanly with good docco and test coverage as we go, in no rush. Does anyone here think (b) is worth pursuing to production quality, given that we have limited resources, and time spent on it would cut into time spent on (c)? -- Andy ?The Helmbolds 2645 E Southern Ave A241 Tempe AZ 85282 Email: helmrp at yahoo.com VOX: 480-831-3611 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dirk.holtwick at gmail.com Fri Dec 5 11:28:46 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Fri, 05 Dec 2008 17:28:46 +0100 Subject: [reportlab-users] Python 3000 In-Reply-To: <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> References: <4937EE89.4090606@gmail.com> <956003ae0812041001h33f80a77q14bbf3c791d23344@mail.gmail.com> <20081205073732.GA16480@fridge.pov.lt> <4939021A.70405@chamonix.reportlab.co.uk> <956003ae0812050319rb4a7bf1hc4e6dbe5900d76b0@mail.gmail.com> Message-ID: <493956BE.3050107@gmail.com> Hi, I think you should consider what Guido says about porting: -----------------8<---------------[cut here] Porting To Python 3.0 For porting existing Python 2.5 or 2.6 source code to Python 3.0, the best strategy is the following: 0. (Prerequisite:) Start with excellent test coverage. 1. Port to Python 2.6. This should be no more work than the average port from Python 2.x to Python 2.(x+1). Make sure all your tests pass. 2. (Still using 2.6:) Turn on the -3 command line switch. This enables warnings about features that will be removed (or change) in 3.0. Run your test suite again, and fix code that you get warnings about until there are no warnings left, and all your tests still pass. Run the 2to3 source-to-source translator over your source code tree. (See 2to3 - Automated Python 2 to 3 code translation for more on this tool.) 3. Run the result of the translation under Python 3.0. Manually fix up any remaining issues, fixing problems until all tests pass again. It is not recommended to try to write source code that runs unchanged under both Python 2.6 and 3.0; you?d have to use a very contorted coding style, e.g. avoiding print statements, metaclasses, and much more. If you are maintaining a library that needs to support both Python 2.6 and Python 3.0, the best approach is to modify step 3 above by editing the 2.6 version of the source code and running the 2to3 translator again, rather than editing the 3.0 version of the source code. -----------------8<---------------[cut here] I think we should start to rewrite the basic parts of Reportlab using unit tests and a clean API with documentation. In the second step the flowables and stuff should be rethought and reimplemented. I think there are a lot of ideas to optimize some central parts of Reportlab. I could contribute paragraph implementation for example. But I am afraid this will remain a dream for some time, since this would be a really big effort and it is not that urgent to do the port now :( Dirk Andy Robinson schrieb: > I've been pondering this more. I see 3 possible "branches"... > > > (a) the present codebase running on 2.3 to 2.6. But we aim to remove > dead code and examples, document and package a bit better, and make > APIs a bit more explicit, so it's clearer what needs porting. > > (b) a Python 3.0 port which aims to present the same behaviour (and > thus the same undocumented mishmash of APIs as we have now), but > needing some significant internal rewrites to achieve it > > (c) a Python 3.0 port which aims to deprecate any stuff we don't need, > properly take advantage of the clear distinction between > natural-language text and byte-arrays, restructure anything we want > to, and maybe catch up a bit with recent PDF specs. This would > probably start off by porting just the lowest layers (pdfgen/pdfdoc) > and we could try to build it up cleanly with good docco and test > coverage as we go, in no rush. > > Does anyone here think (b) is worth pursuing to production quality, > given that we have limited resources, and time spent on it would cut > into time spent on (c)? > > From knut.hansen at tromso.online.no Sun Dec 7 15:47:33 2008 From: knut.hansen at tromso.online.no (Knut Hansen) Date: Sun, 07 Dec 2008 21:47:33 +0100 Subject: [reportlab-users] TIFF-files with group 4 encoding and image-object in drawImage Message-ID: <493C3665.3080706@tromso.online.no> This is two related problems. If I try to put a TIFF-image with group 4 encoding on a reportlab canvas with drawImage(c,'MyFile.TIF',0,0) I get an argument error. It seems the image-handling routine in ReportLab cannot handle TIFF-files with group 4 encoding. Googling the problem I see I'm not alone. So first question: Is there any patch or new version of reportlab that will fix this? To try to work around this problem I have found that wx and PIL can help (I need to use PIL to modify the images anyway, so that is no overhead). According to the documentation drawImage will accept either a filename or an image object. But when I try the following code, it fails: wx_img = wx.Image('MyFile.TIF', wx.BITMAP_TYPE_TIF) pil = Image.new('RGB',(wx_img.GetWidth(), wx_img.GetHeight())) pil.fromstring(wx_img.GetData()) Canvas.drawImage(c,pil,0,0) The error message is: Traceback (most recent call last): File "tilpdf.py", line 58, in make_page(c,filer[i], i) File "tilpdf.py", line 43, in make_page z = Canvas.drawImage(c,pil,0,0) File "/usr/lib/python2.5/site-packages/reportlab/pdfgen/canvas.py", line 629,in drawImage imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask) File "/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfdoc.py", line 1842, in __init__ self.loadImageFromSRC(source) File "/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfdoc.py", line 1891, in loadImageFromSRC fp = im.jpeg_fh() File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 494, in __getattr__ raise AttributeError(name) AttributeError: jpeg_fh But if I write the PIL image to a file and read that with drawImage everything is OK. So, why doesn't drawImage accept my image object? Knut From jason at brucetek.net Mon Dec 8 12:29:08 2008 From: jason at brucetek.net (Jason Galyon) Date: Mon, 08 Dec 2008 11:29:08 -0600 Subject: [reportlab-users] selectively display data point labels on line charts Message-ID: <493D5964.7010400@brucetek.net> I have a line chart with 2 lines of data. I would like to show only the beginning two values and the end two values of each line. How do I selectively display data point values? I tried using lineLabelArray, populating None and then '' for values I didn't want displayed and the actual amount I wanted displayed. However, all values were displayed when I used lineLabelFormat. I also tried using .lines[n] but I was unsure what attributes and methods I had available to me. Also, how do I give custom values for each data point? For example, I may need to round to the nearest million with precision of thousandths and add a M on end. Is this where I would use lineLabelFormat? -- Jason Galyon BruceTek Ranorex US Representative 2691 Nova Park Ct Rockwall, TX 75087 USA email (preferred): jasong at brucetek.net Tel: (+1) 214-774-2669 From dirk.holtwick at gmail.com Mon Dec 8 12:38:40 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Mon, 08 Dec 2008 18:38:40 +0100 Subject: [reportlab-users] BUG+FIX: Paragraph splitting Message-ID: <493D5BA0.7070102@gmail.com> Hi, I found an error for paragraphs that need to split and contain inline images. After a long search I found out that the reason was that "autoLeading" was not inherited to the resulting split-paragraphs. Here is the part in Paragraph.split that needs to be modified: -----------------8<---------------[cut here] func = self._get_split_blParaFunc() P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s)) P1.blPara = ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth) P1._JustifyLast = 1 P1._splitpara = 1 P1.height = height P1.width = availWidth P1.autoLeading = self.autoLeading # <-- BUGFIX if style.firstLineIndent != 0: style = deepcopy(style) style.firstLineIndent = 0 P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n)) P2.autoLeading = self.autoLeading # <-- BUGFIX return [P1,P2] -----------------8<---------------[cut here] Dirk From gslindstrom at gmail.com Mon Dec 8 13:11:40 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Mon, 8 Dec 2008 12:11:40 -0600 Subject: [reportlab-users] Printing in Landscape Mode Message-ID: Hello, I am generating a report using reportlab 2.2 and everything is fine (Paragraphs and Tables printing fine). My problem is that I have 1 table I would like to print in landscape rather than portrait. Is that possible in a single document? If so, how? Thanks, --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From nutbeam at acrossthebigpond.com Mon Dec 8 14:04:27 2008 From: nutbeam at acrossthebigpond.com (Gary Nutbeam) Date: Mon, 08 Dec 2008 13:04:27 -0600 Subject: [reportlab-users] Reportlab 2.1 "Symbol" font problem on FC8 Message-ID: <1228763067.2917.10.camel@toad> I'm using Fedora Core 8 and Reportlab 2.1. When I try and print an Omega (unicode 0057 or Decimal 87) I get a black square. It's odd because I was trying other characters and after a question mark (U+003F) produced black squares too. I did a search and couldn't find anything about this. Also tried on a CentOS 5.1 system and had the same problem. The program I'm porting worked fine with reportlab 1.x and CentOS 4.2. I'm either missing something completely obvious, or something is broke? I've made sure the adobe fonts are in the path searched by reportlab. Thanks for any help. >From my simple test program. c.setFont("Symbol",12) c.drawString(100,100, u'\u0057') Gary. From paul.barrass at safeonlinebilling.com Mon Dec 8 14:28:18 2008 From: paul.barrass at safeonlinebilling.com (Paul Barrass) Date: Mon, 08 Dec 2008 19:28:18 +0000 Subject: [reportlab-users] Reportlab 2.1 "Symbol" font problem on FC8 In-Reply-To: <1228763067.2917.10.camel@toad> References: <1228763067.2917.10.camel@toad> Message-ID: <493D7552.5080802@safeonlinebilling.com> Gary Nutbeam wrote: > I'm using Fedora Core 8 and Reportlab 2.1. When I try and print an Omega > (unicode 0057 or Decimal 87) I get a black square. It's odd because I > > \u0057 appears to be 'W' (which is probably not present in the Symbol font), not omega - have you tried \u03A9? If that doesn't work, see http://two.pairlist.net/pipermail/reportlab-users/2008-August/007124.html Versions of RL before 2.0 didn't use Unicode, so that may explain the different behaviour. Paul Barrass From robin at reportlab.com Mon Dec 8 14:35:58 2008 From: robin at reportlab.com (Robin Becker) Date: Mon, 08 Dec 2008 19:35:58 +0000 Subject: [reportlab-users] Reportlab 2.1 "Symbol" font problem on FC8 In-Reply-To: <1228763067.2917.10.camel@toad> References: <1228763067.2917.10.camel@toad> Message-ID: <493D771E.3000803@jessikat.plus.net> Gary Nutbeam wrote: > I'm using Fedora Core 8 and Reportlab 2.1. When I try and print an Omega > (unicode 0057 or Decimal 87) I get a black square. It's odd because I > was trying other characters and after a question mark (U+003F) produced > black squares too. I did a search and couldn't find anything about this. > Also tried on a CentOS 5.1 system and had the same problem. The program > I'm porting worked fine with reportlab 1.x and CentOS 4.2. I'm either > missing something completely obvious, or something is broke? I've made > sure the adobe fonts are in the path searched by reportlab. > > Thanks for any help. > >>From my simple test program. > > c.setFont("Symbol",12) > c.drawString(100,100, u'\u0057') > > Gary. 2.1 now uses either utf8 strings or unicode -- Robin Becker From nutbeam at acrossthebigpond.com Mon Dec 8 15:11:36 2008 From: nutbeam at acrossthebigpond.com (Gary Nutbeam) Date: Mon, 08 Dec 2008 14:11:36 -0600 Subject: [reportlab-users] Reportlab 2.1 "Symbol" font problem on FC8 In-Reply-To: <493D7552.5080802@safeonlinebilling.com> References: <1228763067.2917.10.camel@toad> <493D7552.5080802@safeonlinebilling.com> Message-ID: <1228767096.2917.18.camel@toad> I have been reading my character selection program wrong (kcharselect). When I selected Symbols, and clicked on the omega it showed in the grid then, it was telling me it was 0057. If I type in 2126 manually it goes to table 33 and an omega character. I understand what I was doing wrong now. Thank you very much for clearing the blockage :-) On Mon, 2008-12-08 at 19:28 +0000, Paul Barrass wrote: > Gary Nutbeam wrote: > > I'm using Fedora Core 8 and Reportlab 2.1. When I try and print an Omega > > (unicode 0057 or Decimal 87) I get a black square. It's odd because I > > > > > \u0057 appears to be 'W' (which is probably not present in the Symbol > font), not omega - have you tried \u03A9? If that doesn't work, see > http://two.pairlist.net/pipermail/reportlab-users/2008-August/007124.html > > Versions of RL before 2.0 didn't use Unicode, so that may explain the > different behaviour. > > Paul Barrass > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From jason at brucetek.net Tue Dec 9 11:25:40 2008 From: jason at brucetek.net (Jason Galyon) Date: Tue, 09 Dec 2008 10:25:40 -0600 Subject: [reportlab-users] selectively display data point labels on line charts Message-ID: <493E9C04.1060705@brucetek.net> I have a line chart with 2 lines of data. I would like to show only the beginning two values and the end two values of each line. How do I selectively display data point values? I tried using lineLabelArray, populating None and then '' for values I didn't want displayed and the actual amount I wanted displayed. However, all values were displayed when I used lineLabelFormat. I also tried using .lines[n] but I was unsure what attributes and methods I had available to me. Also, how do I give custom values for each data point? For example, I may need to round to the nearest million with precision of thousandths and add a M on end. Is this where I would use lineLabelFormat? -- Jason Galyon BruceTek Ranorex US Representative 2691 Nova Park Ct Rockwall, TX 75087 USA email (preferred): jasong at brucetek.net Tel: (+1) 214-774-2669 From mukkablues at hotmail.it Wed Dec 10 05:37:38 2008 From: mukkablues at hotmail.it (giulia cherubini) Date: Wed, 10 Dec 2008 11:37:38 +0100 Subject: [reportlab-users] rotate page Message-ID: Well, I?m trying to rotate a table-grid, but?result is non as I exactly want to be? Now I can see a bit of table, but?it?s not enough!!! I have a little trouble understanding: --- wich kind of pagesize I have to set ---which value put onto canvas.translate ---values of inch I only rotate first page. The parameter rotate(90) is ok, I can see the end of table in the right position but?only the end!!! Thanx for your help, sorry if I?m very newbie!!! giulia _________________________________________________________________ Vai oltre le parole, scarica il nuovo Messenger! http://download.live.com/?mkt=it-it -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pdf3.py Url: -------------- next part -------------- A non-text attachment was scrubbed... Name: pdf3.pdf Type: application/pdf Size: 9019 bytes Desc: not available Url : From robin at reportlab.com Wed Dec 10 06:03:51 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 10 Dec 2008 11:03:51 +0000 Subject: [reportlab-users] rotate page In-Reply-To: References: Message-ID: <493FA217.1090107@chamonix.reportlab.co.uk> giulia cherubini wrote: > Well, > I?m trying to rotate a table-grid, but?result is non as I exactly want to be? > Now I can see a bit of table, but?it?s not enough!!! > I have a little trouble understanding: > --- wich kind of pagesize I have to set > ---which value put onto canvas.translate > ---values of inch > I only rotate first page. > The parameter rotate(90) is ok, I can see the end of table in the right position but?only the end!!! > Thanx for your help, sorry if I?m very newbie!!! > giulia ........ first off at the end of each page the graphic state is reset by adobe. That means you'll have to do the rotation in each page. It's a bit odd to use negative page width so I don't know what's happening here. Try changing the two inch,inch translations one at a time, by a small amount to determine which direction the drawn table gets moved. That should allow you to figure out what the correct adjustment should be for your set up. I cannot run your example as I don't have data/psychopg2. -- Robin Becker From mukkablues at hotmail.it Wed Dec 10 06:12:09 2008 From: mukkablues at hotmail.it (giulia cherubini) Date: Wed, 10 Dec 2008 12:12:09 +0100 Subject: [reportlab-users] rotate page In-Reply-To: <493FA217.1090107@chamonix.reportlab.co.uk> References: <493FA217.1090107@chamonix.reportlab.co.uk> Message-ID: ok! I'll try as you suggest, I'll post if I'll have some nice report, thanx a lot! giulia> Date: Wed, 10 Dec 2008 11:03:51 +0000> From: robin at reportlab.com> To: reportlab-users at reportlab.com> Subject: Re: [reportlab-users] rotate page> > giulia cherubini wrote:> > Well,> > I?m trying to rotate a table-grid, but?result is non as I exactly want to be?> > Now I can see a bit of table, but?it?s not enough!!!> > I have a little trouble understanding:> > --- wich kind of pagesize I have to set> > ---which value put onto canvas.translate> > ---values of inch> > I only rotate first page.> > The parameter rotate(90) is ok, I can see the end of table in the right position but?only the end!!!> > Thanx for your help, sorry if I?m very newbie!!!> > giulia> ........> > first off at the end of each page the graphic state is reset by adobe. That > means you'll have to do the rotation in each page.> > It's a bit odd to use negative page width so I don't know what's happening here. > Try changing the two inch,inch translations one at a time, by a small amount to > determine which direction the drawn table gets moved. That should allow you to > figure out what the correct adjustment should be for your set up.> > I cannot run your example as I don't have data/psychopg2.> -- > Robin Becker> _______________________________________________> reportlab-users mailing list> reportlab-users at reportlab.com> http://two.pairlist.net/mailman/listinfo/reportlab-users _________________________________________________________________ Ci sai fare con l'italiano? Scoprilo con Typectionary! http://typectionary.it.msn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mukkablues at hotmail.it Wed Dec 10 09:21:08 2008 From: mukkablues at hotmail.it (giulia cherubini) Date: Wed, 10 Dec 2008 15:21:08 +0100 Subject: [reportlab-users] rotate page Message-ID: now it works as I want, it's no so perfect (speak about naming convention and code) but ok for my little program, thanx to all!!! _________________________________________________________________ Ci sai fare con l'italiano? Scoprilo con Typectionary! http://typectionary.it.msn.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pdf4.py Url: -------------- next part -------------- A non-text attachment was scrubbed... Name: pdf4.pdf Type: application/pdf Size: 3201 bytes Desc: not available Url : From graeme at lutralutra.co.uk Wed Dec 10 10:05:24 2008 From: graeme at lutralutra.co.uk (Graeme Hawker) Date: Wed, 10 Dec 2008 15:05:24 -0000 (GMT) Subject: [reportlab-users] Insert image from url Message-ID: <12466.213.122.166.34.1228921524.squirrel@mail5.webfaction.com> Hi there! I am trying to insert an image from a url into a pdf. In practice, this will be a dynamically generated chart (I'm using PHP's jpgraph as this has scatterplot and windrose functionality), but I'm just trying to test it on a flat image file (in this case a google icon). I try: logo = Image(urllib2.urlopen('http://images.google.co.uk/intl/en_ALL/images/images_hp.gif')) story.append(logo) But I get the error: addinfourl instance has no attribute 'seek' fileName=> I've read somewhere a mention of passing the url contents via a StringIO object, but am unsure the details of how to do this. Can anyone assist? Thanks Graeme From jonas at reportlab.com Wed Dec 10 10:11:55 2008 From: jonas at reportlab.com (jonas wustrack) Date: Wed, 10 Dec 2008 15:11:55 +0000 Subject: [reportlab-users] Insert image from url In-Reply-To: <12466.213.122.166.34.1228921524.squirrel@mail5.webfaction.com> References: <12466.213.122.166.34.1228921524.squirrel@mail5.webfaction.com> Message-ID: Hi, This does not work because the object returned by urlopen lacks a seek method. Use a StringIO object instead: from StringIO import StringIO data = urllib2.urlopen('http://images.google.co.uk/intl/en_ALL/images/images_hp.gif').read() logo = Image(StringIO(data)) story.append(logo) I have not tested this, but it should work. -- Jonas On Wed, Dec 10, 2008 at 3:05 PM, Graeme Hawker wrote: > Hi there! > > I am trying to insert an image from a url into a pdf. In practice, this > will be a dynamically generated chart (I'm using PHP's jpgraph as this has > scatterplot and windrose functionality), but I'm just trying to test it on > a flat image file (in this case a google icon). > > I try: > > logo = > Image(urllib2.urlopen('http://images.google.co.uk/intl/en_ALL/images/images_hp.gif')) > story.append(logo) > > But I get the error: > > addinfourl instance has no attribute 'seek' fileName= 13242120 whose fp = > > > I've read somewhere a mention of passing the url contents via a StringIO > object, but am unsure the details of how to do this. Can anyone assist? > > Thanks > > Graeme > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > From graeme at lutralutra.co.uk Wed Dec 10 10:48:19 2008 From: graeme at lutralutra.co.uk (Graeme Hawker) Date: Wed, 10 Dec 2008 15:48:19 -0000 (GMT) Subject: [reportlab-users] Insert image from url In-Reply-To: References: <12466.213.122.166.34.1228921524.squirrel@mail5.webfaction.com> Message-ID: <12610.213.122.166.34.1228924099.squirrel@mail5.webfaction.com> Thanks - this works perfectly! I have also tried this on the dynamically generated images and it works there too. Cheers Graeme > Hi, > > This does not work because the object returned by urlopen lacks a seek > method. > Use a StringIO object instead: > > from StringIO import StringIO > data = > urllib2.urlopen('http://images.google.co.uk/intl/en_ALL/images/images_hp.gif').read() > logo = Image(StringIO(data)) > story.append(logo) > > I have not tested this, but it should work. > > -- > Jonas > > On Wed, Dec 10, 2008 at 3:05 PM, Graeme Hawker > wrote: >> Hi there! >> >> I am trying to insert an image from a url into a pdf. In practice, this >> will be a dynamically generated chart (I'm using PHP's jpgraph as this >> has >> scatterplot and windrose functionality), but I'm just trying to test it >> on >> a flat image file (in this case a google icon). >> >> I try: >> >> logo = >> Image(urllib2.urlopen('http://images.google.co.uk/intl/en_ALL/images/images_hp.gif')) >> story.append(logo) >> >> But I get the error: >> >> addinfourl instance has no attribute 'seek' fileName=> 13242120 whose fp = > >> >> I've read somewhere a mention of passing the url contents via a StringIO >> object, but am unsure the details of how to do this. Can anyone assist? >> >> Thanks >> >> Graeme >> _______________________________________________ >> reportlab-users mailing list >> reportlab-users at reportlab.com >> http://two.pairlist.net/mailman/listinfo/reportlab-users >> > > From gu_barthe at yahoo.fr Thu Dec 11 05:05:39 2008 From: gu_barthe at yahoo.fr (Barthe Guillaume) Date: Thu, 11 Dec 2008 10:05:39 +0000 (GMT) Subject: [reportlab-users] Create a table with data from wxpythongrid Message-ID: <987239.53285.qm@web24506.mail.ird.yahoo.com> Hello, I want to create a table. The data sources are cells from a wxgrid from wxpython. I build my table with this code : styleSheet = getSampleStyleSheet() ??? ??? ??? doc = SimpleDocTemplate(destination_file) ??? ??? ??? Story = [Spacer(1, 2*inch)] ??? ??? ??? style = styleSheet["Normal"] ??? ??? ??? Story.append(Spacer(1, 3*cm)) ??? ??? ??? data = [] ??? ??? ??? en_tete = [u'Rep?re', u'D?signations', u'T ECS [?C]', 'Nombre', u'D?bit de base [l / s]', u'D?bits ECS [l / s]', u'D?bits ECS totaux [l / s]'] ??? ??? ??? data.append(en_tete) ??? ??? ??? for i in range(nb_lignes_ecs_semi_instantanee - 1): ??? ??? ??? ??? data.append("[" + self.detail_ecs.GetCellValue(i, 0) + ", " + "\'" + self.detail_ecs.GetCellValue(i, 1) + "\'" + ", " + self.detail_ecs.GetCellValue(i, 2) + ", " + self.detail_ecs.GetCellValue(i, 3) + ", " + self.detail_ecs.GetCellValue(i, 4) + ", " + self.detail_ecs.GetCellValue(i, 5) + ", " + self.detail_ecs.GetCellValue(i, 6) + "]") t=Table(data, 7*[2*cm], nb_lignes_ecs_semi_instantanee*[0.9*cm]) ??? ??? ??? # Ajustement des colonnes une par une en fct du contenu ??? ??? ??? t._argW[0]=1.1*cm ??? ??? ??? t._argW[1]=3.8*cm ??? ??? ??? t._argW[3]=1.4*cm ??? ??? ??? t._argW[4]=3*cm ??? ??? ??? t._argW[5]=2.6*cm ??? ??? ??? t._argW[6]=3.6*cm ??? ??? ??? # Style du tableau ??? ??? ??? t.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, 0), colors.green), ('ALIGN', (0, 0), (-1, 0), 'CENTER'), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('GRID', (0, 0), (-1, -1), 0.5, colors.black), ('ALIGN',(0, 1),(0, -1),'CENTER'), ('ALIGN',(1, 1),(1, -1),'LEFT'), ('ALIGN',(2, 1),(2, -1),'RIGHT'), ('ALIGN',(3, 1),(3, -1),'RIGHT'), ('ALIGN',(4, 1),(4, -1),'RIGHT'), ('ALIGN',(5, 1),(5, -1),'RIGHT'), ('ALIGN',(6, 1),(6, -1),'RIGHT')])) ??? ??? ??? Story.append(t) ??? ??? ??? # Cr?ation du fichier ??? ??? ??? doc.build(Story, onFirstPage=self.partie_1_pdf) But this code return an error : Traceback (most recent call last): ? File "./astugeclim.py", line 537, in creer_pdf_ecs_semi_instantanee ??? t=Table(data, 7*[2*cm], nb_lignes_ecs_semi_instantanee*[0.9*cm]) ? File "/usr/lib/python2.5/site-packages/reportlab/platypus/tables.py", line 251, in __init__ ??? raise ValueError, "%s not enough data points in row %d!" % (self.identity(),i) ValueError:
with cell(0,0) containing 'Rep\xc3\xa8re' not enough data points in row 1! And I have see that the result of data is : [[u'Rep\xe8re', u'D\xe9signations', u'T ECS [\xb0C]', 'Nombre', u'D\xe9bit de base [l / s]', u'D\xe9bits ECS [l / s]', u'D\xe9bits ECS totaux [l / s]'], u"[1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14]", u"[2, 'Vidoir (0.20)', 45, 2, 0.2, 0.14, 0.28]", u"[3, 'Auge 3 postes (0.60)', 45, 3, 0.6, 0.42, 1.26]", u"[4, 'Vasque (0.20)', 45, 4, 0.2, 0.14, 0.56]", u"[5, 'Evier (0.20)', 45, 5, 0.2, 0.14, 0.7]", u"[6, 'Douche (0.20)', 45, 6, 0.2, 0.14, 0.84]", u"[7, 'Lave-mains (0.10)', 45, 7, 0.1, 0.07, 0.49]", u"[8, 'Timbre d'office (0.20)', 45, 8, 0.2, 0.14, 1.12]", u"[9, 'Lave bassin (0.30)', 45, 9, 0.3, 0.21, 1.89]", u"[10, 'Baignoire 2 (0.40)', 45, 10, 0.4, 0.28, 2.8]", u"[11, 'Baignoire 1 (0.33)', 60, 11, 0.33, 0.33, 3.63]", u"[12, 'Auge 2 postes (0.40)', 45, 12, 0.4, 0.28, 3.36]", u"[13, 'Auge 3 postes (0.60)', 60, 13, 0.6, 0.6, 7.8]", u"[14, 'Evier (0.20)', 60, 14, 0.2, 0.2, 2.8]", u"[15, '', 45, 15, 0.0, 0.0, 0.0]", u"[16, 'Gros debit (0.66)', 60, 16, 0.66, 0.66, 10.56]", u"[17, 'Lave-mains (0.10)', 45, 17, 0.1, 0.07, 1.19]", u"[18, 'Auge 2 postes (0.40)', 45, 18, 0.4, 0.28, 5.04]", u"[19, 'Vidoir (0.20)', 45, 19, 0.2, 0.14, 2.66]", u"[20, 'Vidoir (0.20)', 60, 20, 0.2, 0.2, 4.0]", u"[21, 'Lavabo (0.20)', 45, 21, 0.2, 0.14, 2.94]", u"[22, 'Lave-mains (0.10)', 45, 22, 0.1, 0.07, 1.54]", u"[23, 'Evier (0.20)', 45, 23, 0.2, 0.14, 3.22]", u"[24, 'Paillasse (0.20)', 60, 24, 0.2, 0.2, 4.8]"] And I have try with this data : data = [en_tete, [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14]] And I think that is my data format is bad but I don't see how to transform my data. Can you help me please ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at reportlab.com Thu Dec 11 05:31:12 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 11 Dec 2008 10:31:12 +0000 Subject: [reportlab-users] Create a table with data from wxpythongrid In-Reply-To: <987239.53285.qm@web24506.mail.ird.yahoo.com> References: <987239.53285.qm@web24506.mail.ird.yahoo.com> Message-ID: <4940EBF0.7080101@chamonix.reportlab.co.uk> Barthe Guillaume wrote: > Hello, > > I want to create a table. The data sources are cells from a wxgrid from wxpython. I build my table with this code : > > styleSheet = getSampleStyleSheet() > doc = SimpleDocTemplate(destination_file) > Story = [Spacer(1, 2*inch)] > style = styleSheet["Normal"] > Story.append(Spacer(1, 3*cm)) > data = [] > en_tete = [u'Rep?re', u'D?signations', u'T ECS [?C]', 'Nombre', u'D?bit de base [l / s]', u'D?bits ECS [l / s]', u'D?bits ECS totaux [l / s]'] > data.append(en_tete) > for i in range(nb_lignes_ecs_semi_instantanee - 1): > data.append("[" + self.detail_ecs.GetCellValue(i, 0) + ", " + "\'" + self.detail_ecs.GetCellValue(i, 1) + "\'" + ", " + self.detail_ecs.GetCellValue(i, 2) + ", " + self.detail_ecs.GetCellValue(i, 3) + ", " + self.detail_ecs.GetCellValue(i, 4) + ", " + self.detail_ecs.GetCellValue(i, 5) + ", " + self.detail_ecs.GetCellValue(i, 6) + "]") > t=Table(data, 7*[2*cm], nb_lignes_ecs_semi_instantanee*[0.9*cm]) > # Ajustement des colonnes une par une en fct du contenu > t._argW[0]=1.1*cm > t._argW[1]=3.8*cm > t._argW[3]=1.4*cm > t._argW[4]=3*cm > t._argW[5]=2.6*cm > t._argW[6]=3.6*cm > # Style du tableau > t.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, 0), colors.green), ('ALIGN', (0, 0), (-1, 0), 'CENTER'), ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'), ('GRID', (0, 0), (-1, -1), 0.5, colors.black), ('ALIGN',(0, 1),(0, -1),'CENTER'), ('ALIGN',(1, 1),(1, -1),'LEFT'), ('ALIGN',(2, 1),(2, -1),'RIGHT'), ('ALIGN',(3, 1),(3, -1),'RIGHT'), ('ALIGN',(4, 1),(4, -1),'RIGHT'), ('ALIGN',(5, 1),(5, -1),'RIGHT'), ('ALIGN',(6, 1),(6, -1),'RIGHT')])) > Story.append(t) > # Cr?ation du fichier > doc.build(Story, onFirstPage=self.partie_1_pdf) > > But this code return an error : > > Traceback (most recent call last): > File "./astugeclim.py", line 537, in creer_pdf_ecs_semi_instantanee > t=Table(data, 7*[2*cm], nb_lignes_ecs_semi_instantanee*[0.9*cm]) > File "/usr/lib/python2.5/site-packages/reportlab/platypus/tables.py", line 251, in __init__ > raise ValueError, "%s not enough data points in row %d!" % (self.identity(),i) > ValueError:
with cell(0,0) containing > 'Rep\xc3\xa8re' not enough data points in row 1! > > And I have see that the result of data is : > > [[u'Rep\xe8re', u'D\xe9signations', u'T ECS [\xb0C]', 'Nombre', u'D\xe9bit de base [l / s]', u'D\xe9bits ECS [l / s]', u'D\xe9bits ECS totaux [l / s]'], u"[1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14]", u"[2, 'Vidoir (0.20)', 45, 2, 0.2, 0.14, 0.28]", u"[3, 'Auge 3 postes (0.60)', 45, 3, 0.6, 0.42, 1.26]", u"[4, 'Vasque (0.20)', 45, 4, 0.2, 0.14, 0.56]", u"[5, 'Evier (0.20)', 45, 5, 0.2, 0.14, 0.7]", u"[6, 'Douche (0.20)', 45, 6, 0.2, 0.14, 0.84]", u"[7, 'Lave-mains (0.10)', 45, 7, 0.1, 0.07, 0.49]", u"[8, 'Timbre d'office (0.20)', 45, 8, 0.2, 0.14, 1.12]", u"[9, 'Lave bassin (0.30)', 45, 9, 0.3, 0.21, 1.89]", u"[10, 'Baignoire 2 (0.40)', 45, 10, 0.4, 0.28, 2.8]", u"[11, 'Baignoire 1 (0.33)', 60, 11, 0.33, 0.33, 3.63]", u"[12, 'Auge 2 postes (0.40)', 45, 12, 0.4, 0.28, 3.36]", u"[13, 'Auge 3 postes (0.60)', 60, 13, 0.6, 0.6, 7.8]", u"[14, 'Evier (0.20)', 60, 14, 0.2, 0.2, 2.8]", u"[15, '', 45, 15, 0.0, 0.0, 0.0]", u"[16, 'Gros debit (0.66)', 60, 16, > 0.66, 0.66, 10.56]", u"[17, 'Lave-mains (0.10)', 45, 17, 0.1, 0.07, 1.19]", u"[18, 'Auge 2 postes (0.40)', 45, 18, 0.4, 0.28, 5.04]", u"[19, 'Vidoir (0.20)', 45, 19, 0.2, 0.14, 2.66]", u"[20, 'Vidoir (0.20)', 60, 20, 0.2, 0.2, 4.0]", u"[21, 'Lavabo (0.20)', 45, 21, 0.2, 0.14, 2.94]", u"[22, 'Lave-mains (0.10)', 45, 22, 0.1, 0.07, 1.54]", u"[23, 'Evier (0.20)', 45, 23, 0.2, 0.14, 3.22]", u"[24, 'Paillasse (0.20)', 60, 24, 0.2, 0.2, 4.8]"] > > And I have try with this data : > > data = [en_tete, [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse > (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14], [1, 'Paillasse (0.20)', 45, 1, 0.2, 0.14, 0.14]] > > And I think that is my data format is bad but I don't see how to transform my data. > > Can you help me please ? > ...... well the first set of data is a bit confused about what is in each row. The first row contains 7 items, but the next element after that row is actually a singleton unicode. In your second attempt things look better (assuming en_tete is the same). It looks like your problem is actually with the conversion into a list of the wxgrid rows (because they are strings). A simple starting solution is to build the row list directly eg for i in range(nb_lignes_ecs_semi_instantanee - 1): row =[] for j in xrange(7): #j=0,1,....6 row.append(self.detail_ecs.GetCellValue(i, j)) data.append(row) -- Robin Becker From robin at reportlab.com Thu Dec 11 06:16:58 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 11 Dec 2008 11:16:58 +0000 Subject: [reportlab-users] BUG+FIX: Paragraph splitting In-Reply-To: <493D5BA0.7070102@gmail.com> References: <493D5BA0.7070102@gmail.com> Message-ID: <4940F6AA.2070502@chamonix.reportlab.co.uk> Dirk Holtwick wrote: > Hi, > > I found an error for paragraphs that need to split and contain inline > images. After a long search I found out that the reason was that > "autoLeading" was not inherited to the resulting split-paragraphs. > > Here is the part in Paragraph.split that needs to be modified: > > -----------------8<---------------[cut here] > func = self._get_split_blParaFunc() > P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s)) > > P1.blPara = > ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth) > P1._JustifyLast = 1 > P1._splitpara = 1 > P1.height = height > P1.width = availWidth > P1.autoLeading = self.autoLeading # <-- BUGFIX > if style.firstLineIndent != 0: > style = deepcopy(style) > style.firstLineIndent = 0 > P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n)) > P2.autoLeading = self.autoLeading # <-- BUGFIX > return [P1,P2] > -----------------8<---------------[cut here] > >....... Dirk are you setting the autoLeading directly on the Paragraph here? I know that we have allowed this for certain attributes. It's a slippery slope, but I guess since we've allowed this in the past it should go forward. Probably though since autoLeading can be on the style we ought to check for existence rather than assume that it's on the instance directly. I suggest the following patch. > P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s)) > #this is a major hack > P1.blPara = ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth) > P1._JustifyLast = 1 > P1._splitpara = 1 > P1.height = height > P1.width = availWidth > if style.firstLineIndent != 0: > style = deepcopy(style) > style.firstLineIndent = 0 > P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n)) ###################### > for a in ('autoLeading', #possible attributes that might be directly on self. > ): > if hasattr(self,a): > setattr(P1,a,getattr(self,a)) > setattr(P2,a,getattr(self,a)) ###################### > return [P1,P2] Can you see if that works for you? -- Robin Becker From dirk.holtwick at gmail.com Thu Dec 11 06:25:41 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Thu, 11 Dec 2008 12:25:41 +0100 Subject: [reportlab-users] BUG+FIX: Paragraph splitting In-Reply-To: <4940F6AA.2070502@chamonix.reportlab.co.uk> References: <493D5BA0.7070102@gmail.com> <4940F6AA.2070502@chamonix.reportlab.co.uk> Message-ID: <4940F8B5.8050705@gmail.com> Hi Robin, nice patch ;) And yes, it works fine. I applied it to my implementation too (see attachment). Cheers Dirk Robin Becker schrieb: > Dirk Holtwick wrote: >> Hi, >> >> I found an error for paragraphs that need to split and contain inline >> images. After a long search I found out that the reason was that >> "autoLeading" was not inherited to the resulting split-paragraphs. >> >> Here is the part in Paragraph.split that needs to be modified: >> >> -----------------8<---------------[cut here] >> func = self._get_split_blParaFunc() >> P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s)) >> >> P1.blPara = >> ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth) >> P1._JustifyLast = 1 >> P1._splitpara = 1 >> P1.height = height >> P1.width = availWidth >> P1.autoLeading = self.autoLeading # <-- BUGFIX >> if style.firstLineIndent != 0: >> style = deepcopy(style) >> style.firstLineIndent = 0 >> P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n)) >> P2.autoLeading = self.autoLeading # <-- BUGFIX >> return [P1,P2] >> -----------------8<---------------[cut here] >> >> ....... > Dirk are you setting the autoLeading directly on the Paragraph here? I > know that we have allowed this for certain attributes. It's a slippery > slope, but I guess since we've allowed this in the past it should go > forward. Probably though since autoLeading can be on the style we ought > to check for existence rather than assume that it's on the instance > directly. I suggest the following patch. > >> >> P1=self.__class__(None,style,bulletText=self.bulletText,frags=func(blPara,0,s)) >> >> #this is a major hack >> P1.blPara = >> ParaLines(kind=1,lines=blPara.lines[0:s],aH=availHeight,aW=availWidth) >> P1._JustifyLast = 1 >> P1._splitpara = 1 >> P1.height = height >> P1.width = availWidth >> if style.firstLineIndent != 0: >> style = deepcopy(style) >> style.firstLineIndent = 0 >> >> P2=self.__class__(None,style,bulletText=None,frags=func(blPara,s,n)) > ###################### >> for a in ('autoLeading', #possible attributes that might be >> directly on self. >> ): >> if hasattr(self,a): >> setattr(P1,a,getattr(self,a)) >> setattr(P2,a,getattr(self,a)) > ###################### >> return [P1,P2] > > Can you see if that works for you? -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: reportlab_paragraph.py Url: From fobmark at gmail.com Thu Dec 11 21:01:49 2008 From: fobmark at gmail.com (Mark Willard) Date: Thu, 11 Dec 2008 21:01:49 -0500 Subject: [reportlab-users] Can I install reportlab toolkit on shared hosting?? Message-ID: <44e9ad770812111801l3adbef7dl8cf46cb795b37422@mail.gmail.com> Hi, Since I am on shared hosting on Unix OS, i am wondering if I can put those files in my hosting space? Help!. -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.barrass at safeonlinebilling.com Fri Dec 12 05:58:24 2008 From: paul.barrass at safeonlinebilling.com (Paul Barrass) Date: Fri, 12 Dec 2008 10:58:24 +0000 Subject: [reportlab-users] Can I install reportlab toolkit on shared hosting?? In-Reply-To: <44e9ad770812111801l3adbef7dl8cf46cb795b37422@mail.gmail.com> References: <44e9ad770812111801l3adbef7dl8cf46cb795b37422@mail.gmail.com> Message-ID: <494243D0.80109@safeonlinebilling.com> Mark Willard wrote: > > Since I am on shared hosting on Unix OS, i am wondering if I can put > those files in my hosting space? Help!. Hi, Short answer is 'yes', longer answer is 'maybe'.... You should certainly be able to place the files in the shared space you have - but it might not do you much good, if the host doesn't have the right support in place, and/or your host doesn't allow you to install extra software. The best thing to do is check with your host, they may already have it installed or be willing to install it as a shared resource - if they're not, but will allow you to install it locally, you'll need to make sure they have Python and PIL installed (not sure what other dependencies there are). I assume the setup.py has options for where to install, so you can configure it to install to your ~/usr or wherever, if not - I'm fairly sure it will work if you just copy the files to somewhere Python can find them (either from the tarball or from an installed copy on your dev/local server). You may have problems with compiling _rl_accell, as I think compilers are often removed from live-on-the-web hosts as a security precaution, though again compiling locally and copying should be fine if you have a compatible compiler. Paul Barrass. From andy at reportlab.com Fri Dec 12 06:26:13 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 12 Dec 2008 11:26:13 +0000 Subject: [reportlab-users] Can I install reportlab toolkit on shared hosting?? In-Reply-To: <494243D0.80109@safeonlinebilling.com> References: <44e9ad770812111801l3adbef7dl8cf46cb795b37422@mail.gmail.com> <494243D0.80109@safeonlinebilling.com> Message-ID: <956003ae0812120326u3a32f504n3b96acf79192201e@mail.gmail.com> 2008/12/12 Paul Barrass : > You may have problems with compiling _rl_accell, as I think compilers are > often removed from live-on-the-web hosts as a security precaution, though > again compiling locally and copying should be fine if you have a compatible > compiler. Agreed. For small documents, a "pure python" installation (just unzip our archive, compile and put on the path) should work. But the real issue is whether you can compile C code, which varies from host to host. If you can't, you probably won't be able to use _rl_accel, or to use PIL and will have trouble including images (except for JPEG) in your PDFs as well. If you are using WebFaction, you'll have no problem as they give you a C compiler, allow you to install just about anything, and are all Python gurus. And if you haven't chosen a host I would highly recommend them to any Python developer. - Andy From andy at reportlab.com Fri Dec 12 13:05:32 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 12 Dec 2008 18:05:32 +0000 Subject: [reportlab-users] 2.3 release and improved code kwalitee Message-ID: <956003ae0812121005w7d8f67f4kaa2cd43fa2359cab@mail.gmail.com> Hi all, Things have got a bit quieter - maybe the economic end of the world or maybe just Christmas - and we hope to put out a version 2.3 before or after New Year. We will be trying to - close down bugs - register this one with the Cheese Shop. - remove a few more obsolete bits of code and tools - make all the docstrings restructured-text compatible (or at least warning-free) and aim to put up a tree of dosctring output on the site, to make it easier to understand the framework - make the web site a bit clearer. SVN-watchers may see a flurry of checkins over the next few days, including a bunch of docstrings updates. For anyone familiar with the concept of Code Kwalitee (google it), we will be ticking boxes in a spurious and irreverent manner over the coming days to increase our Cheesecake index as far as possible. More on Monday... -- Andy Robinson CEO/Chief Architect ReportLab Europe Ltd. Media House, 3 Palmerston Road, Wimbledon, London SW19 1PG, UK Tel +44-20-8545-1570 From gu_barthe at yahoo.fr Sat Dec 13 04:35:04 2008 From: gu_barthe at yahoo.fr (Barthe Guillaume) Date: Sat, 13 Dec 2008 09:35:04 +0000 (GMT) Subject: [reportlab-users] Patch to reportlab with python 2.6 Message-ID: <132226.75472.qm@web24502.mail.ird.yahoo.com> Hello, I use reportlab 2.2 with python 2.6 and when I launch my soft, I have an error with canvas.py file for pdfgen module. In fact this file use the md5 module witch is replace by haslib module. So to resolved the problem, I have just replace "import md5" by "import hashlib" in line 18 and this line "rawName = 'PS' + md5.md5(command).hexdigest()" by "rawName = 'PS' + hashlib.md5(command).hexdigest()" in line 739. I don't know if this correction is in the svn code but I hope that this little correction can help you. Bye. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at reportlab.com Mon Dec 15 04:38:40 2008 From: andy at reportlab.com (Andy Robinson) Date: Mon, 15 Dec 2008 09:38:40 +0000 Subject: [reportlab-users] 2.3 release and improved code kwalitee In-Reply-To: <956003ae0812121005w7d8f67f4kaa2cd43fa2359cab@mail.gmail.com> References: <956003ae0812121005w7d8f67f4kaa2cd43fa2359cab@mail.gmail.com> Message-ID: <956003ae0812150138q5b0fa2ddi822d3bd01e63d2ec@mail.gmail.com> 2008/12/12 Andy Robinson : > SVN-watchers may see a flurry of checkins over the next few days, > including a bunch of docstrings updates. You can now find API documents on our main library here; this is linked from the main page on www.reportlab.org http://www.reportlab.org/apis/reportlab/ This should make it a bit easier to browse documentation and source. Each module or package has at least a one-liner so you can see whether it's worth browsing further into. Note yet as beautiful as Python or Django's docs, but I hope a useful step. - Andy From jason at brucetek.net Mon Dec 15 12:14:58 2008 From: jason at brucetek.net (Jason Galyon) Date: Mon, 15 Dec 2008 11:14:58 -0600 Subject: [reportlab-users] 2.3 release and improved code kwalitee In-Reply-To: <956003ae0812150138q5b0fa2ddi822d3bd01e63d2ec@mail.gmail.com> References: <956003ae0812121005w7d8f67f4kaa2cd43fa2359cab@mail.gmail.com> <956003ae0812150138q5b0fa2ddi822d3bd01e63d2ec@mail.gmail.com> Message-ID: <49469092.2010706@brucetek.net> Andy Robinson wrote: > 2008/12/12 Andy Robinson : > >> SVN-watchers may see a flurry of checkins over the next few days, >> including a bunch of docstrings updates. >> > > You can now find API documents on our main library here; this is linked > from the main page on www.reportlab.org > > http://www.reportlab.org/apis/reportlab/ > > This should make it a bit easier to browse documentation and source. > Each module or package has at least a one-liner so you can > see whether it's worth browsing further into. > > Note yet as beautiful as Python or Django's docs, but I hope a useful > step. > > > - Andy > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > Python.org uses Sphinx and my local user group played around with this and found it quite helpful in generating code documentation. I highly recommend this tool. -- Jason Galyon BruceTek Ranorex US Representative 2691 Nova Park Ct Rockwall, TX 75087 USA email (preferred): jasong at brucetek.net Tel: (+1) 214-774-2669 From andy at reportlab.com Mon Dec 15 13:05:27 2008 From: andy at reportlab.com (Andy Robinson) Date: Mon, 15 Dec 2008 18:05:27 +0000 Subject: [reportlab-users] 2.3 release and improved code kwalitee In-Reply-To: <49469092.2010706@brucetek.net> References: <956003ae0812121005w7d8f67f4kaa2cd43fa2359cab@mail.gmail.com> <956003ae0812150138q5b0fa2ddi822d3bd01e63d2ec@mail.gmail.com> <49469092.2010706@brucetek.net> Message-ID: <956003ae0812151005y6039c5ebs271a3cdce42b0216@mail.gmail.com> 2008/12/15 Jason Galyon : > Python.org uses Sphinx and my local user group played around with this > and found it quite helpful in generating code documentation. I highly > recommend this tool. > We have limited time on each release, so we made a start by picking ReST as the docstring format and making sure they all parsed. If/when we write new manuals we'll be using Sphinx. We have one problem, though. Our raison d'etre is making PDF ourselves, not via LaTeX. So we will have to adopt and make any changes we need to Roberto Alsina's rst2pdf tool before or concurrently with switching our own main manuals to Sphinx. (And then we can help python.org eliminate the last non-Python step on their toolchain!). So, porting all the docs is too much of a bite for our New Year release. But hopefully it will come. Best Regards, Andy Robinson From ralsina at netmanagers.com.ar Tue Dec 16 08:08:22 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Tue, 16 Dec 2008 11:08:22 -0200 Subject: [reportlab-users] 2.3 release and improved code kwalitee References: <956003ae0812121005w7d8f67f4kaa2cd43fa2359cab@mail.gmail.com> <956003ae0812150138q5b0fa2ddi822d3bd01e63d2ec@mail.gmail.com> <49469092.2010706@brucetek.net> <956003ae0812151005y6039c5ebs271a3cdce42b0216@mail.gmail.com> Message-ID: Andy Robinson writes: > 2008/12/15 Jason Galyon : >> Python.org uses Sphinx and my local user group played around with this >> and found it quite helpful in generating code documentation. I highly >> recommend this tool. >> > > We have limited time on each release, so we made a start by picking > ReST as the docstring format and making sure they all parsed. If/when > we write new manuals we'll be using Sphinx. > > We have one problem, though. Our raison d'etre is making PDF ourselves, > not via LaTeX. So we will have to adopt and make any changes we need > to Roberto Alsina's rst2pdf tool before or concurrently with switching > our own main > manuals to Sphinx. (And then we can help python.org eliminate the last > non-Python step on their toolchain!). I have written a hackish rst2pdf output thingie for sphinx. You can find it somewhere in their bug tracking system. That should help you do one thing only ;-) Anyway, if you feel there is any way I can help you, just let me know. > > So, porting all the docs is too much of a bite for our New Year release. > But hopefully it will come. > > Best Regards, > > > Andy Robinson > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From stephane at is-webdesign.com Tue Dec 16 05:23:20 2008 From: stephane at is-webdesign.com (=?iso-8859-1?q?KLEIN_St=E9phane?=) Date: Tue, 16 Dec 2008 10:23:20 +0000 (UTC) Subject: [reportlab-users] [Tip] How to change underline thickness : canvas.setLineWidth(...) Message-ID: Hi, I write to post one tip that I don't found in reportlab user guide documentation. How to change underline tichness : call canvas.setLineWidth(your_value) Example : from reportlab.pdfgen.canvas import Canvas from reportlab.platypus import Paragraph from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib.pagesizes import A4 from reportlab.lib.units import cm c = Canvas('test.pdf', pagesize = A4) style = getSampleStyleSheet()["Normal"] c.setLineWidth(0.5 * cm) p = Paragraph("foo bar foo", style) p.wrap(10 *cm, 10*cm) p.drawOn(c, 5 * cm, 5*cm) c.showPage() c.save() Regards, Stephane From donn.ingle at gmail.com Tue Dec 16 12:08:48 2008 From: donn.ingle at gmail.com (Donn) Date: Tue, 16 Dec 2008 19:08:48 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs Message-ID: <200812161908.48432.donn.ingle@gmail.com> Hi, New to reportlab. I have been hacking for a while but can't make this work. If anyone could give me a nudge or two that would be great. I want something like this: "Some text or other" **** The stars are what I want to draw (i.e. I don't want to rely on a unicode symbol) alongside the preceding text. The text runs down in a frame. Each line is made from a Paragraph (I use the xml markup). At the moment I have it drawing boxes but it always breaks the flow and draws beneath the text. The boxes are generated like so: D=Drawing(width,18) D.add(Rect(0, 0, width, 18, fillColor=colors.yellow) I then: P = Paragraph(xml) fl=flowables.KeepTogether([P,D]) story.append(fl) (My code is kind of long and messy, so I won't post it unless I must.) Oh, I tried using an tag (in my paragraph) but it never draws the images. I tried pngs, jpgs and gifs. I am running this all through Apache and Django, so I may be getting the path to the image messed-up. The docs don't really say much about paths to this tag. Well, I hope someone can help! \d From gherman at darwin.in-berlin.de Wed Dec 17 03:11:30 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Wed, 17 Dec 2008 09:11:30 +0100 Subject: [reportlab-users] Using multiple versions in parallel? Message-ID: <9E2146CA-774C-4C94-B813-1780F96A91F4@darwin.in-berlin.de> Hi, I find myself switching between RL versions 2.1 and 2.2 often enough that I would like to replace my current method (switch- ing symbolic links inside the site-packages directory) with something on a higher (more pythonic) level. AFAIK RL doesn't support using multiple versions in parallel, but maybe somebody here has found a trick to to just that? And in fact, that would be of interest not only for using RL. Regards, Dinu From dirk.holtwick at gmail.com Wed Dec 17 03:17:15 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Wed, 17 Dec 2008 09:17:15 +0100 Subject: [reportlab-users] Using multiple versions in parallel? In-Reply-To: <9E2146CA-774C-4C94-B813-1780F96A91F4@darwin.in-berlin.de> References: <9E2146CA-774C-4C94-B813-1780F96A91F4@darwin.in-berlin.de> Message-ID: <4948B58B.9050409@gmail.com> Hi Dinu, I use "virtualenv" http://pypi.python.org/pypi/virtualenv/ and I can highly recommend it! This is such a great tool and makes testing in different environments as easy as turning the environment on (for Linux and Mac like this): $ source bin/activate and turn it off: $ deactivate Try it, it will change your life ;) Cheers Dirk Dinu Gherman schrieb: > Hi, > > I find myself switching between RL versions 2.1 and 2.2 often > enough that I would like to replace my current method (switch- > ing symbolic links inside the site-packages directory) with > something on a higher (more pythonic) level. > > AFAIK RL doesn't support using multiple versions in parallel, > but maybe somebody here has found a trick to to just that? > And in fact, that would be of interest not only for using RL. > > Regards, > > Dinu > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From andy at reportlab.com Wed Dec 17 04:41:41 2008 From: andy at reportlab.com (Andy Robinson) Date: Wed, 17 Dec 2008 09:41:41 +0000 Subject: [reportlab-users] Using multiple versions in parallel? In-Reply-To: <4948B58B.9050409@gmail.com> References: <9E2146CA-774C-4C94-B813-1780F96A91F4@darwin.in-berlin.de> <4948B58B.9050409@gmail.com> Message-ID: <956003ae0812170141y6d86849dwcfca64a07c983020@mail.gmail.com> 2008/12/17 Dirk Holtwick : > Hi Dinu, > > I use "virtualenv" http://pypi.python.org/pypi/virtualenv/ and I can highly > Try it, it will change your life ;) This worked for me as well. We're more "low-tech" with our usual projects with a solution which predates virtualenv by many years: each project we work on has a standard directory which is supposed to be on the path, and one can symlink or checkout the needed versions of reportlab, PIL, django or whatever that the project needs. We also tend to use a shell script to invoke each Python script, which makes sure that ONLY the main directory is on the PYTHONPATH. And site-packages contains nothing which would vary. The servers work the same. We've had this pattern for some time. In summary, put NOTHING which you might need to change in site-packages; and put everything a project needs to import in the project directory. BTW this is another reason why I dislike both distutils and setuptools. The default behaviour is to put everything in site-packages - a system-wide installation - which encourages clashes and confusion. I really think the simplest and safest installation process for Python was years ago when they would say "unzip foo.tgz and copy bar to your python path" - Andy From donn.ingle at gmail.com Wed Dec 17 23:49:37 2008 From: donn.ingle at gmail.com (Donn) Date: Thu, 18 Dec 2008 06:49:37 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <200812161908.48432.donn.ingle@gmail.com> References: <200812161908.48432.donn.ingle@gmail.com> Message-ID: <200812180649.37620.donn.ingle@gmail.com> Anyone out there? Please give me a small clue in the right direction. \d From timr at probo.com Thu Dec 18 13:46:10 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Dec 2008 10:46:10 -0800 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <200812161908.48432.donn.ingle@gmail.com> References: <200812161908.48432.donn.ingle@gmail.com> Message-ID: <494A9A72.3020403@probo.com> Donn wrote: > New to reportlab. I have been hacking for a while but can't make this work. If > anyone could give me a nudge or two that would be great. > > I want something like this: > > "Some text or other" **** > > The stars are what I want to draw (i.e. I don't want to rely on a unicode > symbol) alongside the preceding text. The text runs down in a frame. Each > line is made from a Paragraph (I use the xml markup). > > At the moment I have it drawing boxes but it always breaks the flow and draws > beneath the text. I'm not convinced this is possible, without writing a custom paragraph flowable. The whole principle of platpus flowables is that each flowable consists of one kind of "thing"; you are violating this principle. Do you really need flowable paragraphs? For 99% of the reportlab work I do, I forget about platypus and just draw directly on the canvas. If you don't use platypus, what you ask is very easy to do. > Oh, I tried using an tag (in my paragraph) but it never draws the > images. I tried pngs, jpgs and gifs. The platypus paragraph parser doesn't handle tags. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From donn.ingle at gmail.com Thu Dec 18 14:20:11 2008 From: donn.ingle at gmail.com (Donn) Date: Thu, 18 Dec 2008 21:20:11 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494A9A72.3020403@probo.com> References: <200812161908.48432.donn.ingle@gmail.com> <494A9A72.3020403@probo.com> Message-ID: <200812182120.12520.donn.ingle@gmail.com> On Thursday, 18 December 2008 20:46:10 Tim Roberts wrote: > If > you don't use platypus, what you ask is very easy to do. Okay, that was where I was leaning towards. > The platypus paragraph parser doesn't handle tags. Not according to the docs, unless I read them wrong. There is a section after the XML tags (like bold, font, etc.) that shows an img tag. If I could get that working it would solve the problem. Thanks for your help, \d From timr at probo.com Thu Dec 18 14:17:04 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Dec 2008 11:17:04 -0800 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <200812182120.12520.donn.ingle@gmail.com> References: <200812161908.48432.donn.ingle@gmail.com> <494A9A72.3020403@probo.com> <200812182120.12520.donn.ingle@gmail.com> Message-ID: <494AA1B0.1080200@probo.com> Donn wrote: > On Thursday, 18 December 2008 20:46:10 Tim Roberts wrote: > >> The platypus paragraph parser doesn't handle tags. >> > Not according to the docs, unless I read them wrong. There is a section after > the XML tags (like bold, font, etc.) that shows an img tag. If I could get > that working it would solve the problem. > Well, I am a version or two behind, so perhaps it was added recently. If so, then perhaps your real issue is the paths. Remember that your ReportLab script is running locally on the server. It doesn't know anything about the web. The tag needs to use real file system paths, relative to the directory containing the script (if you are running CGI). You don't use URLs. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From donn.ingle at gmail.com Thu Dec 18 15:12:15 2008 From: donn.ingle at gmail.com (Donn) Date: Thu, 18 Dec 2008 22:12:15 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494AA1B0.1080200@probo.com> References: <200812161908.48432.donn.ingle@gmail.com> <200812182120.12520.donn.ingle@gmail.com> <494AA1B0.1080200@probo.com> Message-ID: <200812182212.15944.donn.ingle@gmail.com> On Thursday, 18 December 2008 21:17:04 Tim Roberts wrote: > The tag needs to use real file system > paths, relative to the directory containing the script (if you are > running CGI). ?You don't use URLs. Thanks, I did try absolute paths from root down, but to no avail. I will try using relative paths but that will take some hacking as I am using Python via modpython and Apache etc. and paths are anything but simple :) Appreciate the input. \d From timr at probo.com Thu Dec 18 15:14:25 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 18 Dec 2008 12:14:25 -0800 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <200812182212.15944.donn.ingle@gmail.com> References: <200812161908.48432.donn.ingle@gmail.com> <200812182120.12520.donn.ingle@gmail.com> <494AA1B0.1080200@probo.com> <200812182212.15944.donn.ingle@gmail.com> Message-ID: <494AAF21.4020209@probo.com> Donn wrote: > On Thursday, 18 December 2008 21:17:04 Tim Roberts wrote: > >> The tag needs to use real file system >> paths, relative to the directory containing the script (if you are >> running CGI). You don't use URLs. >> > > Thanks, I did try absolute paths from root down, but to no avail. I will try > using relative paths but that will take some hacking as I am using Python via > modpython and Apache etc. and paths are anything but simple :) > If absolute paths didn't work, then relative aren't going to, either. Permission issues? Do you have PIL installed? What happened? Did you get an error, or just no image? -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From cfoster at oda.state.or.us Thu Dec 18 16:17:16 2008 From: cfoster at oda.state.or.us (Chris Foster) Date: Thu, 18 Dec 2008 13:17:16 -0800 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494AAF21.4020209@probo.com> References: <200812161908.48432.donn.ingle@gmail.com> <200812182120.12520.donn.ingle@gmail.com> <494AA1B0.1080200@probo.com> <200812182212.15944.donn.ingle@gmail.com> <494AAF21.4020209@probo.com> Message-ID: Make sure you are actually hitting the right frame and that it is big enough. That simple error has tripped me twice. I use images in Paragraphs with absolute paths. I have noticed some placement issues, but I'm surviving and the users go gaga for fancy checkboxes. On Dec 18, 2008, at 12:14 PM, Tim Roberts wrote: > Donn wrote: >> On Thursday, 18 December 2008 21:17:04 Tim Roberts wrote: >> >>> The tag needs to use real file system >>> paths, relative to the directory containing the script (if you are >>> running CGI). You don't use URLs. >>> >> >> Thanks, I did try absolute paths from root down, but to no avail. I >> will try >> using relative paths but that will take some hacking as I am using >> Python via >> modpython and Apache etc. and paths are anything but simple :) >> > > If absolute paths didn't work, then relative aren't going to, either. > > Permission issues? Do you have PIL installed? What happened? Did > you > get an error, or just no image? > > -- > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From donn.ingle at gmail.com Fri Dec 19 02:51:18 2008 From: donn.ingle at gmail.com (Donn) Date: Fri, 19 Dec 2008 09:51:18 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494AAF21.4020209@probo.com> References: <200812161908.48432.donn.ingle@gmail.com> <200812182212.15944.donn.ingle@gmail.com> <494AAF21.4020209@probo.com> Message-ID: <200812190951.19056.donn.ingle@gmail.com> On Thursday, 18 December 2008 22:14:25 Tim Roberts wrote: > If absolute paths didn't work, then relative aren't going to, either. Darn. > Permission issues? ? Yes and no. The thing is a little complex with modpython/Django and Co. All images in my media directory can be accessed by Apache. > Do you have PIL installed? ? Yes. > What happened? ?Did you > get an error, or just no image? I looked for errors. Perhaps there's a log I don't know about, but there was no python error, nothing in the Apache logs. It simply drew no image in the resulting PDF. I will scrape some code together and try again. I need something more concrete to show here. Many thanks, \d From donn.ingle at gmail.com Fri Dec 19 04:06:24 2008 From: donn.ingle at gmail.com (Donn) Date: Fri, 19 Dec 2008 11:06:24 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: References: <200812161908.48432.donn.ingle@gmail.com> <494AAF21.4020209@probo.com> Message-ID: <200812191106.24458.donn.ingle@gmail.com> On Thursday, 18 December 2008 23:17:16 Chris Foster wrote: > I use images in Paragraphs with absolute paths. ?I have noticed some ? > placement issues, but I'm surviving and the users go gaga for fancy ? > checkboxes. I have now tried it relative and absolute. I have tried png, gif and jpg. Pil is installed. Nothing shows up. I made the frame as wide as the page and the paragraphs within it have plenty space on the right. To the end of a basic xml string I add: If it's easy, could you paste some code? \d From robin at reportlab.com Fri Dec 19 05:21:51 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 19 Dec 2008 10:21:51 +0000 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494AA1B0.1080200@probo.com> References: <200812161908.48432.donn.ingle@gmail.com> <494A9A72.3020403@probo.com> <200812182120.12520.donn.ingle@gmail.com> <494AA1B0.1080200@probo.com> Message-ID: <494B75BF.4090300@chamonix.reportlab.co.uk> Tim Roberts wrote: > Donn wrote: >> On Thursday, 18 December 2008 20:46:10 Tim Roberts wrote: >> >>> The platypus paragraph parser doesn't handle tags. >>> >> Not according to the docs, unless I read them wrong. There is a section after >> the XML tags (like bold, font, etc.) that shows an img tag. If I could get >> that working it would solve the problem. >> > > Well, I am a version or two behind, so perhaps it was added recently. > > If so, then perhaps your real issue is the paths. Remember that your > ReportLab script is running locally on the server. It doesn't know > anything about the web. The tag needs to use real file system > paths, relative to the directory containing the script (if you are > running CGI). You don't use URLs. > Modern ReportLab should be able to handle urls etc etc, but we certainly don't have the concept of a baseurl. This works for me with latest code ################################ from reportlab.platypus import Paragraph, SimpleDocTemplate from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle styleSheet = getSampleStyleSheet() P = Paragraph('This is an Img ',styleSheet['BodyText']) P.autoLeading = 'max' doc = SimpleDocTemplate('timg.pdf') doc.build([P]) ################################ -- Robin Becker From donn.ingle at gmail.com Fri Dec 19 09:19:42 2008 From: donn.ingle at gmail.com (Donn) Date: Fri, 19 Dec 2008 16:19:42 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494B75BF.4090300@chamonix.reportlab.co.uk> References: <200812161908.48432.donn.ingle@gmail.com> <494AA1B0.1080200@probo.com> <494B75BF.4090300@chamonix.reportlab.co.uk> Message-ID: <200812191619.43235.donn.ingle@gmail.com> On Friday, 19 December 2008 12:21:51 Robin Becker wrote: > P = Paragraph('This is an Img src="http://www.reportlab.com/media/base/logo_bg.gif"/>',styleSheet['BodyTe >xt']) I tried to use the same URL and got nothing. Here is my stripped-down code (a Django view) to show what I am trying. The text always appears, but never the image. \d def desiderata_pdf(request,brotherpk=None): styles = getSampleStyleSheet() styleN = styles['Normal'] styleN.fontSize= 9 styleN.leading=11 styleH2 = styles['Heading3'] story = [] hcm = 0.5 * cm # Create the HttpResponse object with the appropriate PDF headers. response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=TEST.PDF' import os,sys cwd=sys.path#os.getcwd() # getcwd shows "/" # tried this, with many types of paths. i='' # And this i='' story.append(Paragraph('CWD is:%s image?%s ' %(cwd, i), styleH2 )) #create the basic page and frames document = platypus.BaseDocTemplate(response, leftMargin=hcm,rightMargin=hcm,topMargin=hcm,bottomMargin=hcm,pagesize=A5) frameCount = 1 frameWidth = document.width/frameCount frameHeight = document.height frames = [] #construct a frame for each column for frame in range(frameCount): leftMargin = document.leftMargin + frame*frameWidth column = platypus.Frame(leftMargin,hcm, frameWidth, frameHeight,showBoundary=1) frames.append(column) template = platypus.PageTemplate(frames=frames) document.addPageTemplates(template) document.build( story ) return response From donn.ingle at gmail.com Fri Dec 19 11:08:59 2008 From: donn.ingle at gmail.com (Donn) Date: Fri, 19 Dec 2008 18:08:59 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494BC30F.3030906@appropriatesolutions.com> References: <494BC30F.3030906@appropriatesolutions.com> Message-ID: <200812191808.59489.donn.ingle@gmail.com> On Friday, 19 December 2008 17:51:43 you wrote: > but have you confirmed whether you can > make this stuff work from a command line python? ?If it doesn't work > there, it won't work under Django. You are right, I should go back to first principles. Lemme go hack. \d -- Isn't it enough to see that a garden is beautiful without having to believe that there are fairies at the bottom of it too? -- Douglas Adams Fonty Python and other dev news at: http://otherwiseingle.blogspot.com/ From Michael at Hipp.com Fri Dec 19 18:41:18 2008 From: Michael at Hipp.com (Michael Hipp) Date: Fri, 19 Dec 2008 17:41:18 -0600 Subject: [reportlab-users] Installer for Python 2.6? Message-ID: <494C311E.8060003@Hipp.com> Is ReportLab fully compatible with Python 2.6? I notice there is no binary installer for 2.6 listed here: http://www.reportlab.org/downloads.html Thanks, Michael From donn.ingle at gmail.com Sat Dec 20 03:28:09 2008 From: donn.ingle at gmail.com (Donn) Date: Sat, 20 Dec 2008 10:28:09 +0200 Subject: [reportlab-users] Paragraph img tag issue Message-ID: <200812201028.09611.donn.ingle@gmail.com> Hello, I got a chance to focus on the issue in my other thread. I used examples.py and added an img tag. I cannot get it to draw the image that sits in the same directory that I run the script from (all from the cli). I am on Kubuntu and reportlab version: Version: 2.0dfsg-1 I am on Python 2.5 The image was tried as jpg, png and gif. The path as "halo.gif", "./halo.gif" I hope the problem does not require a newer version of RL since I rely on the repository version on my server. Thanks, \d Here is the code: from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib.units import inch styles = getSampleStyleSheet() def go(): doc = SimpleDocTemplate("phello.pdf") Story = [Spacer(1,2*inch)] style = styles["Normal"] img='' for i in range(2): bogustext = ("XML tags work!, but not images: %s. see?" % img) *20 p = Paragraph(bogustext, style) Story.append(p) Story.append(Spacer(1,0.2*inch)) doc.build(Story) go() From gherman at darwin.in-berlin.de Sat Dec 20 03:38:52 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Sat, 20 Dec 2008 09:38:52 +0100 Subject: [reportlab-users] Paragraph img tag issue In-Reply-To: <200812201028.09611.donn.ingle@gmail.com> References: <200812201028.09611.donn.ingle@gmail.com> Message-ID: Donn: > I cannot get it to draw the image that sits in the same directory > that I run > the script from (all from the cli). I'd be surprised if a relative path name would work. Can't you determine and indicate the absolute path? Dinu From donn.ingle at gmail.com Sat Dec 20 03:53:59 2008 From: donn.ingle at gmail.com (Donn) Date: Sat, 20 Dec 2008 10:53:59 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <494A9A72.3020403@probo.com> References: <200812161908.48432.donn.ingle@gmail.com> <494A9A72.3020403@probo.com> Message-ID: <200812201053.59797.donn.ingle@gmail.com> On Thursday, 18 December 2008 20:46:10 Tim Roberts wrote: > I'm not convinced this is possible, without writing a custom paragraph > flowable. ?The whole principle of platpus flowables is that each > flowable consists of one kind of "thing"; you are violating this principle. Hi, My PDF is a two-column affair. I am not adept enough to avoid platypus and get the right layout. Could you (or anyone) give me a hand with a custom Paragraph that can include a drawing-area alongside it? It's not the end of the world to have the stars under the text, but it does waste space and make longer documents. Some text **** vs Some text **** As an alternative: I was using the unicode symbol u"\u2605" and it gave really nice stars until it stopped. It's now drawing a thin slanted + symbol. I gather this has something to do with fonts, but don't know what or why. Is there anything I can do to guarantee the right symbol arrives in PDF on J.Random User's machine? \d From donn.ingle at gmail.com Sat Dec 20 03:56:12 2008 From: donn.ingle at gmail.com (Donn) Date: Sat, 20 Dec 2008 10:56:12 +0200 Subject: [reportlab-users] Paragraph img tag issue In-Reply-To: References: <200812201028.09611.donn.ingle@gmail.com> Message-ID: <200812201056.12892.donn.ingle@gmail.com> On Saturday, 20 December 2008 10:38:52 Dinu Gherman wrote: > I'd be surprised if a relative path name would work. > Can't you determine and indicate the absolute path? I just tried with an absolute path and there's still no image. (P.S The docs use a relative path as their example.) Thanks for the input! \d From luc.saffre at gmx.net Sun Dec 21 19:39:57 2008 From: luc.saffre at gmx.net (Luc Saffre) Date: Mon, 22 Dec 2008 02:39:57 +0200 Subject: [reportlab-users] ANN: pdfnup 0.3.0 In-Reply-To: <20BB4A0E-EDB4-44E2-8A2C-1BA7A7BE3BC3@darwin.in-berlin.de> References: <20BB4A0E-EDB4-44E2-8A2C-1BA7A7BE3BC3@darwin.in-berlin.de> Message-ID: <494EE1DD.5050600@gmx.net> Dinu, thanks for you work so far! I downloaded http://www.dinu-gherman.net/tmp/pdfnup-0.3.3.tar.gz and created a file pdfnup_test.py: import sys from pdfnup import generateNup generateNup(sys.argv[1],2) This failed on a simple PDF file generated by OpenOffice: C:\temp>python pdfnup_test.py pdfnup_test.pdf Traceback (most recent call last): File "pdfnup_test.py", line 3, in generateNup(sys.argv[1],2) File "s:\py-site-packages\pdfnup-0.3.3\pdfnup.py", line 284, in generateNup rotation = page2["/Rotate"].getObject() File "s:\py-site-packages\pyPdf-1.12\pyPdf\generic.py", line 466, in __getitem__ return dict.__getitem__(self, key).getObject() KeyError: '/Rotate' The file I used for testing is here: http://lino.saffre-rumma.ee/dl/pdfnup_test.pdf Any idea? Luc On 24.09.2008 13:40, Dinu Gherman wrote: > Hi, > > I'm announcing the next of a series of little PDF handling tools > I wrote to work with PDF files. This one is named "pdfnup" and > is (verly lightly) based on ReportLab (apart from the test PDFs, > also created with RL), but might be useful for people on this > list as well. Mostly it is based on PyPDF. > > You should be able to easy_install "pdfnup" and lookup details > in the Python Package Index: > > http://pypi.python.org/pypi/pdfnup > > Sadly, I cannot establish a proper dependency to the RL toolkit > in PyPI/setuptools, because the RL code isn't propperly regist- > ered there. > > Nevertheless, I hope this will be useful for others as well. > Comments are welcome! > > Regards, > > Dinu > > > ------------------------------------------------------------------------ > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From andy at reportlab.com Mon Dec 22 03:00:27 2008 From: andy at reportlab.com (Andy Robinson) Date: Mon, 22 Dec 2008 08:00:27 +0000 Subject: [reportlab-users] Installer for Python 2.6? In-Reply-To: <494C311E.8060003@Hipp.com> References: <494C311E.8060003@Hipp.com> Message-ID: <956003ae0812220000x385668d9l5dd5022ae90977f6@mail.gmail.com> 2008/12/19 Michael Hipp : > Is ReportLab fully compatible with Python 2.6? > > I notice there is no binary installer for 2.6 listed here: > http://www.reportlab.org/downloads.html Today we are not. At least one incompatibility was reported last month. However, we are aiming for a version 2.3 (of ReportLab, not Python) in the next couple of weeks and if we get time and the issues are not too big we may try to tackle them. Best Regards, -- Andy Robinson ReportLab From andy at reportlab.com Mon Dec 22 03:46:15 2008 From: andy at reportlab.com (Andy Robinson) Date: Mon, 22 Dec 2008 08:46:15 +0000 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <200812201053.59797.donn.ingle@gmail.com> References: <200812161908.48432.donn.ingle@gmail.com> <494A9A72.3020403@probo.com> <200812201053.59797.donn.ingle@gmail.com> Message-ID: <956003ae0812220046o414684bdi879557d6c8f74637@mail.gmail.com> 2008/12/20 Donn : > As an alternative: I was using the unicode symbol u"\u2605" and it gave really > nice stars until it stopped. It's now drawing a thin slanted + symbol. I > gather this has something to do with fonts, but don't know what or why. Is > there anything I can do to guarantee the right symbol arrives in PDF on > J.Random User's machine? Pick a font you like, which is NOT used by reference (i.e. not Helvetica, Times-Roman, Courier, Symbol or ZapfDingbats); and use that to draw the stars in, and the glyphs should be embedded in your PDF. I would suggest using a TrueType font Best Regards, -- Andy Robinson CEO/Chief Architect ReportLab Europe Ltd. Media House, 3 Palmerston Road, Wimbledon, London SW19 1PG, UK Tel +44-20-8545-1570 From donn.ingle at gmail.com Mon Dec 22 05:02:55 2008 From: donn.ingle at gmail.com (Donn) Date: Mon, 22 Dec 2008 12:02:55 +0200 Subject: [reportlab-users] Drawing things alongside paragraphs In-Reply-To: <956003ae0812220046o414684bdi879557d6c8f74637@mail.gmail.com> References: <200812161908.48432.donn.ingle@gmail.com> <200812201053.59797.donn.ingle@gmail.com> <956003ae0812220046o414684bdi879557d6c8f74637@mail.gmail.com> Message-ID: <200812221202.55776.donn.ingle@gmail.com> On Monday, 22 December 2008 10:46:15 Andy Robinson wrote: > and the glyphs should be > embedded in your PDF. ? I would suggest using a TrueType font Thanks. I'll go give it a whirl. \d From robin at reportlab.com Mon Dec 22 05:39:25 2008 From: robin at reportlab.com (Robin Becker) Date: Mon, 22 Dec 2008 10:39:25 +0000 Subject: [reportlab-users] Paragraph img tag issue In-Reply-To: <200812201028.09611.donn.ingle@gmail.com> References: <200812201028.09611.donn.ingle@gmail.com> Message-ID: <494F6E5D.2090008@chamonix.reportlab.co.uk> Donn wrote: > Hello, > I got a chance to focus on the issue in my other thread. I used examples.py > and added an img tag. > > I cannot get it to draw the image that sits in the same directory that I run > the script from (all from the cli). > > I am on Kubuntu and reportlab version: Version: 2.0dfsg-1 > I am on Python 2.5 ......... Version 2.0 doesn't support img tags. You need to install a private copy of 2.2 or later. -- Robin Becker From donn.ingle at gmail.com Mon Dec 22 05:52:24 2008 From: donn.ingle at gmail.com (Donn) Date: Mon, 22 Dec 2008 12:52:24 +0200 Subject: [reportlab-users] Paragraph img tag issue In-Reply-To: <494F6E5D.2090008@chamonix.reportlab.co.uk> References: <200812201028.09611.donn.ingle@gmail.com> <494F6E5D.2090008@chamonix.reportlab.co.uk> Message-ID: <200812221252.24429.donn.ingle@gmail.com> On Monday, 22 December 2008 12:39:25 Robin Becker wrote: > Version 2.0 doesn't support img tags. You need to install a private copy of > 2.2 or later. Ah, that sorts that then! Thanks. \d From a.cappelli at gmail.com Mon Dec 22 06:23:38 2008 From: a.cappelli at gmail.com (Andrea Cappelli) Date: Mon, 22 Dec 2008 12:23:38 +0100 Subject: [reportlab-users] CMYK in platypus.Table Message-ID: <494F78BA.1000709@gmail.com> Hi all, I'am using report lab to produce pdf which will be printed in a tipography, which requires CMYK colors for everything. For text and images i'am able to specify such colors, but if I want to use a Table or Paragraph with platypus i see in the doc the colors have to be specified as RGB. Is possible to have CMYK colors in Tables/Paragraphs? Someone as the same problem/requirement? Thank you Andrea From gherman at darwin.in-berlin.de Mon Dec 22 06:27:33 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Mon, 22 Dec 2008 12:27:33 +0100 Subject: [reportlab-users] ANN: pdfnup 0.3.0 In-Reply-To: <494EE1DD.5050600@gmx.net> References: <20BB4A0E-EDB4-44E2-8A2C-1BA7A7BE3BC3@darwin.in-berlin.de> <494EE1DD.5050600@gmx.net> Message-ID: Luc Saffre: > Dinu, > > thanks for you work so far! I downloaded > http://www.dinu-gherman.net/tmp/pdfnup-0.3.3.tar.gz > and created a file pdfnup_test.py: > > import sys > from pdfnup import generateNup > generateNup(sys.argv[1],2) > > This failed on a simple PDF file generated by OpenOffice: > > C:\temp>python pdfnup_test.py pdfnup_test.pdf > Traceback (most recent call last): > File "pdfnup_test.py", line 3, in > generateNup(sys.argv[1],2) > File "s:\py-site-packages\pdfnup-0.3.3\pdfnup.py", line 284, in > generateNup > rotation = page2["/Rotate"].getObject() > File "s:\py-site-packages\pyPdf-1.12\pyPdf\generic.py", line 466, in > __getitem__ > return dict.__getitem__(self, key).getObject() > KeyError: '/Rotate' > > The file I used for testing is here: > > http://lino.saffre-rumma.ee/dl/pdfnup_test.pdf > > Any idea? Hi Luc, sure, use the patch I've sent you on Dec, 12th via private email. If you didn't receive it, please find it below. Regards, Dinu $ diff -u pdfnup.py pdfnupX.py --- pdfnup.py 2008-11-17 13:26:02.000000000 +0100 +++ pdfnupX.py 2008-12-19 11:02:25.000000000 +0100 @@ -281,7 +281,10 @@ page2Content.operations.insert(0, [[], "q"]) # handle rotation - rotation = page2["/Rotate"].getObject() + try: + rotation = page2["/Rotate"].getObject() + except: + rotation = 0 if rotation in (180, 270): dw, dh = destWidth, destHeight arr = [-xScale, 0, 0, -yScale, destX+dw, destY+dh] From a.cappelli at gmail.com Mon Dec 22 06:28:32 2008 From: a.cappelli at gmail.com (Andrea Cappelli) Date: Mon, 22 Dec 2008 12:28:32 +0100 Subject: [reportlab-users] Table usage Message-ID: <494F79E0.30508@gmail.com> Hi all, i would like to build a table that span over more pages. I was able to reproduce the table headers in each page, but i would to write other info in each page tha table spans to. So i was wondering if is possible to dinamically add new rows to the table and after each insert check the table height with wrapOn, so when I realize that the table is too tall to fit the page i remove the last row, close the page and start a new page. Anyone does something similar? There is a quick way in report lab? Thanks in advance From luc.saffre at gmx.net Mon Dec 22 09:47:17 2008 From: luc.saffre at gmx.net (Luc Saffre) Date: Mon, 22 Dec 2008 16:47:17 +0200 Subject: [reportlab-users] ANN: pdfnup 0.3.0 In-Reply-To: References: <20BB4A0E-EDB4-44E2-8A2C-1BA7A7BE3BC3@darwin.in-berlin.de> <494EE1DD.5050600@gmx.net> Message-ID: <494FA875.2040203@gmx.net> On 22.12.2008 13:27, Dinu Gherman wrote: > > sure, use the patch I've sent you on Dec, 12th via private > email. Oho? No, it seems that I didn't receive this message? Maybe you can send it again to my private e-mail? > If you didn't receive it, please find it below. > $ diff -u pdfnup.py pdfnupX.py > --- pdfnup.py 2008-11-17 13:26:02.000000000 +0100 > +++ pdfnupX.py 2008-12-19 11:02:25.000000000 +0100 > @@ -281,7 +281,10 @@ > page2Content.operations.insert(0, [[], "q"]) > > # handle rotation > - rotation = page2["/Rotate"].getObject() > + try: > + rotation = page2["/Rotate"].getObject() > + except: > + rotation = 0 > if rotation in (180, 270): > dw, dh = destWidth, destHeight > arr = [-xScale, 0, 0, -yScale, destX+dw, destY+dh] That's fine, now it works. I'd suggest that you write "except KeyError:" instead of "except:" because if something else happens during getObject() this will be hard to track. Luc From luc.saffre at gmx.net Mon Dec 22 10:07:18 2008 From: luc.saffre at gmx.net (Luc Saffre) Date: Mon, 22 Dec 2008 17:07:18 +0200 Subject: [reportlab-users] ANN: pdfnup 0.3.0 In-Reply-To: References: <20BB4A0E-EDB4-44E2-8A2C-1BA7A7BE3BC3@darwin.in-berlin.de> <494EE1DD.5050600@gmx.net> Message-ID: <494FAD26.7000305@gmx.net> Dinu, here is a next bug report, consider it as a Christmas gift ;-) Now I tested it on a similar file, created using pdflatex. The .tex input file is here: http://lino.saffre-rumma.ee/dl/pdfnup_test.tex and the resulting pdf is here: http://lino.saffre-rumma.ee/dl/pdfnup_test.pdf And here is the traceback I get when I try pdfnup_test.py on it: C:\temp>python pdfnup_test.py pdfnup_test.pdf Traceback (most recent call last): File "pdfnup_test.py", line 3, in generateNup(sys.argv[1],2) File "s:\py-site-packages\pdfnup-0.3.3\pdfnup.py", line 307, in generateNup output.write(outputStream) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 167, in write self._sweepIndirectReferences(externalReferenceMap, self._root) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 242, in _sweepIndirectReferences self._sweepIndirectReferences(externMap, realdata) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 218, in _sweepIndirectReferences value = self._sweepIndirectReferences(externMap, value) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 242, in _sweepIndirectReferences self._sweepIndirectReferences(externMap, realdata) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 218, in _sweepIndirectReferences value = self._sweepIndirectReferences(externMap, value) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 227, in _sweepIndirectReferences value = self._sweepIndirectReferences(externMap, data[i]) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 242, in _sweepIndirectReferences self._sweepIndirectReferences(externMap, realdata) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 218, in _sweepIndirectReferences value = self._sweepIndirectReferences(externMap, value) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 218, in _sweepIndirectReferences value = self._sweepIndirectReferences(externMap, value) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 218, in _sweepIndirectReferences value = self._sweepIndirectReferences(externMap, value) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 248, in _sweepIndirectReferences newobj = data.pdf.getObject(data) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 546, in getObject idnum, generation = self.readObjectHeader(self.stream) File "s:\py-site-packages\pyPdf-1.12\pyPdf\pdf.py", line 593, in readObjectHeader return int(idnum), int(generation) ValueError: invalid literal for int() with base 10: '' Merry Christmas! (in case we don't write before) Luc On 22.12.2008 13:27, Dinu Gherman wrote: > Luc Saffre: > >> Dinu, >> >> thanks for you work so far! I downloaded >> http://www.dinu-gherman.net/tmp/pdfnup-0.3.3.tar.gz >> and created a file pdfnup_test.py: >> >> import sys >> from pdfnup import generateNup >> generateNup(sys.argv[1],2) >> >> This failed on a simple PDF file generated by OpenOffice: >> >> C:\temp>python pdfnup_test.py pdfnup_test.pdf >> Traceback (most recent call last): >> File "pdfnup_test.py", line 3, in >> generateNup(sys.argv[1],2) >> File "s:\py-site-packages\pdfnup-0.3.3\pdfnup.py", line 284, in >> generateNup >> rotation = page2["/Rotate"].getObject() >> File "s:\py-site-packages\pyPdf-1.12\pyPdf\generic.py", line 466, in >> __getitem__ >> return dict.__getitem__(self, key).getObject() >> KeyError: '/Rotate' >> >> The file I used for testing is here: >> >> http://lino.saffre-rumma.ee/dl/pdfnup_test.pdf >> >> Any idea? > > > Hi Luc, > > sure, use the patch I've sent you on Dec, 12th via private > email. If you didn't receive it, please find it below. > > Regards, > > Dinu > > > $ diff -u pdfnup.py pdfnupX.py > --- pdfnup.py 2008-11-17 13:26:02.000000000 +0100 > +++ pdfnupX.py 2008-12-19 11:02:25.000000000 +0100 > @@ -281,7 +281,10 @@ > page2Content.operations.insert(0, [[], "q"]) > > # handle rotation > - rotation = page2["/Rotate"].getObject() > + try: > + rotation = page2["/Rotate"].getObject() > + except: > + rotation = 0 > if rotation in (180, 270): > dw, dh = destWidth, destHeight > arr = [-xScale, 0, 0, -yScale, destX+dw, destY+dh] > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > From graeme at lutralutra.co.uk Tue Dec 23 05:20:37 2008 From: graeme at lutralutra.co.uk (Graeme Hawker) Date: Tue, 23 Dec 2008 10:20:37 -0000 (GMT) Subject: [reportlab-users] Mixing landscape and portrait pages Message-ID: <27174.213.122.166.34.1230027637.squirrel@mail5.webfaction.com> Hi, I've seen that reportlab can handle landscape page styles for the entire document: from reportlab.lib.pagesizes import A4, LETTER, landscape, portrait doc.pagesize = landscape(A4) doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages) But is there any way to mix the two page orientations (landscape and portrait) within a single document? I would like to create a portrait document with a couple of landscape pages inside for wide tables. Thanks Graeme From andy at reportlab.com Tue Dec 23 05:27:45 2008 From: andy at reportlab.com (Andy Robinson) Date: Tue, 23 Dec 2008 10:27:45 +0000 Subject: [reportlab-users] CMYK in platypus.Table In-Reply-To: <494F78BA.1000709@gmail.com> References: <494F78BA.1000709@gmail.com> Message-ID: <956003ae0812230227g53a55d78v8ef855a703a60b58@mail.gmail.com> 2008/12/22 Andrea Cappelli : > Hi all, > I'am using report lab to produce pdf which will be printed in a > tipography, which requires CMYK colors for everything. > For text and images i'am able to specify such colors, but if I want to > use a Table or Paragraph with platypus i see in the doc the colors have > to be specified as RGB. Is possible to have CMYK colors in > Tables/Paragraphs? Someone as the same problem/requirement? > You can use CMYK everywhere. However, the standard color names such as "black", "red" etc refer to RGB colors, and several things default to RGB black (such as grid line colour and paragraph text colour). To produce a CMYK document, you'll therefore need to explicitly create a "CMYK black", and set the colour of your paragraph text to it in the stylesheet. If you are using getSampleStyleSheet(), paste the source into a new module of your own and set the colours. We have found in the past that printing presses are usually smart enough to treat RGB black as CMYK black - YMMV here - but any other colour needs to be specified. We probably ought to have a variable you can set at the outset which asks if the document is CMYK or RGB and warns if you mix them, but at this time we don't. - Andy From donn.ingle at gmail.com Wed Dec 24 01:09:40 2008 From: donn.ingle at gmail.com (Donn) Date: Wed, 24 Dec 2008 08:09:40 +0200 Subject: [reportlab-users] Unicode stars and fonts -- resolved Message-ID: <200812240809.40844.donn.ingle@gmail.com> Hello all, I thought I'd feed-back a little. The problem was: I had a string s=u"\u2605" that used to draw nice stars (in the PDF) and then stopped doing so. The solution was: I removed fonts installed to my $HOME/.fonts directory (I am on Gnu/Linux) and one of them was zapfdingbats.ttf I don't know why, but this reset some voodoo in the scheme of things and my PDF stars returned with no other change to the source required. Have a Merry Newtonmas and thanks for the recent help. \d From mark.zitnik at gmail.com Wed Dec 24 04:34:17 2008 From: mark.zitnik at gmail.com (Mark Zitnik) Date: Wed, 24 Dec 2008 04:34:17 -0500 Subject: [reportlab-users] problem with missing Times-Roman font Message-ID: Hi All, i have installed successfully reportlab on ubunto and tried to create VerticalBarChart but i'am missing Can't setFont(Times-Roman) missing the T1 files? and i can not find it. Please help. the code # code to produce the above chart from reportlab.graphics.shapes import Drawing from reportlab.lib import colors from reportlab.graphics.charts.barcharts import VerticalBarChart drawing = Drawing(400, 200) data = [ (13, 5, 20, 22, 37, 45, 19, 4), (14, 6, 21, 23, 38, 46, 20, 5) ] bc = VerticalBarChart() #bc.setFont('Helvetica', 30) bc.x = 50 bc.y = 50 bc.height = 125 bc.width = 300 bc.data = data bc.strokeColor = colors.black bc.valueAxis.valueMin = 0 bc.valueAxis.valueMax = 50 bc.valueAxis.valueStep = 10 bc.categoryAxis.labels.boxAnchor = 'ne' bc.categoryAxis.labels.dx = 8 bc.categoryAxis.labels.dy = -2 bc.categoryAxis.labels.angle = 30 bc.categoryAxis.categoryNames = ['Jan-99','Feb-99','Mar-99', 'Apr-99','May-99','Jun-99','Jul-99','Aug-99'] drawing.add(bc) drawing.save(formats=['gif']) -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at reportlab.com Wed Dec 24 05:24:23 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 24 Dec 2008 10:24:23 +0000 Subject: [reportlab-users] problem with missing Times-Roman font In-Reply-To: References: Message-ID: <49520DD7.3000903@chamonix.reportlab.co.uk> Mark Zitnik wrote: > Hi All, > > i have installed successfully reportlab on ubunto and tried to create > VerticalBarChart > > but i'am missing Can't setFont(Times-Roman) missing the T1 files? and i can > not find it. > > Please help. > > the code > > # code to produce the above chart > from reportlab.graphics.shapes import Drawing > from reportlab.lib import colors > from reportlab.graphics.charts.barcharts import VerticalBarChart > drawing = Drawing(400, 200) > data = [ > (13, 5, 20, 22, 37, 45, 19, 4), > (14, 6, 21, 23, 38, 46, 20, 5) > ] > bc = VerticalBarChart() > #bc.setFont('Helvetica', 30) > bc.x = 50 > bc.y = 50 > bc.height = 125 > bc.width = 300 > bc.data = data > bc.strokeColor = colors.black > bc.valueAxis.valueMin = 0 > bc.valueAxis.valueMax = 50 > bc.valueAxis.valueStep = 10 > bc.categoryAxis.labels.boxAnchor = 'ne' > bc.categoryAxis.labels.dx = 8 > bc.categoryAxis.labels.dy = -2 > bc.categoryAxis.labels.angle = 30 > bc.categoryAxis.categoryNames = ['Jan-99','Feb-99','Mar-99', > 'Apr-99','May-99','Jun-99','Jul-99','Aug-99'] > drawing.add(bc) > > > drawing.save(formats=['gif']) you need to down load the original pfb fonts for the standard 14 fonts and unpack them into reportlab/fonts. You can find them here http://www.reportlab.com/ftp/pfbfer.zip -- Robin Becker From carl at personnelware.com Mon Dec 29 12:28:57 2008 From: carl at personnelware.com (Carl Karsten) Date: Mon, 29 Dec 2008 11:28:57 -0600 Subject: [reportlab-users] stretching fonts Message-ID: <495908D9.2060706@personnelware.com> Is there a way to make a font, wider? or make a string take up x amount of space? the string is a constant (well, it will be "2009" for the next year...) and I need it to fill up an area that is about 1.5x the width it currently uses, without increasing the hight. and I don't want to just increase the spacing, because I like the look of the wider font. This may qualify as "that is changing the font, and so you should just use a different font." maybe. but I am trying to use a font that is pre-installed on ubuntu boxes. Carl K From p at ulmcnett.com Mon Dec 29 12:34:51 2008 From: p at ulmcnett.com (Paul McNett) Date: Mon, 29 Dec 2008 09:34:51 -0800 Subject: [reportlab-users] stretching fonts In-Reply-To: <495908D9.2060706@personnelware.com> References: <495908D9.2060706@personnelware.com> Message-ID: <49590A3B.6000608@ulmcnett.com> Carl Karsten wrote: > Is there a way to make a font, wider? or make a string take up x > amount of space? the string is a constant (well, it will be "2009" for > the next year...) and I need it to fill up an area that is about 1.5x > the width it currently uses, without increasing the hight. and I don't > want to just increase the spacing, because I like the look of the wider > font. > > This may qualify as "that is changing the font, and so you should just > use a different font." maybe. but I am trying to use a font that is > pre-installed on ubuntu boxes. Use PIL to draw the string to a bitmap, and then scale down the bitmap? Paul From timr at probo.com Mon Dec 29 13:18:09 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 29 Dec 2008 10:18:09 -0800 Subject: [reportlab-users] stretching fonts In-Reply-To: <495908D9.2060706@personnelware.com> References: <495908D9.2060706@personnelware.com> Message-ID: <49591461.5050900@probo.com> Carl Karsten wrote: > Is there a way to make a font, wider? or make a string take up x > amount of space? the string is a constant (well, it will be "2009" > for the next year...) and I need it to fill up an area that is about > 1.5x the width it currently uses, without increasing the hight. and I > don't want to just increase the spacing, because I like the look of > the wider font. > > This may qualify as "that is changing the font, and so you should just > use a different font." maybe. but I am trying to use a font that is > pre-installed on ubuntu boxes. This is easy. The canvas.scale method can scale isotropically (meaning different values in X and Y), and it applies to fonts. However, you need to remember that after you apply scale, ALL of the X and Y values get scaled, including the coordinates you supply to drawString. The easy way around this is to do something like this: canvas.saveState() canvas.translate( myX, myY ) # move origin to desired start of string canvas.scale( 1.5, 1.0 ) # scale by 150% in X direction only canvas.drawString( 0, 0, "2009" ) canvas.restoreState() -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From andy at reportlab.com Mon Dec 29 15:09:43 2008 From: andy at reportlab.com (Andy Robinson) Date: Mon, 29 Dec 2008 20:09:43 +0000 Subject: [reportlab-users] stretching fonts In-Reply-To: <49591461.5050900@probo.com> References: <495908D9.2060706@personnelware.com> <49591461.5050900@probo.com> Message-ID: <956003ae0812291209u784a78fbq24c359638b4655a6@mail.gmail.com> 2008/12/29 Tim Roberts : > Carl Karsten wrote: >> Is there a way to make a font, wider? or make a string take up x >> amount of space? the string is a constant (well, it will be "2009" >> for the next year...) and I need it to fill up an area that is about >> 1.5x the width it currently uses, without increasing the hight. and I >> don't want to just increase the spacing, because I like the look of >> the wider font. Instead of Canvas.drawString, you can create a TextObject which offers methods for adjusting the inter-character spacing. You could use PDFTextObject.setCharSpace or setWordSpace. You will need to call stringwidth yourself to work out the actual size, then add character or word spacing accordingly. Docstrings here... src/reportlab/pdfgen/textobject.py Examples of text object and stringwidth are in src/tests/test_pdfgen_general.py Hope this helps, - Andy From carl at personnelware.com Tue Dec 30 19:06:09 2008 From: carl at personnelware.com (Carl Karsten) Date: Tue, 30 Dec 2008 18:06:09 -0600 Subject: [reportlab-users] pdf417 barcodes Message-ID: <495AB771.6000708@personnelware.com> first I want to thank Tim and Andy for the font stretching tips. worked like a charm. (at least Paul didn't grumble when I asked him to implement it in dabo :) Now to pdf417 barcodes - I need em. http://two.pairlist.net/pipermail/reportlab-users/2006-July/005129.html says: "A colleague has pointed out that someone has already posted a PDF417 implementation to the list, so we will take a look at this and contact the author." What ever happened with this? I searched the lists, and all I could find was a mention of https://sourceforge.net/projects/pdf417encode/ here: http://two.pairlist.net/pipermail/reportlab-users/2006-January/004657.html Three is also: https://sourceforge.net/projects/pdf417lib/ Not sure what the differences are. Carl K From robin at reportlab.com Wed Dec 31 05:18:53 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 31 Dec 2008 10:18:53 +0000 Subject: [reportlab-users] pdf417 barcodes In-Reply-To: <495AB771.6000708@personnelware.com> References: <495AB771.6000708@personnelware.com> Message-ID: <495B470D.20705@chamonix.reportlab.co.uk> Carl Karsten wrote: > first I want to thank Tim and Andy for the font stretching tips. worked > like a charm. (at least Paul didn't grumble when I asked him to > implement it in dabo :) > > Now to pdf417 barcodes - I need em. > > http://two.pairlist.net/pipermail/reportlab-users/2006-July/005129.html > says: > "A colleague has pointed out that someone has already posted a PDF417 > implementation to the list, so we will take a look at this and contact > the author." > > What ever happened with this? > > I searched the lists, and all I could find was a mention of > https://sourceforge.net/projects/pdf417encode/ here: > http://two.pairlist.net/pipermail/reportlab-users/2006-January/004657.html > > Three is also: > https://sourceforge.net/projects/pdf417lib/ > > Not sure what the differences are. > > Carl K As the person who did most of the work/extensions after Ty Sarna contributed the original work I can tell you we have not implemented 417. I did look at the sf project, but the license is GPL and we could not use it directly as our license is more liberal. I know this thing can produce postscript so it is potentially usable with a translation layer. -- Robin Becker From andy at reportlab.com Wed Dec 31 06:11:57 2008 From: andy at reportlab.com (Andy Robinson) Date: Wed, 31 Dec 2008 11:11:57 +0000 Subject: [reportlab-users] pdf417 barcodes In-Reply-To: <495B470D.20705@chamonix.reportlab.co.uk> References: <495AB771.6000708@personnelware.com> <495B470D.20705@chamonix.reportlab.co.uk> Message-ID: <956003ae0812310311p42355204h491390fb0f8deea5@mail.gmail.com> 2008/12/31 Robin Becker : > As the person who did most of the work/extensions after Ty Sarna contributed > the original work I can tell you we have not implemented 417. I did look at > the sf project, but the license is GPL and we could not use it directly as > our license is more liberal. I know this thing can produce postscript so it > is potentially usable with a translation layer. Also, we only have a one-dimensional barcode reader. From ReportLab's end, we'd be happy to implement this (and DataMatrix too) if a customer is willing to pay the time costs, which are probably a couple of man-weeks. Various enterprise customers have enquired in the past but nobody has committed. Let us know if your employers need this badly enough ;-) -- Andy From carl at personnelware.com Wed Dec 31 08:19:10 2008 From: carl at personnelware.com (Carl Karsten) Date: Wed, 31 Dec 2008 07:19:10 -0600 Subject: [reportlab-users] pdf417 barcodes In-Reply-To: <956003ae0812310311p42355204h491390fb0f8deea5@mail.gmail.com> References: <495AB771.6000708@personnelware.com> <495B470D.20705@chamonix.reportlab.co.uk> <956003ae0812310311p42355204h491390fb0f8deea5@mail.gmail.com> Message-ID: <495B714E.30705@personnelware.com> Andy Robinson wrote: > 2008/12/31 Robin Becker : >> As the person who did most of the work/extensions after Ty Sarna contributed >> the original work I can tell you we have not implemented 417. I did look at >> the sf project, but the license is GPL and we could not use it directly as >> our license is more liberal. I know this thing can produce postscript so it >> is potentially usable with a translation layer. for the record, http://sourceforge.net/projects/pdf417encode/ is LGPL http://sourceforge.net/projects/pdf417.lib is LGPL or MPL 1.1 http://www.reportlab.org/devfaq.html is BSD I have no idea what MPL is - does it play nice with BSD? Could the authors release under BSD? > > > Also, we only have a one-dimensional barcode reader. From ReportLab's > end, we'd be happy to implement this (and DataMatrix too) if a > customer is willing to pay the time costs, which are probably a couple > of man-weeks. Various enterprise customers have enquired in the past > but nobody has committed. Let us know if your employers need this > badly enough ;-) Well, my employer is PyCon - last year we got inquiries if the attendee name tags could be scanned. scanner rental is around $300, I will be surprised if we get 10 rentals. so even if we mark up the rental 100%, that only gives us 3k to work with. Any interest in a booth at PyCon? Carl K From andy at reportlab.com Wed Dec 31 08:46:51 2008 From: andy at reportlab.com (Andy Robinson) Date: Wed, 31 Dec 2008 13:46:51 +0000 Subject: [reportlab-users] pdf417 barcodes In-Reply-To: <495B714E.30705@personnelware.com> References: <495AB771.6000708@personnelware.com> <495B470D.20705@chamonix.reportlab.co.uk> <956003ae0812310311p42355204h491390fb0f8deea5@mail.gmail.com> <495B714E.30705@personnelware.com> Message-ID: <956003ae0812310546m608d6431t3a2dd02154296e2d@mail.gmail.com> 2008/12/31 Carl Karsten : > Andy Robinson wrote: > for the record, ... > Could the authors release under BSD? If we wanted to include their code in our core distro, then we'd at least want their permission. But that may be premature. If someone makes a wrapper or adaptor around another library so that it can be used within reportlab, I'd suggest the wrapper is released independently and we just tell people it's there. > Well, my employer is PyCon - last year we got inquiries if the attendee name > tags could be scanned. scanner rental is around $300, I will be surprised > if we get 10 rentals. so even if we mark up the rental 100%, that only > gives us 3k to work with. Any interest in a booth at PyCon? Ah well - if you were an insurance giant trying to save a million next year we might have a case, but there is a much more pragmatic route. I suggest you just use one of those libraries to make a bitmap barcode for each person's badge, and then include that (as a bitmap) in the PyCon badges. It's a bit less elegant but I hope only a few hours of work. - Andy From gherman at darwin.in-berlin.de Wed Dec 31 13:05:01 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Wed, 31 Dec 2008 19:05:01 +0100 Subject: [reportlab-users] pdf417 barcodes In-Reply-To: <495B470D.20705@chamonix.reportlab.co.uk> References: <495AB771.6000708@personnelware.com> <495B470D.20705@chamonix.reportlab.co.uk> Message-ID: <3C08AF0D-2721-4A06-B795-640362C6A694@darwin.in-berlin.de> Carl Karsten: > Andy Robinson: >> > >> Also, we only have a one-dimensional barcode reader. From >> ReportLab's >> end, we'd be happy to implement this (and DataMatrix too) if a >> customer is willing to pay the time costs, which are probably a >> couple >> of man-weeks. Various enterprise customers have enquired in the past >> but nobody has committed. Let us know if your employers need this >> badly enough ;-) > > Well, my employer is PyCon - last year we got inquiries if the > attendee name tags could be scanned. scanner rental is around $300, > I will be surprised if we get 10 rentals. so even if we mark up the > rental 100%, that only gives us 3k to work with. Any interest in a > booth at PyCon? I've done something like that for EuroPython 2008, or let's say I offered doing it, but people said for about 200 people the scanning wouldn't make much sense, which is mostly true. For PyCon US and the general fear level in the US that might be different. Here's a sample with the (not so meaningful) QR codes generated by an online service and added as bitmaps to the badges PDF file (in the end I made them much simpler): http://python.net/~gherman/tmp/badges.pdf Robin Becker: > As the person who did most of the work/extensions after Ty Sarna > contributed the original work I can tell you we have not implemented > 417. I did look at the sf project, but the license is GPL and we > could not use it directly as our license is more liberal. [...] Many people would point out that GPL is actually more liberal than BSD or anything else... but making that point here is probably pointless. ;-) Regards, Dinu From carl at personnelware.com Wed Dec 31 13:40:55 2008 From: carl at personnelware.com (Carl Karsten) Date: Wed, 31 Dec 2008 12:40:55 -0600 Subject: [reportlab-users] pdf417 barcodes In-Reply-To: <3C08AF0D-2721-4A06-B795-640362C6A694@darwin.in-berlin.de> References: <495AB771.6000708@personnelware.com> <495B470D.20705@chamonix.reportlab.co.uk> <3C08AF0D-2721-4A06-B795-640362C6A694@darwin.in-berlin.de> Message-ID: <495BBCB7.2040006@personnelware.com> Dinu Gherman wrote: > Carl Karsten: > >> Andy Robinson: >>> >> >>> Also, we only have a one-dimensional barcode reader. From ReportLab's >>> end, we'd be happy to implement this (and DataMatrix too) if a >>> customer is willing to pay the time costs, which are probably a couple >>> of man-weeks. Various enterprise customers have enquired in the past >>> but nobody has committed. Let us know if your employers need this >>> badly enough ;-) >> >> Well, my employer is PyCon - last year we got inquiries if the >> attendee name tags could be scanned. scanner rental is around $300, I >> will be surprised if we get 10 rentals. so even if we mark up the >> rental 100%, that only gives us 3k to work with. Any interest in a >> booth at PyCon? > > I've done something like that for EuroPython 2008, or let's > say I offered doing it, but people said for about 200 people > the scanning wouldn't make much sense, which is mostly true. > How were you going to implement it? I am trying out https://sourceforge.net/projects/pdf417encode - I was able to generate a .eps from the command line. I am hoping to get some python bindings so that I don't have to mess with disk files. > For PyCon US and the general fear level in the US that might > be different. Here's a sample with the (not so meaningful) > QR codes generated by an online service and added as bitmaps > to the badges PDF file (in the end I made them much simpler): > > http://python.net/~gherman/tmp/badges.pdf neat. Can you post the code? Carl K From erik at erikwickstrom.com Wed Dec 31 20:52:55 2008 From: erik at erikwickstrom.com (Erik Wickstrom) Date: Wed, 31 Dec 2008 17:52:55 -0800 Subject: [reportlab-users] Generating PNGs/JPGs instead of PDFs? Message-ID: <3d381e170812311752v341d646w70cef28b78a4b204@mail.gmail.com> Hi all, First, Happy New Year! I need to output some reports as PNGs or JPGs in addition to PDFs. Can ReportLab render to these other formats? If not, any suggestions on how I can do this? Thanks! Erik -------------- next part -------------- An HTML attachment was scrubbed... URL: From carl at personnelware.com Wed Dec 31 21:09:59 2008 From: carl at personnelware.com (Carl Karsten) Date: Wed, 31 Dec 2008 20:09:59 -0600 Subject: [reportlab-users] Generating PNGs/JPGs instead of PDFs? In-Reply-To: <3d381e170812311752v341d646w70cef28b78a4b204@mail.gmail.com> References: <3d381e170812311752v341d646w70cef28b78a4b204@mail.gmail.com> Message-ID: <495C25F7.6040003@personnelware.com> Erik Wickstrom wrote: > Hi all, > > First, Happy New Year! > > I need to output some reports as PNGs or JPGs in addition to PDFs. Can > ReportLab render to these other formats? Last I checked, no. > If not, any suggestions on how I > can do this? I have been fighting this for about 2 years. use reportlab to generate the pdf, then convert that to an image. it's easy to do at the command prompt, but trying to do it reliably in python gets tedious. PythonMagickWand is python bindings for ImageMagick. http://www.procoders.net/?p=121 last year's version caused segfaults, so I went with shelling out to ghostscript: look at line 42 badge_png(ds): http://bazaar.launchpad.net/~carl-personnelware/web2conf/badges/annotate/head%3A/controllers/badge.py then look at line 82 def badge_png2(ds). that would be really nice if it wasn't for https://bugs.edge.launchpad.net/poppler-python/+bug/312462 TypeError: document_new_from_data() argument 1 must be string without null bytes, not str Carl K From aaron.barlow at gmail.com Wed Dec 31 21:55:25 2008 From: aaron.barlow at gmail.com (Aaron Barlow) Date: Wed, 31 Dec 2008 19:55:25 -0700 Subject: [reportlab-users] Generating PNGs/JPGs instead of PDFs? In-Reply-To: <3d381e170812311752v341d646w70cef28b78a4b204@mail.gmail.com> References: <3d381e170812311752v341d646w70cef28b78a4b204@mail.gmail.com> Message-ID: Erik I use imagemagick to convert a PDF cover page generated via reportlab to a PNG thumbnail as a preview. Seems to work fairly painlessly. However, I thought you could pass in an output type to the canvas.save method or even the build method of the Document Template to set the output to png or JPEG. You have to have PIL installed for this to work. I don't have the manual with me but I'm pretty sure there's a section in there about that. Hope this helps. -- Aaron Barlow On Dec 31, 2008, at 6:52 PM, "Erik Wickstrom" wrote: > Hi all, > > First, Happy New Year! > > I need to output some reports as PNGs or JPGs in addition to PDFs. > Can ReportLab render to these other formats? If not, any > suggestions on how I can do this? > > Thanks! > Erik > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users