From Jason.Brower at kone.com Thu Oct 1 00:34:54 2009 From: Jason.Brower at kone.com (Brower Jason) Date: Thu, 1 Oct 2009 06:34:54 +0200 Subject: [reportlab-users] Support for stacked bar charts... Message-ID: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> I am hoping to move away from the java iReport stuff to a more enjoyable language, python. :D Our current reports use a stacked bar chart. Has reportlab this feature yet? It was mentioning that it was in the works in the documentation. In the mean time I will be using png's that I have created by hand. Regards, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jason.Brower at kone.com Thu Oct 1 00:45:00 2009 From: Jason.Brower at kone.com (Brower Jason) Date: Thu, 1 Oct 2009 06:45:00 +0200 Subject: [reportlab-users] How to properly get alignments of flowables right... Message-ID: <7BEADC998EA85041A0170E2F5F726D2F01BF53B0@EUDEXC01.KONENET.COM> I am trying to get my first flowable working in my pdf. It works, but I want to have it start at a certain upper left position. 5*cm x 5*cm Is there a way to designate that? It seems to always want to draw from the lower left. I have no problem with that, it's just that when I create the text in the box the starting point moves UP and I can't figure out how to logically place this object. Best Regards, Jason Brower -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at reportlab.com Thu Oct 1 04:16:21 2009 From: andy at reportlab.com (Andy Robinson) Date: Thu, 1 Oct 2009 09:16:21 +0100 Subject: [reportlab-users] Support for stacked bar charts... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> Message-ID: <956003ae0910010116q76369104re1644748bdd17df0@mail.gmail.com> 2009/10/1 Brower Jason : > I am hoping to move away from the java iReport stuff to a more enjoyable > language, python. :D? Our current reports use a stacked bar chart. ?Has > reportlab this feature yet?? It was mentioning that it was in the works in > the documentation.? In the mean time I will be using png?s that I have > created by hand. We've had stacked bar charts for about 7 years! I have just seen the offending docstring in the top of reportlab/graphics/barcharts.py and fixed it. I think what's misleading is that this is a property of the axis, not the chart. You need to set something like... myDrawing.chart.categoryAxis.style = 'stacked' The definition of that property is as follows....(in axes.py) style = AttrMapValue(OneOf('parallel','stacked','parallel_3d'),"How common category bars are plotted"), Best Regards, Andy Robinson From andy at reportlab.com Thu Oct 1 04:16:21 2009 From: andy at reportlab.com (Andy Robinson) Date: Thu, 1 Oct 2009 09:16:21 +0100 Subject: [reportlab-users] Support for stacked bar charts... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> Message-ID: <956003ae0910010116q76369104re1644748bdd17df0@mail.gmail.com> 2009/10/1 Brower Jason : > I am hoping to move away from the java iReport stuff to a more enjoyable > language, python. :D? Our current reports use a stacked bar chart. ?Has > reportlab this feature yet?? It was mentioning that it was in the works in > the documentation.? In the mean time I will be using png?s that I have > created by hand. We've had stacked bar charts for about 7 years! I have just seen the offending docstring in the top of reportlab/graphics/barcharts.py and fixed it. I think what's misleading is that this is a property of the axis, not the chart. You need to set something like... myDrawing.chart.categoryAxis.style = 'stacked' The definition of that property is as follows....(in axes.py) style = AttrMapValue(OneOf('parallel','stacked','parallel_3d'),"How common category bars are plotted"), Best Regards, Andy Robinson From jarimatti.valkonen at protacon.com Thu Oct 1 04:22:19 2009 From: jarimatti.valkonen at protacon.com (Jarimatti Valkonen) Date: Thu, 01 Oct 2009 11:22:19 +0300 Subject: [reportlab-users] Support for stacked bar charts... In-Reply-To: <956003ae0910010116q76369104re1644748bdd17df0@mail.gmail.com> References: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> <956003ae0910010116q76369104re1644748bdd17df0@mail.gmail.com> Message-ID: <4AC466BB.2040202@protacon.com> Andy Robinson wrote: > > You need to set something like... > myDrawing.chart.categoryAxis.style = 'stacked' > > The definition of that property is as follows....(in axes.py) > style = AttrMapValue(OneOf('parallel','stacked','parallel_3d'),"How > common category bars are plotted"), Does this also work for LineCharts? I must do an area plot, but I'd like to use the chart module for it as all of my other plots are charts. Best regards, Jarimatti Valkonen -- Jarimatti Valkonen Protacon Engineering Oy Tel: +358 (0)10 3472 667 Fax: +358 (0)10 3472 601 Email: jarimatti.valkonen at protacon.com www.protacon.com From robin at reportlab.com Thu Oct 1 04:40:05 2009 From: robin at reportlab.com (Robin Becker) Date: Thu, 01 Oct 2009 09:40:05 +0100 Subject: [reportlab-users] How to properly get alignments of flowables right... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF53B0@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01BF53B0@EUDEXC01.KONENET.COM> Message-ID: <4AC46AE5.7010506@chamonix.reportlab.co.uk> Brower Jason wrote: > I am trying to get my first flowable working in my pdf. > > It works, but I want to have it start at a certain upper left position. > 5*cm x 5*cm > > Is there a way to designate that? It seems to always want to draw from > the lower left. I have no problem with that, it's just that when I > create the text in the box the starting point moves UP and I can't > figure out how to logically place this object. > > Best Regards, > > Jason Brower Although Drawings are flowables they were originally intended as stand alone objects ie create a single bitmap, pdf, eps or svg image etc etc. If you intend to use the flowable interface then either you add the flowable to a platypus story or you need to use the drawOn method. So if D is your drawing you should do something like D.drawOn(canv,x,y) where canv is your pdf canvas and x and y are the coordinates with x measured from left edge of the user space and y from the bottom. -- Robin Becker From Jason.Brower at kone.com Thu Oct 1 04:56:27 2009 From: Jason.Brower at kone.com (Brower Jason) Date: Thu, 1 Oct 2009 10:56:27 +0200 Subject: [reportlab-users] How to properly get alignments of flowables right... In-Reply-To: <4AC46AE5.7010506@chamonix.reportlab.co.uk> Message-ID: <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> I felt I was doing something similar now. --- salesman_comments = "This is something called lorem ipsom text.
It is used as a filler text. Lorem ipsum dolor sit amet, consectetur adipisicing..." style = getSampleStyleSheet() P=Paragraph(salesman_comments,style["Normal"]) P.wrap(140, 800) P.drawOn(pdf,6.1*cm,4.5*cm) pdf.showPage() pdf.save() --- But it looks like I have to make adjustments from the bottom left corner of the object. It doesn't seem logical that way. Is there something I am missing about doing zero point of the object at the top left of itself? Otherwise as my dynamic text gets longer it pulls the top higher and higher. Regards, Jason -----Original Message----- From: reportlab-users-bounces at lists2.reportlab.com [mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of Robin Becker Sent: 01/10/2009 11:40 To: Support list for users of Reportlab software Subject: Re: [reportlab-users] How to properly get alignments of flowables right... Brower Jason wrote: > I am trying to get my first flowable working in my pdf. > > It works, but I want to have it start at a certain upper left position. > 5*cm x 5*cm > > Is there a way to designate that? It seems to always want to draw from > the lower left. I have no problem with that, it's just that when I > create the text in the box the starting point moves UP and I can't > figure out how to logically place this object. > > Best Regards, > > Jason Brower Although Drawings are flowables they were originally intended as stand alone objects ie create a single bitmap, pdf, eps or svg image etc etc. If you intend to use the flowable interface then either you add the flowable to a platypus story or you need to use the drawOn method. So if D is your drawing you should do something like D.drawOn(canv,x,y) where canv is your pdf canvas and x and y are the coordinates with x measured from left edge of the user space and y from the bottom. -- Robin Becker _______________________________________________ reportlab-users mailing list reportlab-users at lists2.reportlab.com http://two.pairlist.net/mailman/listinfo/reportlab-users From andy at reportlab.com Thu Oct 1 05:24:09 2009 From: andy at reportlab.com (Andy Robinson) Date: Thu, 1 Oct 2009 10:24:09 +0100 Subject: [reportlab-users] How to properly get alignments of flowables right... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> References: <4AC46AE5.7010506@chamonix.reportlab.co.uk> <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> Message-ID: <956003ae0910010224l1705da0bwd7fbaf0e172a0783@mail.gmail.com> 2009/10/1 Brower Jason : > Otherwise as my dynamic text gets longer it pulls the top higher and > higher. > Regards, > Jason Most people us Paragraphs within the Platypus framework where you have more than one page (if needed) and it handles the downwards flow for you. Please review that chapter of the user guide and the examples beginning with tests/test_platypus_*.py If you just want a few flowing paragraphs on a mostly-statically-drawn page, you can create a Frame object, add content using addFromList, and draw that, and it will work top-down. Best Regards, Andy Robinson From robin at reportlab.com Thu Oct 1 05:35:36 2009 From: robin at reportlab.com (Robin Becker) Date: Thu, 01 Oct 2009 10:35:36 +0100 Subject: [reportlab-users] How to properly get alignments of flowables right... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> Message-ID: <4AC477E8.7000104@chamonix.reportlab.co.uk> Brower Jason wrote: > I felt I was doing something similar now. > --- > salesman_comments = "This is something called lorem ipsom text.
It > is used as a filler text. Lorem ipsum dolor sit amet, consectetur > adipisicing..." > style = getSampleStyleSheet() > P=Paragraph(salesman_comments,style["Normal"]) > P.wrap(140, 800) > P.drawOn(pdf,6.1*cm,4.5*cm) > pdf.showPage() > pdf.save() > --- > But it looks like I have to make adjustments from the bottom left corner > of the object. It doesn't seem logical that way. Is there something I > am missing about doing zero point of the object at the top left of > itself? > Otherwise as my dynamic text gets longer it pulls the top higher and > higher. > Regards, > Jason >....... the above looks right, but bottum up is our standard way of doing things (like in maths the origin is lower left). We measure from the ground up and not from an infinite distance above etc etc etc. Frame objects position flowables starting at the top of their area and gradually reduce the position at which the next flowable should be added. To position your paragraph's top left at a specified point x,y you need to do w,h = P.wrap(140,800) P.drawOn(pdf,x,y-h) of course y here is from the bottom of the page, but if pagesize = pw, ph then it's trivial to do stuff like P.drawOn(pdf,1.5*cm,ph-1.5*cm-h) ie position the top left of the paragraph 1.5cm from the left and top of the page. -- Robin Becker From damian at reportlab.com Thu Oct 1 08:36:54 2009 From: damian at reportlab.com (Damian Moore) Date: Thu, 01 Oct 2009 13:36:54 +0100 Subject: [reportlab-users] Support for stacked bar charts... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01BF53AC@EUDEXC01.KONENET.COM> Message-ID: <1254400614.4138.18.camel@fuji> On Thu, 2009-10-01 at 06:34 +0200, Brower Jason wrote: > I am hoping to move away from the java iReport stuff to a more > enjoyable language, python. :D Our current reports use a stacked bar > chart. Has reportlab this feature yet? It was mentioning that it was > in the works in the documentation. In the mean time I will be using > png?s that I have created by hand. I have just commited some additional text and example graph to the documentation. If you update reportlab SVN and re-generate the documentation you will see the example on page 102. Regards, Damian -- Damian Moore Software Developer ReportLab Europe Ltd. Media House 3 Palmerston Road London SW19 1PG Tel +44-20-8544-8049 From timr at probo.com Thu Oct 1 14:56:30 2009 From: timr at probo.com (Tim Roberts) Date: Thu, 01 Oct 2009 11:56:30 -0700 Subject: [reportlab-users] How to properly get alignments of flowables right... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01BF5672@EUDEXC01.KONENET.COM> Message-ID: <4AC4FB5E.5050303@probo.com> Brower Jason wrote: > ... > But it looks like I have to make adjustments from the bottom left corner > of the object. It doesn't seem logical that way. Is there something I > am missing about doing zero point of the object at the top left of > itself? > Well, there's a historical basis for this. Reportlab generates PDF, which is a dialect of Postscript. Postscript uses the Cartesian coordinate model for its axes. So, in order to have the whole page be in quadrant 1 where X and Y are both positive, that puts the origin at the lower left. You can use scale (by 1 and -1) and transform to turn it into a more traditional printing model, if you're careful. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Jason.Brower at kone.com Fri Oct 2 00:38:32 2009 From: Jason.Brower at kone.com (Brower Jason) Date: Fri, 2 Oct 2009 06:38:32 +0200 Subject: [reportlab-users] Return a file object rather than save a file... Message-ID: <7BEADC998EA85041A0170E2F5F726D2F01C79F94@EUDEXC01.KONENET.COM> After a look through the main documentation I found section 2.2 and it shoulds how to open a file like object and insert a pdf into that. But I would like to have just the file object itself to return as a downloadable stream. (I am using web2py) --- Regards, Jason Brower -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at reportlab.com Fri Oct 2 04:03:32 2009 From: andy at reportlab.com (Andy Robinson) Date: Fri, 2 Oct 2009 09:03:32 +0100 Subject: [reportlab-users] Return a file object rather than save a file... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01C79F94@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01C79F94@EUDEXC01.KONENET.COM> Message-ID: <956003ae0910020103n7ee68c82ub346316f5fab5728@mail.gmail.com> 2009/10/2 Brower Jason : > After a look through the main documentation I found section 2.2 and it > shoulds how to open a file like object and insert a pdf into that. ?But I > would like to have just the file object itself to return as a downloadable > stream. (I am using web2py) I am not familiar with web2py, but if there is some kind of file-like response object you can write to, then pass that to the Canvas constructor. Alternatively, create a StringIO object (which is file-like) and use that. Best Regards, Andy Robinson From Jason.Brower at kone.com Fri Oct 2 05:39:26 2009 From: Jason.Brower at kone.com (Brower Jason) Date: Fri, 2 Oct 2009 11:39:26 +0200 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <956003ae0910020103n7ee68c82ub346316f5fab5728@mail.gmail.com> Message-ID: <7BEADC998EA85041A0170E2F5F726D2F01C7A29E@EUDEXC01.KONENET.COM> Don't worry about web2py. Unless you want to use a cool web framework. :D I can return the object as a streamable item. And the web2py part is working properly. But I don't think I am doing the pdf generation properly. Here are the important bits... def create_report(): from reportlab.pdfgen.canvas import Canvas from reportlab.lib.pagesizes import A4, landscape from reportlab.lib.units import cm, mm, pica from reportlab.platypus import Paragraph, SimpleDocTemplate, Spacer from reportlab.lib.styles import getSampleStyleSheet from reportlab.graphics.shapes import Drawing from reportlab.graphics.charts.barcharts import VerticalBarChart import StringIO output = StringIO.StringIO() #My programming bits... pdf.showPage() pdf.save() return response.stream(output,chunk_size=64*1024) Somehow I need to make the save work with the output and I am am just to know with this file object stuff to know what to do. Regards, Jason Brower -----Original Message----- From: reportlab-users-bounces at lists2.reportlab.com [mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of Andy Robinson Sent: 02/10/2009 11:04 To: For users of Reportlab open source software Subject: Re: [reportlab-users] Return a file object rather than save afile... 2009/10/2 Brower Jason : > After a look through the main documentation I found section 2.2 and it > shoulds how to open a file like object and insert a pdf into that. ?But I > would like to have just the file object itself to return as a downloadable > stream. (I am using web2py) I am not familiar with web2py, but if there is some kind of file-like response object you can write to, then pass that to the Canvas constructor. Alternatively, create a StringIO object (which is file-like) and use that. Best Regards, Andy Robinson _______________________________________________ reportlab-users mailing list reportlab-users at lists2.reportlab.com http://two.pairlist.net/mailman/listinfo/reportlab-users From andy at reportlab.com Fri Oct 2 07:43:37 2009 From: andy at reportlab.com (Andy Robinson) Date: Fri, 2 Oct 2009 12:43:37 +0100 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01C7A29E@EUDEXC01.KONENET.COM> References: <956003ae0910020103n7ee68c82ub346316f5fab5728@mail.gmail.com> <7BEADC998EA85041A0170E2F5F726D2F01C7A29E@EUDEXC01.KONENET.COM> Message-ID: <956003ae0910020443m39ec650ara5967954c41932de@mail.gmail.com> 2009/10/2 Brower Jason : > Somehow I need to make the save work with the output and I am am just to know with this file object stuff to know what to do. Here's how to save your PDF as a string in memory. buf = StringIO.StringIO() c = Canvas(buf) #do your drawing here c.save() #PDF file is written into the buffer at this point #extract contents as a byte string buf.reset() rawPdfFileContent = buf.read() You then pass this to the response. If it was Django, I could write to the response object (which is file-like), so I could do this and cut out the StringIO... response.setContentType('application/pdf') c = Canvas(response) .... c.save() HTH....Andy From ralsina at netmanagers.com.ar Fri Oct 2 08:10:48 2009 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Fri, 2 Oct 2009 09:10:48 -0300 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <956003ae0910020443m39ec650ara5967954c41932de@mail.gmail.com> References: <956003ae0910020103n7ee68c82ub346316f5fab5728@mail.gmail.com> <7BEADC998EA85041A0170E2F5F726D2F01C7A29E@EUDEXC01.KONENET.COM> <956003ae0910020443m39ec650ara5967954c41932de@mail.gmail.com> Message-ID: <200910020910.48288.ralsina@netmanagers.com.ar> On Friday 02 October 2009 08:43:37 Andy Robinson wrote: > 2009/10/2 Brower Jason : > > Somehow I need to make the save work with the output and I am am just to > > know with this file object stuff to know what to do. > > Here's how to save your PDF as a string in memory. > > buf = StringIO.StringIO() > > c = Canvas(buf) > > > #do your drawing here > > > c.save() #PDF file is written into the buffer at this point > > > #extract contents as a byte string > buf.reset() > rawPdfFileContent = buf.read() > > You then pass this to the response. If it was Django, I could write > to the response object (which is file-like), so I could do this and > cut out the StringIO... > > response.setContentType('application/pdf') > c = Canvas(response) > .... > c.save() Isn't this faster? buf = cStringIO.StringIO() c=Canvas(buf) #do your drawing c.save() rawPdfFileContent = buf.getvalue() -- ("\''/").__..-''"`-. . Roberto Alsina `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) From andy at reportlab.com Fri Oct 2 08:15:06 2009 From: andy at reportlab.com (Andy Robinson) Date: Fri, 2 Oct 2009 13:15:06 +0100 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <200910020910.48288.ralsina@netmanagers.com.ar> References: <956003ae0910020103n7ee68c82ub346316f5fab5728@mail.gmail.com> <7BEADC998EA85041A0170E2F5F726D2F01C7A29E@EUDEXC01.KONENET.COM> <956003ae0910020443m39ec650ara5967954c41932de@mail.gmail.com> <200910020910.48288.ralsina@netmanagers.com.ar> Message-ID: <956003ae0910020515w4c9da32fo7e2fb0a059b5a166@mail.gmail.com> 2009/10/2 Roberto Alsina : > Isn't this faster? > buf = cStringIO.StringIO() > c=Canvas(buf) > #do your drawing > c.save() > rawPdfFileContent = buf.getvalue() It's certainly one line shorter and thus more elegant - thanks... - Andy From ralsina at netmanagers.com.ar Fri Oct 2 08:15:23 2009 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Fri, 2 Oct 2009 09:15:23 -0300 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <956003ae0910020515w4c9da32fo7e2fb0a059b5a166@mail.gmail.com> References: <956003ae0910020103n7ee68c82ub346316f5fab5728@mail.gmail.com> <200910020910.48288.ralsina@netmanagers.com.ar> <956003ae0910020515w4c9da32fo7e2fb0a059b5a166@mail.gmail.com> Message-ID: <200910020915.23845.ralsina@netmanagers.com.ar> On Friday 02 October 2009 09:15:06 Andy Robinson wrote: > 2009/10/2 Roberto Alsina : > > Isn't this faster? > > buf = cStringIO.StringIO() > > c=Canvas(buf) > > #do your drawing > > c.save() > > rawPdfFileContent = buf.getvalue() > > It's certainly one line shorter and thus more elegant - thanks... Also cStringIO is much, much faster when it works. It's not a perfect StringIO replacement, but it works for reportlab. -- ("\''/").__..-''"`-. . Roberto Alsina `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) From carl at personnelware.com Fri Oct 2 08:42:09 2009 From: carl at personnelware.com (Carl Karsten) Date: Fri, 2 Oct 2009 07:42:09 -0500 Subject: [reportlab-users] Return a file object rather than save a file... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01C79F94@EUDEXC01.KONENET.COM> References: <7BEADC998EA85041A0170E2F5F726D2F01C79F94@EUDEXC01.KONENET.COM> Message-ID: <549053140910020542y7ce3c9a9wfd65e32ba14203f4@mail.gmail.com> On Thu, Oct 1, 2009 at 11:38 PM, Brower Jason wrote: > After a look through the main documentation I found section 2.2 and it > shoulds how to open a file like object and insert a pdf into that. ?But I > would like to have just the file object itself to return as a downloadable > stream. (I am using web2py) > I wrote code like that a year ago. It is here: http://bazaar.launchpad.net/~mdipierro/web2conf/devel but right now I get "Sorry, there was a problem connecting to the Launchpad server. " so I can't find the exact place. Look for the dabo report writer stuff. That is a reportlab wrapper, but the parts you want is the same. -- Carl K From vasudevram at gmail.com Sun Oct 4 14:19:28 2009 From: vasudevram at gmail.com (Vasudev Ram) Date: Sun, 4 Oct 2009 23:49:28 +0530 Subject: [reportlab-users] ANNOUNCE: Client-server PDF creation with xtopdf and ReportLab and Python and XML-RPC Message-ID: Hi list, I'm happy to announce the release of v1.0 of PDFXMLRPC, a client-server application that lets users create PDF content from text, over the Internet or their intranet, using Reportlab, xtopdf, XML-RPC and Python. Usage example for PDFXMLRPC: You can run the server on one computer which is connected to the Internet. You can run the client on another computer which is connected to the Internet. When you run the client, it sends text content to the server. The server then converts this text to PDF, and sends that PDF content back to the client over the Internet. The client then writes that PDF content to a local PDF file, which the user can then open / print / etc. (But also see the part about callability (i.e., programmability) of both the client and server below.) The announcement of PDFXMLRPC is here on my blog: http://jugad2.blogspot.com/2009/10/client-server-pdf-creation-with-xtopdf.html That blog post has a link to a zip file that you can download, which contains the PDFXMLRPC package. The zip file contains the following files: - PDFXMLRPCServer.py - the server - PDFXMLRPCClient.py - the client - README.txt - documentation of the prerequisites needed (*), the links to get them from, the steps to install PDFXMLRPC, and steps to run it (the server and the client). - License.txt - the license file (PDFXMLRPC is released under the BSD License) (*) The prerequisites are: - xtopdf v1.0, Reportlab v1.x and Python 2.x or higher for the server - Python 2.x or higher for the client (XML-RPC is required for both the client and the server, but since it is included in the standard Python library, I don't treat it as a separate prerequisite). Although both the server and the client programs contain main() functions, and therefore both can be run as standalone programs, they are also both callable. There is one "top-level" class in each of the server and the client - PDFXMLRPCServer and PDFXMLRPCClient respectively. The main functions in the server and client, act as examples of how to call those classes. Since the classes are callable, you can incorporate the functionality of the server and the client, into your own larger programs, to get the functionality of client/server PDF creation over the Net, in your own applications. I welcome any feedback on this software. Finally, thanks a lot to the Reportlab team and all the users who've helped improve it, for their work. Thanks, Vasudev Ram --- Dancing Bison Enterprises Biz: www.dancingbison.com Google Profile: http://is.gd/tWe3 Blog: jugad2.blogspot.com xtopdf: fast and easy PDF creation: www.dancingbison.com/products.html Twitter: @vasudevram -------------- next part -------------- An HTML attachment was scrubbed... URL: From carl at personnelware.com Sun Oct 4 14:54:53 2009 From: carl at personnelware.com (Carl Karsten) Date: Sun, 4 Oct 2009 13:54:53 -0500 Subject: [reportlab-users] ANNOUNCE: Client-server PDF creation with xtopdf and ReportLab and Python and XML-RPC In-Reply-To: References: Message-ID: <549053140910041154ua207052h2e55cac77ccc79ae@mail.gmail.com> On Sun, Oct 4, 2009 at 1:19 PM, Vasudev Ram wrote: > > Hi list, > > I'm happy to announce the release of v1.0 of PDFXMLRPC, a client-server > application that lets users create PDF content from text, over the Internet > or their intranet, using Reportlab, xtopdf, XML-RPC and Python. > > Usage example for PDFXMLRPC: > > You can run the server on one computer which is connected to the Internet. > You can run the client on another computer which is connected to the > Internet. > > When you run the client, it sends text content to the server. The server > then converts this text to PDF, and sends that PDF content back to the > client over the Internet. The client then writes that PDF content to a local > PDF file, which the user can then open / print / etc. > (But also see the part about callability (i.e., programmability) of both the > client and server below.) > > The announcement of PDFXMLRPC is here on my blog: > > http://jugad2.blogspot.com/2009/10/client-server-pdf-creation-with-xtopdf.html > > That blog post has a link to a zip file that you can download, which > contains the PDFXMLRPC package. > > The zip file contains the following files: > > - PDFXMLRPCServer.py - the server > - PDFXMLRPCClient.py - the client > - README.txt - documentation of the prerequisites needed (*), the links to > get them from, the steps to install PDFXMLRPC, and steps to run it (the > server and the client). > - License.txt - the license file (PDFXMLRPC is released under the BSD > License) > (*) The prerequisites are: > > - xtopdf v1.0, Reportlab v1.x and Python 2.x or higher for the server > > -? Python 2.x or higher for the client > > (XML-RPC is required for both the client and the server, but since it is > included in the standard Python library, I don't treat it as a separate > prerequisite). > > Although both the server and the client programs contain main() functions, > and therefore both can be run as standalone programs, they are also both > callable. There is one "top-level" class in each of the server and the > client - PDFXMLRPCServer and PDFXMLRPCClient respectively. > > The main functions in the server and client, act as examples of how to call > those classes. > > Since the classes are callable, you can incorporate the functionality of the > server and the client, into your own larger programs, to get the > functionality of client/server PDF creation over the Net, in your own > applications. > > I welcome any feedback on this software. > > Finally, thanks a lot to the Reportlab team and all the users who've helped > improve it, for their work. > Pretty cool. You should post this message on your blog - it explains it pretty well. -- Carl K From vasudevram at gmail.com Sun Oct 4 15:06:29 2009 From: vasudevram at gmail.com (Vasudev Ram) Date: Mon, 5 Oct 2009 00:36:29 +0530 Subject: [reportlab-users] ANNOUNCE: Client-server PDF creation with xtopdf and ReportLab and Python and XML-RPC In-Reply-To: <549053140910041154ua207052h2e55cac77ccc79ae@mail.gmail.com> References: <549053140910041154ua207052h2e55cac77ccc79ae@mail.gmail.com> Message-ID: On Mon, Oct 5, 2009 at 12:24 AM, Carl Karsten wrote: > On Sun, Oct 4, 2009 at 1:19 PM, Vasudev Ram wrote: > > > > Hi list, > > > > I'm happy to announce the release of v1.0 of PDFXMLRPC, a client-server > > application that lets users create PDF content from text, over the > Internet > > or their intranet, using Reportlab, xtopdf, XML-RPC and Python. > > > > Usage example for PDFXMLRPC: > > > > You can run the server on one computer which is connected to the > Internet. > > You can run the client on another computer which is connected to the > > Internet. > > > > When you run the client, it sends text content to the server. The server > > then converts this text to PDF, and sends that PDF content back to the > > client over the Internet. The client then writes that PDF content to a > local > > PDF file, which the user can then open / print / etc. > > (But also see the part about callability (i.e., programmability) of both > the > > client and server below.) > > > > Pretty cool. > > You should post this message on your blog - it explains it pretty well. > > -- > Carl K > Thanks, Carl! I'll do just that :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From janssen at parc.com Sun Oct 4 15:39:36 2009 From: janssen at parc.com (Bill Janssen) Date: Sun, 4 Oct 2009 12:39:36 PDT Subject: [reportlab-users] ANNOUNCE: Client-server PDF creation with xtopdf and ReportLab and Python and XML-RPC In-Reply-To: References: Message-ID: <80693.1254685176@parc.com> Vasudev, Could you say a bit more about the problem you are trying to solve? Here are some of the questions that popped into my mind when I read your note. Why is it hard to convert text to PDF? I just run GNU enscript into ps2pdf from GNU Ghostscript to do this -- no server required: enscript -o- -M Letter foo.txt | ps2pdf - foo.pdf And, if a server is for some reason useful, why is it better to have a dedicated client, and drag XML-RPC into this? Why not just use an HTTP server framework (say, SimpleHTTPServer), and let users just POST their text to the server and get back the PDF as the reply value? Be more useful for programs that way, and users don't have to install clients. Bill From vasudevram at gmail.com Sun Oct 4 17:20:09 2009 From: vasudevram at gmail.com (Vasudev Ram) Date: Mon, 5 Oct 2009 02:50:09 +0530 Subject: [reportlab-users] ANNOUNCE: Client-server PDF creation with xtopdf and ReportLab and Python and XML-RPC In-Reply-To: <80693.1254685176@parc.com> References: <80693.1254685176@parc.com> Message-ID: On Mon, Oct 5, 2009 at 1:09 AM, Bill Janssen wrote: > Vasudev, > > Bill, First, thanks for your feedback. Could you say a bit more about the problem you are trying to solve? > I did not say anywhere (i.e., in any of my blog posts or this post to the reportlab-users mailing list, about PDFXMLRPC) that I was trying to solve any problem. The fact is, I was not (trying to solve some problem). I simply wrote PDFXMLRPC for fun. Did it initially as a rough version, a while back when I was playing around with XML-RPC in Python, sometime after first writing xtopdf. (So I happened to think of combining xtopdf with XML-RPC, in Python. Also wrote a Ruby client for it, like the Python client, at that time, again for fun and learning). Then recently I was looking through some of my old code fragments and thought of cleaning up the code some, and releasing it as open source software. That's all. Not all software is written to solve an existing problem. Many people write some of their software just for fun, and some of those people release some of it to the world. Obviously you know all this - it's common knowledge, which is why I'm a bit surprised by your question. > Here are some of the questions that popped into my mind when I read your > note. > > Why is it hard to convert text to PDF? I did not say anywhere that it is hard to convert text into PDF. Obviously there are many easy ways to do it (and not just the way you mention below, that uses enscript and ps2pdf; thanks for mentioning that, BTW - I did not know about it, about that pipeline and enscript at least, though I knew of the existence of ps2pdf. Learnt something new and useful today :). There are many (free and paid, open source or closed source) command-line tools, GUI tools, etc. for PDF creation for both Linux and Windows - Mac and other OS's too, I'm guess. There are also many SDKs / libraries for different OS's, for PDF creation. I'm aware of several of them: iText (Java), PDF::Writer and Prawn (Ruby), ReportLab (Python), libharu (C), PDFTron, JPedal, PDFSharp (.NET), iTextShart (.NET), ... I could go on. There are PDF printer drivers for Windows. Mac OS X has easy ways to convert any or almost any content to PDF (so I've heard / read.) > I just run GNU enscript into > ps2pdf from GNU Ghostscript to do this -- no server required: > > Nor did I say anywhere that a server is required for PDF creation from text (or from any other format). However, a server (and a corresponding client, may be _useful_ in certain cases, though, as I said above, I didn't write PDFXMLRPC because I thought it was needed or would be useful - just did it for fun). enscript -o- -M Letter foo.txt | ps2pdf - foo.pdf > > And, if a server is for some reason useful, why is it better to have a > dedicated client, and drag XML-RPC into this? I don't really like to keep repeating "I did not say ... " etc.; but again, I did not say it is better to have a dedicated client either. Just did it that way, and I recognize the validity of other approaches. Nor am I trying to "drag XML-RPC" into this. I just happen to like XML-RPC, so I used it. Nothing wrong with that. If anyone has any issues with my approach (of having a server in the first place, of having a dedicated client, of using XML-RPC, etc., that's fine with me. I have not asked anyone to use PDFXMLRPC. People are free not to use it. Again, obvious stuff ... > Why not just use an HTTP > server framework (say, SimpleHTTPServer), and let users just POST their > text to the server and get back the PDF as the reply value? Be more > useful for programs that way, and users don't have to install clients. > > Bill > > Though, as said earlier, I did not specifically choose XML-RPC (and therefore a dedicated client) over the HTTP server + POST approach you mention above (though I did think of some such approach, though using BaseHTTPServer, not SimpleHTTPServer, and may implement that in future as well), I do feel think that there can be cases where the XML-RPC approach may be preferable to the HTTP server + POST approach. One simple case (a non-technical reason) may be where your project is already using XML-RPC extensively, for lots of things (services), and you (or more likely your project manager) may not want to mess up things (meaning, really, not confuse less experienced developers) by introducing another "paradigm" (of REST / HTTP / POST, though I'm not sure it's large enough to merit the name paradigm) apart from XML-RPC as a means of inter-process communication. Though that's not a purely technical reason, those who have worked in industry, as opposed to the academic world, know that there are often (even maybe more often) non-technical (business, political) reasons that often sway project decisions - whether such reasons are right or wrong. And those reasons can also sometimes be the right reasons / right decisions - for the success of the project. No one can say arbitrarily with any justification, that all non-technical reasons (for taking a technical decision in a project) are wrong. And I have actually worked on projects like that. Another reason, a technical one this time, for possible use of XML-RPC for this application, including the use of a client, can be if the text data is coming in, in parts, over a period of time, for example because it is being produced in parts over time, for any reason whatsoever. Could be coming in over a socket from the producer, in bursts, with gaps. In that case, the POST / REST approach might not be a good one, since (AFAIK), that approach would result in your getting a PDF file for each chunk of text you send to the server, since REST is stateless. Then you have the problem of joining all those PDF files into one PDF file - which is possible, with tools like pdftk, but more cumbersome. Instead, with the XML-RPC approach, you can just keep sending those pieces of text as you get them, to the server, and the server will keep writing them to the PDF Canvas of ReportLab, and nothing will be sent back till you do your close() call, after which you will get back your entire PDF with the combined content of all the text chunks you had sent, at intervals. All this would be in the context of one long-held open connection between the server and the client. (Might have to do something about ensuring the connection doesn't time-out - I have to check that - set a socket option, maybe.) A few final points: I do agree that not having to install a client is a benefit. But not all use cases need that benefit or have it as a problem to install a client (despite a lot of talk by a lot of people about the web being the only platform, etc.) Also, not needing to install a client (in the REST / POST approach - though in fact you do need a client - either a browser or curl or some such), or using the enscript / postscript approach (AFAIK) implies a "monolithic" approach, i.e. where you just run existing standalone programs to do the text to PDF conversion. What about cases where you want to do that conversion as part of some other work, i.e. a larger program? Or do it repeatedly, in a loop, with varying parameters - e.g. customer invoices, but with the logic parameterized by some runtime conditions / data ? And I even mentioned such use cases in my original post - which Carl Karsten above, BTW, thought was a good idea / well described. IMO he was referring partly to those use cases - which come under the "callable / programmable" category I mentioned. In these cases - where the conversion is wanted as part of some larger process - the XML-RPC and programmable approach may be more appropriate. Note: since the main method used for the conversion is writeLine() (see the server and client code), you can sprinkle calls to writeLine throughout your larger program (which would be your client) as needed (doing other things in between those calls), and get the desired result. Wow, long reply .. :) Once again, I appreciate your feedback and questions. It's stimulating to get questions and have to defend one's decisions, whether one is proved right or wrong or both. In any case one learns something ... Best, Vasudev --- Dancing Bison Enterprises Biz: www.dancingbison.com Google Profile: http://is.gd/tWe3 Blog: jugad2.blogspot.com xtopdf: fast and easy PDF creation: www.dancingbison.com/products.html Twitter: @vasudevram -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jason.Brower at kone.com Mon Oct 5 00:35:41 2009 From: Jason.Brower at kone.com (Brower Jason) Date: Mon, 5 Oct 2009 06:35:41 +0200 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <549053140910020542y7ce3c9a9wfd65e32ba14203f4@mail.gmail.com> Message-ID: <7BEADC998EA85041A0170E2F5F726D2F01C7A957@EUDEXC01.KONENET.COM> I would love to see it. But it's a lot of data to sift through. Regards, Jason Brower -----Original Message----- From: reportlab-users-bounces at lists2.reportlab.com [mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of Carl Karsten Sent: 02/10/2009 15:42 To: For users of Reportlab open source software Subject: Re: [reportlab-users] Return a file object rather than save afile... On Thu, Oct 1, 2009 at 11:38 PM, Brower Jason wrote: > After a look through the main documentation I found section 2.2 and it > shoulds how to open a file like object and insert a pdf into that. ?But I > would like to have just the file object itself to return as a downloadable > stream. (I am using web2py) > I wrote code like that a year ago. It is here: http://bazaar.launchpad.net/~mdipierro/web2conf/devel but right now I get "Sorry, there was a problem connecting to the Launchpad server. " so I can't find the exact place. Look for the dabo report writer stuff. That is a reportlab wrapper, but the parts you want is the same. -- Carl K _______________________________________________ reportlab-users mailing list reportlab-users at lists2.reportlab.com http://two.pairlist.net/mailman/listinfo/reportlab-users From carl at personnelware.com Mon Oct 5 01:13:02 2009 From: carl at personnelware.com (Carl Karsten) Date: Mon, 5 Oct 2009 00:13:02 -0500 Subject: [reportlab-users] Return a file object rather than save afile... In-Reply-To: <7BEADC998EA85041A0170E2F5F726D2F01C7A957@EUDEXC01.KONENET.COM> References: <549053140910020542y7ce3c9a9wfd65e32ba14203f4@mail.gmail.com> <7BEADC998EA85041A0170E2F5F726D2F01C7A957@EUDEXC01.KONENET.COM> Message-ID: <549053140910042213o5920542x2c5221e4dcbfc4fe@mail.gmail.com> http://bazaar.launchpad.net/~mdipierro/web2conf/devel/annotate/head%3A/controllers/badge.py#L105 The important bits: # buffer to create pdf in buffer = StringIO() # generate the pdf in the buffer, using the layout and data rw = dReportWriter(OutputFile=buffer, ReportFormFile=xmlfile, Cursor=ds) rw.write() # get the pdf out of the buffer pdf = buffer.getvalue() buffer.close() return pdf On Sun, Oct 4, 2009 at 11:35 PM, Brower Jason wrote: > I would love to see it. ?But it's a lot of data to sift through. > Regards, > Jason Brower > > -----Original Message----- > From: reportlab-users-bounces at lists2.reportlab.com [mailto:reportlab-users-bounces at lists2.reportlab.com] On Behalf Of Carl Karsten > Sent: 02/10/2009 15:42 > To: For users of Reportlab open source software > Subject: Re: [reportlab-users] Return a file object rather than save afile... > > On Thu, Oct 1, 2009 at 11:38 PM, Brower Jason wrote: >> After a look through the main documentation I found section 2.2 and it >> shoulds how to open a file like object and insert a pdf into that. ?But I >> would like to have just the file object itself to return as a downloadable >> stream. (I am using web2py) >> > > I wrote code like that a year ago. ?It is here: > > http://bazaar.launchpad.net/~mdipierro/web2conf/devel > but right now I get > "Sorry, there was a problem connecting to the Launchpad server. " > > so I can't find the exact place. ?Look for the dabo report writer > stuff. ?That is a reportlab wrapper, but the parts you want is the > same. > > -- > Carl K > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > > -- Carl K From robin at reportlab.com Tue Oct 6 12:11:02 2009 From: robin at reportlab.com (Robin Becker) Date: Tue, 06 Oct 2009 17:11:02 +0100 Subject: [reportlab-users] test email ignore Message-ID: <4ACB6C16.1020000@chamonix.reportlab.co.uk> -- Robin Becker From ralsina at netmanagers.com.ar Fri Oct 9 23:15:37 2009 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Sat, 10 Oct 2009 00:15:37 -0300 Subject: [reportlab-users] rst2pdf version 0.12 released! Message-ID: <200910100015.37387.ralsina@netmanagers.com.ar> It's my pleasure to announce the release of rst2pdf version 0.12, available at http://code.google.com/p/rst2pdf/downloads/list Rst2pdf is a tool to generate PDF files directly from restructured text sources via reportlab. Rst2pdf aims to support the full restructured text feature set, and is very close to that goal, while also including some of the more experimental features, like a source code directive with syntax highlighting and math notation support with LaTeX-like syntax. It supports embedding arbitrary fonts, both True Type and PS Type 1, both raster and vector images (including SVG and PDF), page transition effects, multiple, flexible page layouts, cascading styles, and much, much more. This version includes many bugfixes and **MANY** new features compared to the previous 0.11 version, including but not limited to better styling, integration with `sphinx `_, a very raw, preliminar graphical frontend called bookrest, and a much more powerful tables implementation. In fact, this release has so much new code it needs testers! I would consider it beta quality, and may (probably will) have some rough spots. You can find more information about rst2pdf in its home page (http://rst2pdf.googlecode.com), and ask anything you want in the rst2pdf- discuss mailing list (http://groups.google.com/group/rst2pdf-discuss) A list of improvements and changes in this version is just too long, but is available at the `changelog `_ I hope you enjoy this program! -- ("\''/").__..-''"`-. . Roberto Alsina `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) From pier.carteri at gmail.com Sat Oct 10 12:27:15 2009 From: pier.carteri at gmail.com (pier carteri) Date: Sat, 10 Oct 2009 16:27:15 +0000 Subject: [reportlab-users] a bit confused on rml present and future Message-ID: Hi to all, This is going to be a long post... sorry for that I've used reportlab open source library for quite a long time and I must say that I'm completely satisfied with it. So once again thank you all for this piece of software; it's a great gifts to open source community! That said, back to my question: I would like to explore the rml approach to report generation but, I'm a bit confused on its copyright and licence. I try to explain what I've undestand (please correct me if I'm wrong) - rml is an xml dialect developed by reportlab; it is not an xml standard. Reportlab can change the definition when and how they want, depending on their needs. Basically that means they can add new tags or attributes because I don't think they will never change the behavior of existing one. Use of rml is free, you don't have to pay for creating rml documents. -rml describes the layout of a report and needs to be converted to somethings else for example pdf or html. Reportlab provides this kind of software as a proprietary solution. This is of course the most accurate and complete software for creating pdf from rml files. However there are also some third part implementation free and open source like the one used in OpenERP (I think it was previously called tinyrml). So if someone wants to create pdf based on rml file there are 2 solutions: -purchase a copy of reportlab software to manage rml and pdf files (best solution for enterprise-grade project) -create rml file and use some of the rml2pdf tools freely available to convert them (best solution for small project with no budget) Is everything right? That said if I want to start use the rml language I' ve a couple of question: -is there any possibility that rml use will became more restrictive in the future? Please note that I'm not worried about reportlab people, they have already prove to be good guys; I'm asking if there are any patents on rml language that someone somewhere in the future maybe.... -I have found the rml manual on reportlab website but I've not found any rml definition: can someone point me to the rml.dtd? Thank you! From simone.dalmasso at gmail.com Tue Oct 13 07:02:20 2009 From: simone.dalmasso at gmail.com (Simone Dalmasso) Date: Tue, 13 Oct 2009 13:02:20 +0200 Subject: [reportlab-users] Generic mod_python error when returning pdf Message-ID: Hi, list. Months ago I built a web app under django which through a button creates a pdf and returns it via an HttpResponse. All worked fine util the app was under the django development server but now, trying to deploy under mod_python, it breaks when the server try to send the pdf. What I get is a generic mod_python error. The way I create the pdf is like this: response = HttpResponse(mimetype = "application/pdf") response['Content-Disposition'] = 'attachment; filename=Fasst-laboratories.pdf' doc = SimpleDocTemplate(response, topMargin = 1 *cm) and more... then I return the response variable to another method which handle the http request and sends back the response to the client. Have you got any ideas? Thanks in advance. Simone -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at reportlab.com Tue Oct 13 07:26:57 2009 From: robin at reportlab.com (Robin Becker) Date: Tue, 13 Oct 2009 12:26:57 +0100 Subject: [reportlab-users] Generic mod_python error when returning pdf In-Reply-To: References: Message-ID: <4AD46401.7030106@chamonix.reportlab.co.uk> Simone Dalmasso wrote: > Hi, list. Months ago I built a web app under django which through a button > creates a pdf and returns it via an HttpResponse. All worked fine util the > app was under the django development server but now, trying to deploy under > mod_python, it breaks when the server try to send the pdf. What I get is a > generic mod_python error. > The way I create the pdf is like this: > response = HttpResponse(mimetype = "application/pdf") > response['Content-Disposition'] = 'attachment; > filename=Fasst-laboratories.pdf' > doc = SimpleDocTemplate(response, topMargin = 1 *cm) > and more... > then I return the response variable to another method which handle the http > request and sends back the response to the client. > ........ effectively you are relying on SimpleDocTemplate to write into the response; according to my understanding that should work. However, without knowing what the error is makes it hard to figure out what mod_python is whining about. Have you looked in the apache error logs to see if there's anything obvious going on. A few years ago when we started with django we used mod_python, but several things put us off. Firstly we had problems related to tight binding of apache/python/os etc etc and thene teher were issues about separation of virtual hosts; at one pint we used a two layer scheme with the VMs on the top layer passing to individual apaches running the applications with a mod_python for each. We eventually switched to fastcgi using flup. That has proved very flexible and stable and allows us to use different versions of django python etc etc. -- Robin Becker From simone.dalmasso at gmail.com Tue Oct 13 08:44:54 2009 From: simone.dalmasso at gmail.com (Simone Dalmasso) Date: Tue, 13 Oct 2009 14:44:54 +0200 Subject: [reportlab-users] Generic mod_python error when returning pdf In-Reply-To: <4AD46401.7030106@chamonix.reportlab.co.uk> References: <4AD46401.7030106@chamonix.reportlab.co.uk> Message-ID: Looking for the error stacktrace this is what I get: Traceback (most recent call last): File "/usr/lib64/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib64/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/usr/lib64/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target result = object(arg) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 228, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 201, in __call__ response = self.get_response(request) File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 128, in get_response return self.handle_uncaught_exception(request, resolver, exc_info) File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 160, in handle_uncaught_exception return callback(request, **param_dict) File "/usr/lib/python2.4/site-packages/django/views/defaults.py", line 23, in server_error t = loader.get_template(template_name) # You need to create a 500.html template. File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 80, in get_template source, origin = find_template_source(template_name) File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 73, in find_template_source raise TemplateDoesNotExist, name TemplateDoesNotExist: 500.html I have't designed the 550 error template yet. But anyway it isn't so useful I think. Trying to execute the method through the python shell it doesn't raise any exceptions and it returns an HttpResponse object. So I think that the error occurs when django tries to send the response to the client. Maybe some issues between django and mod_python? Simone 2009/10/13 Robin Becker > Simone Dalmasso wrote: > >> Hi, list. Months ago I built a web app under django which through a >> button >> creates a pdf and returns it via an HttpResponse. All worked fine util the >> app was under the django development server but now, trying to deploy >> under >> mod_python, it breaks when the server try to send the pdf. What I get is a >> generic mod_python error. >> The way I create the pdf is like this: >> response = HttpResponse(mimetype = "application/pdf") >> response['Content-Disposition'] = 'attachment; >> filename=Fasst-laboratories.pdf' >> doc = SimpleDocTemplate(response, topMargin = 1 *cm) >> and more... >> then I return the response variable to another method which handle the >> http >> request and sends back the response to the client. >> >> ........ > > effectively you are relying on SimpleDocTemplate to write into the > response; according to my understanding that should work. However, without > knowing what the error is makes it hard to figure out what mod_python is > whining about. Have you looked in the apache error logs to see if there's > anything obvious going on. > > A few years ago when we started with django we used mod_python, but several > things put us off. Firstly we had problems related to tight binding of > apache/python/os etc etc and thene teher were issues about separation of > virtual hosts; at one pint we used a two layer scheme with the VMs on the > top layer passing to individual apaches running the applications with a > mod_python for each. > > We eventually switched to fastcgi using flup. That has proved very flexible > and stable and allows us to use different versions of django python etc etc. > -- > Robin Becker > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy at reportlab.com Tue Oct 13 09:03:18 2009 From: andy at reportlab.com (Andy Robinson) Date: Tue, 13 Oct 2009 14:03:18 +0100 Subject: [reportlab-users] Generic mod_python error when returning pdf In-Reply-To: References: <4AD46401.7030106@chamonix.reportlab.co.uk> Message-ID: <956003ae0910130603p5289ab1crdc47083df9e9c4b@mail.gmail.com> 2009/10/13 Simone Dalmasso : > TemplateDoesNotExist: 500.html > > I have't designed the 550 error template yet. But anyway it isn't so useful > I think. Trying to execute the method through the python shell it doesn't > raise any exceptions and it returns an HttpResponse object. So I think that > the error occurs when django tries to send the response to the client. Maybe > some issues between django and mod_python? We've had this too when first setting up production apps. It's trying to display the 'underlying' error but failing because no template exists. If you implement this template, or set DEBUG=True in settings.py, it might tell you what the underlying error is with your PDF generation. Usually one gets bitten with things like writing to files or directories (the current working directory may be different under mod_python and development) or important (or failing to import) needed libraries because the path is different. Good luck, Andy From andy at reportlab.com Tue Oct 13 09:28:36 2009 From: andy at reportlab.com (Andy Robinson) Date: Tue, 13 Oct 2009 14:28:36 +0100 Subject: [reportlab-users] a bit confused on rml present and future In-Reply-To: References: Message-ID: <956003ae0910130628i3863c165iafff38a84ac8ea05@mail.gmail.com> 2009/10/10 pier carteri : > That said, back to my question: I would like to explore the rml > approach to report generation but, I'm a bit confused on its copyright > and licence. I try to explain what I've undestand (please correct me > if I'm wrong) > So if someone wants to create pdf based on rml file there are 2 solutions: > -purchase a copy of reportlab software to manage rml and pdf files > (best solution for enterprise-grade project) > -create rml file and use some of the rml2pdf tools freely available to > convert them (best solution for small project with no budget) > Is everything right? Fairly close. However (bearing in mind my bias as RML's vendor) I would like to add two things: (1) The pricing for RML is linked to volume and it's quite affordable for many smaller or departmental projects - not just enterprise-grade. We'll have a lot more info about this on our site soon. (2) We have many tags in our product which do things that would be fairly tricky to implement elsewhere and are not just wrappers around our open source code (e.g. parsing and re-using PDF pages). With rival implementations, you'll have to try them to see what diverges from our docs (3) If you want a zero-cost approach, you can also construct Python code using our open source library to create documents, and get support from hundreds of users here. If you use a rival RML implementation, you're relying on its authors and a smaller community > That said if I want to start use the rml language I' ve a couple of question: > -is there any possibility that rml use will became more restrictive in > the future? Please note that I'm not worried about reportlab people, > they have already prove to be good guys; I'm asking if there are any > patents on rml language that someone ?somewhere in the future > maybe.... I am not aware of anybody else having applicable patents. ReportLab do not believe in software patents, and I don't think you can patent a standard. BUT Report Markup Language and RML2PDF are our trademarks, and we will seek to defend them. Practically, if someone else is creating an implementation, we expect them to clearly acknowledge it is an alternative implementation of our product; state whether they use our engine; try to document what they do and don't support; and try to support their own users. Stephan Richter (author of z3c.rml) has been very good about this and his package has good docs. > -I have found the rml manual on reportlab website but I've not found > any rml definition: can someone point me to the rml.dtd? There is a fairly recent copy here: http://www.reportlab.com/docs/rml.dtd However, we don't want this to be a canonical published location for apps to check against, because we don't want people nagging us about moving it or versioning it, or complaining if we add an attribute or a tag. We do not have a 'standards process' like the W3C; instead, we add stuff when we need it, often at short notice. Each RML2PDF package contains a copy of the DTD which is used for runtime parsing of RML and is 100% in sync with the code. If you want to try out the commercial version and/or get a price quote, you will find a DTD within the package, just email our enquiries address on this page here... http://developer.reportlab.com/ 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 simone.dalmasso at gmail.com Tue Oct 13 09:28:23 2009 From: simone.dalmasso at gmail.com (Simone Dalmasso) Date: Tue, 13 Oct 2009 15:28:23 +0200 Subject: [reportlab-users] Generic mod_python error when returning pdf In-Reply-To: <956003ae0910130603p5289ab1crdc47083df9e9c4b@mail.gmail.com> References: <4AD46401.7030106@chamonix.reportlab.co.uk> <956003ae0910130603p5289ab1crdc47083df9e9c4b@mail.gmail.com> Message-ID: Thank you! It solved, was an I/O error because mod_python look in a different folder path, using an absolute path instead ov relative fixes the issue. Thanks again. Simone 2009/10/13 Andy Robinson > 2009/10/13 Simone Dalmasso : > > TemplateDoesNotExist: 500.html > > > > I have't designed the 550 error template yet. But anyway it isn't so > useful > > I think. Trying to execute the method through the python shell it doesn't > > raise any exceptions and it returns an HttpResponse object. So I think > that > > the error occurs when django tries to send the response to the client. > Maybe > > some issues between django and mod_python? > > > We've had this too when first setting up production apps. It's > trying to display the 'underlying' error but failing because no > template exists. If you implement this template, or set DEBUG=True in > settings.py, it might tell you what the underlying error is with your > PDF generation. > > Usually one gets bitten with things like writing to files or > directories (the current working directory may be different under > mod_python and development) or important (or failing to import) needed > libraries because the path is different. > > Good luck, > > Andy > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bfreeman at appropriatesolutions.com Tue Oct 13 10:09:43 2009 From: bfreeman at appropriatesolutions.com (Bill Freeman) Date: Tue, 13 Oct 2009 10:09:43 -0400 (EDT) Subject: [reportlab-users] Generic mod_python error when returning pdf In-Reply-To: <23134808.1761255443990072.JavaMail.bfreeman@ip-151.corp.appropriatesolutions.com> Message-ID: <3658936.1781255444170770.JavaMail.bfreeman@ip-151.corp.appropriatesolutions.com> ----- Original Message ----- From: "Simone Dalmasso" To: "For users of Reportlab open source software" Sent: Tuesday, October 13, 2009 8:44:54 AM GMT -05:00 US/Canada Eastern Subject: Re: [reportlab-users] Generic mod_python error when returning pdf ... File "/usr/lib64/python2.4/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib64/python2.4/site-packages/mod_python/importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/usr/lib64/python2.4/site-packages/mod_python/importer.py", line 1128, in _execute_target result = object(arg) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 228, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 201, in __call__ response = self.get_response(request) File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 128, in get_response return self.handle_uncaught_exception(request, resolver, exc_info) File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 160, in handle_uncaught_exception return callback(request, **param_dict) File "/usr/lib/python2.4/site-packages/django/views/defaults.py", line 23, in server_error t = loader.get_template(template_name) # You need to create a 500.html template. File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 80, in get_template source, origin = find_template_source(template_name) File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 73, in find_template_source raise TemplateDoesNotExist, name TemplateDoesNotExist: 500.html ... Part of this is trying to render the the template error, so the original error is obscured. Since stuff at the deep end of the stack is involved with importer, one thing to check is whether the python path is enough different between command line (as for run server) and under mod_python to keep you from finding, perhaps, the report lab installation. Also, mod_python is running as apache or root (whatever apache runs as), and some part of your code might have been installed without read permission for the apache user (check directory permissions too). Also, this should probably be asked on the django users list (a google group), where someone may just recognize the trace. Bill From pier.carteri at gmail.com Tue Oct 13 11:32:25 2009 From: pier.carteri at gmail.com (pier carteri) Date: Tue, 13 Oct 2009 17:32:25 +0200 Subject: [reportlab-users] a bit confused on rml present and future In-Reply-To: <956003ae0910130628i3863c165iafff38a84ac8ea05@mail.gmail.com> References: <956003ae0910130628i3863c165iafff38a84ac8ea05@mail.gmail.com> Message-ID: Hi to all, thank you Andy for your reply. I agree with you points; just to clarify: -with enterprise-grade I mean something stable and with good performance. This has no relation with cost. If I, (with my mail) give you the idea that I consider ReportLab too expensive, this was not my intention and I apologize for that. -thank you to point me to the dtd I'm considering the idea to develop something to create rml file, so from a legal point of view the things that I've to point out is thant Report Markup Language and RML2PDF are trademarks or ReportLab. That makes perfect sense to me. Best Regards Pier > Fairly close. ?However (bearing in mind my bias as RML's vendor) I > would like to add two things: > (1) The pricing for RML is linked to volume and it's quite affordable > for many smaller or departmental projects - not just enterprise-grade. > ?We'll have a lot more info about this on our site soon. > (2) We have many tags in our product which do things that would be > fairly tricky to implement elsewhere and are not just wrappers around > our open source code (e.g. parsing and re-using PDF pages). ?With > rival implementations, you'll have to try them to see what diverges > from our docs > (3) If you want a zero-cost approach, you can also construct Python > code using our open source library to create documents, and get > support from hundreds of users here. ?If you use a rival RML > implementation, you're relying on its authors and a smaller community > > >> That said if I want to start use the rml language I' ve a couple of question: >> -is there any possibility that rml use will became more restrictive in >> the future? Please note that I'm not worried about reportlab people, >> they have already prove to be good guys; I'm asking if there are any >> patents on rml language that someone ?somewhere in the future >> maybe.... > I am not aware of anybody else having applicable patents. > ReportLab do not believe in software patents, and I don't think you > can patent a standard. > > BUT Report Markup Language and RML2PDF are our trademarks, and we will > seek to defend them. > Practically, if someone else is creating an implementation, we expect > them to clearly acknowledge it is an alternative implementation of our > product; state whether they use our engine; try to document what they > do and don't support; and try to support their own users. ?Stephan > Richter (author of z3c.rml) has been very good about this and his > package has good docs. > >> -I have found the rml manual on reportlab website but I've not found >> any rml definition: can someone point me to the rml.dtd? > > There is a fairly recent copy here: > ?http://www.reportlab.com/docs/rml.dtd > > However, we don't want this to be a canonical published location for > apps to check against, because we don't want people nagging us about > moving it or versioning it, or complaining if we add an attribute or a > tag. ? We do not have a 'standards process' like the W3C; instead, we > add stuff when we need it, often at short notice. > > Each RML2PDF package contains a copy of the DTD which is used for > runtime parsing of RML and is 100% in sync with the code. > > If you want to try out the commercial version and/or get a price > quote, you will find a DTD within the package, just email our > enquiries address on this page here... > ? ?http://developer.reportlab.com/ > > > 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 > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > From ralsina at netmanagers.com.ar Wed Oct 14 23:48:56 2009 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Thu, 15 Oct 2009 00:48:56 -0300 Subject: [reportlab-users] Bug in RL 2.3: XPreformattedFit and keepwithnext add spurious page Message-ID: <200910150048.56238.ralsina@netmanagers.com.ar> Consider this script: -------------------------------------- styles = getSampleStyleSheet() doc = SimpleDocTemplate("issue216.pdf") knstyle=copy(styles['Normal']) heading=Paragraph('A heading at the beginning of the document',knstyle) heading.keepWithNext=True content= XPreformatted('This is the content\n'*120,styles['Normal']) doc.build([heading,content]) -------------------------------------- If I don't set heading.keepWithNext to True, it produces a document that starts with 'A heading ....' followed by 'This is the content' repeated 120 times. With keepWithNext set to True, there is a pagebreak at the beginning of the document (see attached PDF file). This is with reportlab 2.3 Full test program here: http://code.google.com/p/rst2pdf/source/browse/trunk/rst2pdf/tests/input/test_issue_216.py -- ("\''/").__..-''"`-. . Roberto Alsina `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) -------------- next part -------------- A non-text attachment was scrubbed... Name: issue216.pdf Type: application/pdf Size: 3818 bytes Desc: not available Url : From federico at panizzolo.it Thu Oct 15 09:09:27 2009 From: federico at panizzolo.it (Federico Fanton) Date: Thu, 15 Oct 2009 15:09:27 +0200 Subject: [reportlab-users] Using "follows..." Message-ID: <4AD71F07.7080704@panizzolo.it> Hi everyone! I'm trying to build a report of an invoice.. Given that an invoice has header + rows + footer, I'd like the header to be on every page but the footer ONLY on the last page, while on the previous ones there should be just a "follows on the next page" label. I thought I could use SimpleDocTemplate and its onLaterPages method, but one problem is that if the invoice has just one page, only onFirstPage would get called, so there would be no footer at all.. I think I'd need something like onSinglePage / onLaterPages / onLastPage, but how can I tell if the current page is the last one? Am I going the wrong way entirely? (I'm using PLATYPUS) Thanks in advance! From robin at reportlab.com Thu Oct 15 10:20:58 2009 From: robin at reportlab.com (Robin Becker) Date: Thu, 15 Oct 2009 15:20:58 +0100 Subject: [reportlab-users] Bug in RL 2.3: XPreformattedFit and keepwithnext add spurious page In-Reply-To: <200910150048.56238.ralsina@netmanagers.com.ar> References: <200910150048.56238.ralsina@netmanagers.com.ar> Message-ID: <4AD72FCA.6090202@chamonix.reportlab.co.uk> Roberto Alsina wrote: > Consider this script: > > -------------------------------------- > > styles = getSampleStyleSheet() > doc = SimpleDocTemplate("issue216.pdf") > > knstyle=copy(styles['Normal']) > heading=Paragraph('A heading at the beginning of the document',knstyle) > heading.keepWithNext=True > content= XPreformatted('This is the content\n'*120,styles['Normal']) > > doc.build([heading,content]) > > -------------------------------------- > > If I don't set heading.keepWithNext to True, it produces a document that > starts with 'A heading ....' followed by 'This is the content' repeated 120 > times. > > With keepWithNext set to True, there is a pagebreak at the beginning of the > document (see attached PDF file). > > This is with reportlab 2.3 > > Full test program here: > http://code.google.com/p/rst2pdf/source/browse/trunk/rst2pdf/tests/input/test_issue_216.py ........ thanks for the bug report. I'll try and have a look at the weekend to see if I can figure out what is going on. -- Robin Becker From yroman-reportlab at altalang.com Mon Oct 19 17:39:47 2009 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Mon, 19 Oct 2009 17:39:47 -0400 Subject: [reportlab-users] Arabic joining/shaping Message-ID: <000001ca5104$ae44e470$0502000a@ad.altalang.com> Before I went off reinventing the wheel, I wanted to see if anyone had gotten Arabic shaping working with ReportLab. I've been using Pyfribidi2 to get the RTL ordering and shaping, but its shaping is really doing replacements with the legacy Arabic Presentation Forms Unicode blocks, which don't adequately cover something like Pashto, for example. Is there an existing Python patch/library/extension somewhere to select a glyph within a TrueType font based on the joins/ligatures (like MS's Uniscribe engine)? Thanks, -- Yoann Roman From andy at reportlab.com Tue Oct 20 02:46:15 2009 From: andy at reportlab.com (Andy Robinson) Date: Tue, 20 Oct 2009 07:46:15 +0100 Subject: [reportlab-users] Arabic joining/shaping In-Reply-To: <000001ca5104$ae44e470$0502000a@ad.altalang.com> References: <000001ca5104$ae44e470$0502000a@ad.altalang.com> Message-ID: <956003ae0910192346h415d6daar2a2da7868db9606c@mail.gmail.com> 2009/10/19 Yoann Roman : > Is there an existing Python patch/library/extension somewhere to select > a glyph within a TrueType font based on the joins/ligatures (like MS's > Uniscribe engine)? I have not heard of any such code. -- Andy From bhiggins at gmail.com Wed Oct 21 14:31:43 2009 From: bhiggins at gmail.com (Benjamin Higgins) Date: Wed, 21 Oct 2009 11:31:43 -0700 Subject: [reportlab-users] Line splitting for long tables Message-ID: <4f38543c0910211131y47f7e5adtf824e100617ed974@mail.gmail.com> Hey, We've been using ReportLab with great results except for one hang-up -- we have some tables that are too wide for the page sometimes. It's caused by long text in one of the cells. We need a solution for splitting text to multiple lines so that the table will fit on the page. Any suggestions on how to do this, even a rudimentary solution? I'm thinking of writing an algorithm myself to split long text to multiple lines but I'm sure it's not going to be very good. Thanks, Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From ralsina at netmanagers.com.ar Wed Oct 21 13:45:42 2009 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Wed, 21 Oct 2009 15:45:42 -0200 Subject: [reportlab-users] Line splitting for long tables In-Reply-To: <4f38543c0910211131y47f7e5adtf824e100617ed974@mail.gmail.com> References: <4f38543c0910211131y47f7e5adtf824e100617ed974@mail.gmail.com> Message-ID: <200910211545.42872.ralsina@netmanagers.com.ar> On Wednesday 21 October 2009 16:31:43 Benjamin Higgins wrote: > We've been using ReportLab with great results except for one hang-up -- we > have some tables that are too wide for the page sometimes. It's caused > by long text in one of the cells. We need a solution for splitting text > to multiple lines so that the table will fit on the page. Any suggestions > on how to do this, even a rudimentary solution? I'm thinking of writing > an algorithm myself to split long text to multiple lines but I'm sure it's > not going to be very good. Why not use a Paragraph inside that cell? -- ("\''/").__..-''"`-. . Roberto Alsina `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) From vasudevram at gmail.com Wed Oct 21 15:31:23 2009 From: vasudevram at gmail.com (Vasudev Ram) Date: Thu, 22 Oct 2009 01:01:23 +0530 Subject: [reportlab-users] Line splitting for long tables In-Reply-To: <200910211545.42872.ralsina@netmanagers.com.ar> References: <4f38543c0910211131y47f7e5adtf824e100617ed974@mail.gmail.com> <200910211545.42872.ralsina@netmanagers.com.ar> Message-ID: On Wed, Oct 21, 2009 at 11:15 PM, Roberto Alsina wrote: > On Wednesday 21 October 2009 16:31:43 Benjamin Higgins wrote: > > We've been using ReportLab with great results except for one hang-up -- > we > > have some tables that are too wide for the page sometimes. It's caused > > by long text in one of the cells. We need a solution for splitting text > > to multiple lines so that the table will fit on the page. Any > suggestions > > on how to do this, even a rudimentary solution? I'm thinking of writing > > an algorithm myself to split long text to multiple lines but I'm sure > it's > > not going to be very good. > > Why not use a Paragraph inside that cell? > > -- > ("\''/").__..-''"`-. . Roberto Alsina > `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) > (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar > _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia > (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007) > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > Paragraph in a cell sounds like a good solution. But writing your own algorithm for line splitting could be fun too. >I'm thinking of writing > an algorithm myself to split long text to multiple lines but I'm sure it's > not going to be very good. Why does it need to be very good? As long as it works ... :) Obviously good or very good is better (heh:) than not so good, but if it meets the need, you've at least solved your problem. unless by "very good" you mean its speed, and performance is an issue. Here is an overview of a possible algorithm - it's off the top of my head, so no guarantee that it is right - you'd have to test it: I'm assuming that you have the line in a Python string. 1) If you don't mind splitting the line in the middle of a word, the algorithm is trivial - just split the line at every cell_len characters, where cell_len is the number of characters that can fit into (one line of) your table cell. (You could optionally add a hyphen (after cell_len - 1 characters, to allow one character for the hyphen) to indicate the line is split in the middle of a word - when it is.) The last line in the cell may have less than cell_len characters, but that's ok. 2) If approach 1) above (splitting the line in the middle of words) is not applicable, you'll have to go to the cell_len'th character of the line, step backwards character by character, looking for the first space from that point towards the left (in lower string indices than cell_len). Split the line at that point (i.e. the first space found). Repeat for the rest of the line (i.e. string) to the right of the space (i.e. now treating that part of the string as the whole string was treated earlier above), as long as the rest of the line (string) is still longer than cell_len. Voila! :) Though it may be less effiicient, this algorithm should lend itself nicely to a recursive solution, I think, based on the technique I describe above, which is recursive - i.e. repeats the partial solution with successively smaller pieces of the string, until the string length is less than cell_len, at which point the recursive algorithm terminates. It can also easily be implemented in an interative, non-recursive way, instead. The above may not handle the case when the whole substring s[:cell_len] has no space it it (you're looking for the first space, and there is none there). Handle that case separately (but note, there is a twist involved here - as they say, I'm leaving that as an exercise to the reader :). HTH, Vasudev Ram Biz: dancingbison.com Blog: jugad2.blogspot.com Products: dancingbison.com/products.html Twitter: @vasudevram -------------- next part -------------- An HTML attachment was scrubbed... URL: From robin at reportlab.com Thu Oct 22 05:17:25 2009 From: robin at reportlab.com (Robin Becker) Date: Thu, 22 Oct 2009 10:17:25 +0100 Subject: [reportlab-users] Line splitting for long tables In-Reply-To: <4f38543c0910211131y47f7e5adtf824e100617ed974@mail.gmail.com> References: <4f38543c0910211131y47f7e5adtf824e100617ed974@mail.gmail.com> Message-ID: <4AE02325.6020703@chamonix.reportlab.co.uk> Benjamin Higgins wrote: > Hey, > > We've been using ReportLab with great results except for one hang-up -- we > have some tables that are too wide for the page sometimes. It's caused by > long text in one of the cells. We need a solution for splitting text to > multiple lines so that the table will fit on the page. Any suggestions on > how to do this, even a rudimentary solution? I'm thinking of writing an > algorithm myself to split long text to multiple lines but I'm sure it's not > going to be very good. Table cells can contain flowables or lists of flowables so you can use paragraph flowables inside them. Alternatively if using Paragraphs is too heavy there's a simpleSplit function in reportlab/lib/utils.py that may do what you want. Of course any kind of splitting mechanism requires that we know the desired width, font, font size etc etc. -- Robin Becker From IStevens at globeandmail.com Tue Oct 27 16:34:33 2009 From: IStevens at globeandmail.com (Stevens, Ian) Date: Tue, 27 Oct 2009 16:34:33 -0400 Subject: [reportlab-users] Intermittent failure to find font, followed by IOError In-Reply-To: References: <956003ae0901191437pe94829ctd39af7b19a8bb50c@mail.gmail.com> <956003ae0901200939g3d13a289ob80296b40e2923cc@mail.gmail.com><4976168A.2050406@chamonix.reportlab.co.uk> Message-ID: <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> Hi all. Earlier this year, I posted a problem we had been having with our production servers. We were getting an intermittent "IOError: Cannot open resource '/usr/lib/python2.5/site-packages/reportlab/fonts/LeERC___.AFM'": http://two.pairlist.net/pipermail/reportlab-users/2009-January/007928.html We weren't able to reproduce it at all, but it persisted. We upgraded to Reportlab 2.3, and it still persisted. I added a suggested call to reportlab.rl_config._reset() (see http://two.pairlist.net/pipermail/reportlab-users/2009-January/007933.html) before any fonts are registered. The error still persists: File "/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py", line 226, in bruteForceSearchForAFM (topDict, glyphDict) = parseAFMFile(possible) File "/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py", line 79, in parseAFMFile lines = open_and_readlines(afmFileName, 'r') File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line 459, in open_and_readlines return open_and_read(name,mode).split('\n') File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line 456, in open_and_read return open_for_read(name,mode).read() File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line 452, in open_for_read raise IOError('Cannot open resource "%s"' % name) IOError: Cannot open resource "/usr/lib/python2.5/site-packages/reportlab/fonts/DarkGardenMK.afm" Recently we set Apache's MaxRequestsPerChild to 1 (while using mpm_prefork_module) to determine if the problem was indeed state-related. Under that configuration, none of the above errors appeared. Unfortunately, that setup isn't conducive to a high-performing web server so it had to be removed. While before these errors were only slightly annoying, we're under increasing traffic and so they are increasing in frequency. Under what conditions would reportlab.lib.utils.open_for_read_by_name() fail on a local file? On our server, it would just be a call to open(). We are running Reportlab in Django under Apache with mpm_prefork_module and mod_python. Every request for a PDF first registers a combination of about 65 app-specific Postscript and TrueType fonts before any other Reportlab operations. Adding reportlab.rl_config._reset to the top of that method had no effect. Andy (Robinson) wrote that we could help investigate this error by adding some trace statements in the code. Unfortunately, we haven't been able reproduce the errors. We are open to adding this code for a few days and delivering the results. We are running off the release version of 2.3. Would you be able to provide us with some patches which we could apply? Thanks, Ian. From robin at reportlab.com Wed Oct 28 07:02:29 2009 From: robin at reportlab.com (Robin Becker) Date: Wed, 28 Oct 2009 11:02:29 +0000 Subject: [reportlab-users] Intermittent failure to find font, followed by IOError In-Reply-To: <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> References: <956003ae0901191437pe94829ctd39af7b19a8bb50c@mail.gmail.com> <956003ae0901200939g3d13a289ob80296b40e2923cc@mail.gmail.com><4976168A.2050406@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> Message-ID: <4AE824C5.5070102@chamonix.reportlab.co.uk> Stevens, Ian wrote: > Hi all. Earlier this year, I posted a problem we had been having with our production servers. > ........ > IOError: Cannot open resource "/usr/lib/python2.5/site-packages/reportlab/fonts/DarkGardenMK.afm" > ........ If it helps, I can say that we used to run Django via mod_python, but did not see this particular issue. First off it seems particularly strange that you see DarkGardenMK.afm(or earlier LetError) mentioned. We include this font purely as an exemplar of a type 1 font. So far as I know none of the standard library code is actually using it. I believe it may be mentioned in reportlab/graphics/testshapes.py. Are you importing that module or are you explicitly using this font? Apache+mod_python presumably runs as a special user say www; does that cause any problems of reading etc etc? Secondly as your apache test seems to imply this may be a threading issue. The base ReportLab toolkit is not thread safe. Thus if one thread is in the process of reading a file when another thread attempts to open the same file it's entirely possible that something odd may happen. Calling the reset function may actually make things worse for multi-threaded programs. We run django using flup (http://www.saddi.com/projects/index.html) in prefork mode and have never had any serious issues. My experience of the mod_python approach was that we did encounter some problems related to threading and/or encapsulation (ie privacy between apps). In the flup prefork approach at least I believe the django wsgi server is running single threaded; also since we control the startup of the server as a normal user then only the flup socket needs to be writable by www. -- Robin Becker From van.lindberg at gmail.com Wed Oct 28 11:24:41 2009 From: van.lindberg at gmail.com (VanL) Date: Wed, 28 Oct 2009 10:24:41 -0500 Subject: [reportlab-users] JBIG2 support in reportlab Message-ID: <4AE86239.6080506@gmail.com> Hello, I have put together some support for JBIG2-encoded images in reportlab. This is to replace the somewhat grotty version that comes with jbig2enc. I believe I have things almost set up correctly, based on the examples, but I am not quite sure what the last incantations are to turn this into a multipage pdf. I have put my code up in a repository; could I get any feedback/review/help? jbig2enc version: http://hg.processmechanics.com/jbig2pdf/file/tip/src/pdf.py Code: http://hg.processmechanics.com/jbig2pdf/file/tip/src/jbig2pdf/jbig2pdf.py Test data (tiffs and jbig2 output): http://hg.processmechanics.com/jbig2pdf/file/tip/data/ Thanks, VanL From mjf at pearson.co.uk Wed Oct 28 12:14:16 2009 From: mjf at pearson.co.uk (Matt Folwell) Date: Wed, 28 Oct 2009 16:14:16 +0000 Subject: [reportlab-users] [PATCH] Missing labels from HorizontalBarChart Message-ID: <4AE86DD8.1000502@pearson.co.uk> I had a VerticalBarChart with no ticks drawn on the category axis. When I replaced it with an otherwise identical HorizontalBarChart, the labels disappeared from the category axis. When checking whether the labels should be drawn, the YCategoryAxis.makeTickLabels tests self.visibleTicks, where it should test self.visibleTicks (as XCategoryAxis does) I've attached a trivial patch to fix this. -- Matt Folwell Senior Programmer Pearson Publishing Ltd Chesterton Mill, French's Road, Cambridge CB4 3NP Tel: 01223 350555 Fax: 01223 356484 http://www.pearsonpublishing.co.uk/ Registered in England No 2853229 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: horizontal_bar_graph_labels.patch Url: From robin at reportlab.com Wed Oct 28 12:29:05 2009 From: robin at reportlab.com (Robin Becker) Date: Wed, 28 Oct 2009 16:29:05 +0000 Subject: [reportlab-users] [PATCH] Missing labels from HorizontalBarChart In-Reply-To: <4AE86DD8.1000502@pearson.co.uk> References: <4AE86DD8.1000502@pearson.co.uk> Message-ID: <4AE87151.7000508@chamonix.reportlab.co.uk> Matt Folwell wrote: > I had a VerticalBarChart with no ticks drawn on the category axis. When > I replaced it with an otherwise identical HorizontalBarChart, the labels > disappeared from the category axis. > > When checking whether the labels should be drawn, the > YCategoryAxis.makeTickLabels tests self.visibleTicks, where it should > test self.visibleTicks (as XCategoryAxis does) > > I've attached a trivial patch to fix this. ....... thanks for the patch -- Robin Becker From IStevens at globeandmail.com Wed Oct 28 15:45:26 2009 From: IStevens at globeandmail.com (Stevens, Ian) Date: Wed, 28 Oct 2009 15:45:26 -0400 Subject: [reportlab-users] Intermittent failure to find font, followed by IOError In-Reply-To: <4AE824C5.5070102@chamonix.reportlab.co.uk> References: <956003ae0901191437pe94829ctd39af7b19a8bb50c@mail.gmail.com> <956003ae0901200939g3d13a289ob80296b40e2923cc@mail.gmail.com><4976168A.2050406@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> <4AE824C5.5070102@chamonix.reportlab.co.uk> Message-ID: <935E6400826049439C33D7BC3DC930360CEF7F7D@GMEXMBS1.globeandmail.net> Thanks for taking the time to think about this issue, Robin. I admit it's an odd behaviour, especially seeing as though we never make use of that font or any fonts included with Reportlab. We also don't use the reportlab.graphics.testshapes module. It feels like a symptom of a larger problem. The fonts are owned by root, but readable by everyone. If something were altering the rights for those files, then presumably the error would not have gone away when we changed MaxRequestsPerChild to 1. With respect to multi-threading, I spoke to our operations dept. I had thought we were using Apache prefork, but they have it set up for worker instead. They had it set up with prefork at one point but apparently the errors still occurred, and were more frequent. I instructed them to switch back to prefork. The font errors immediately started coming through with increased frequency. That is odd as I would expect the errors to occur more under worker than prefork. I'll check out the WSGI with flup option and see if that fixes things. Thanks, Ian. > -----Original Message----- > From: reportlab-users-bounces at lists2.reportlab.com > [mailto:reportlab-users-bounces at lists2.reportlab.com] On > Behalf Of Robin Becker > Sent: October 28, 2009 7:02 AM > To: Support list for users of Reportlab software > Subject: Re: [reportlab-users] Intermittent failure to find > font, followed by IOError > > Stevens, Ian wrote: > > Hi all. Earlier this year, I posted a problem we had been > having with our production servers. > > > ........ > > IOError: Cannot open resource > "/usr/lib/python2.5/site-packages/reportlab/fonts/DarkGardenMK.afm" > > > ........ > > If it helps, I can say that we used to run Django via > mod_python, but did not see this particular issue. > > First off it seems particularly strange that you see > DarkGardenMK.afm(or earlier > LetError) mentioned. We include this font purely as an > exemplar of a type 1 font. So far as I know none of the > standard library code is actually using it. I believe it may > be mentioned in reportlab/graphics/testshapes.py. Are you > importing that module or are you explicitly using this font? > > Apache+mod_python presumably runs as a special user say www; > does that > Apache+cause any > problems of reading etc etc? > > Secondly as your apache test seems to imply this may be a > threading issue. The base ReportLab toolkit is not thread > safe. Thus if one thread is in the process of reading a file > when another thread attempts to open the same file it's > entirely possible that something odd may happen. Calling the > reset function may actually make things worse for > multi-threaded programs. > > We run django using flup > (http://www.saddi.com/projects/index.html) in prefork mode > and have never had any serious issues. > > My experience of the mod_python approach was that we did > encounter some problems related to threading and/or > encapsulation (ie privacy between apps). In the flup prefork > approach at least I believe the django wsgi server is running > single threaded; also since we control the startup of the > server as a normal user then only the flup socket needs to be > writable by www. > -- > Robin Becker > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > From IStevens at globeandmail.com Wed Oct 28 15:45:26 2009 From: IStevens at globeandmail.com (Stevens, Ian) Date: Wed, 28 Oct 2009 15:45:26 -0400 Subject: [reportlab-users] Intermittent failure to find font, followed by IOError In-Reply-To: <4AE824C5.5070102@chamonix.reportlab.co.uk> References: <956003ae0901191437pe94829ctd39af7b19a8bb50c@mail.gmail.com> <956003ae0901200939g3d13a289ob80296b40e2923cc@mail.gmail.com><4976168A.2050406@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> <4AE824C5.5070102@chamonix.reportlab.co.uk> Message-ID: <935E6400826049439C33D7BC3DC930360CEF7F7D@GMEXMBS1.globeandmail.net> Thanks for taking the time to think about this issue, Robin. I admit it's an odd behaviour, especially seeing as though we never make use of that font or any fonts included with Reportlab. We also don't use the reportlab.graphics.testshapes module. It feels like a symptom of a larger problem. The fonts are owned by root, but readable by everyone. If something were altering the rights for those files, then presumably the error would not have gone away when we changed MaxRequestsPerChild to 1. With respect to multi-threading, I spoke to our operations dept. I had thought we were using Apache prefork, but they have it set up for worker instead. They had it set up with prefork at one point but apparently the errors still occurred, and were more frequent. I instructed them to switch back to prefork. The font errors immediately started coming through with increased frequency. That is odd as I would expect the errors to occur more under worker than prefork. I'll check out the WSGI with flup option and see if that fixes things. Thanks, Ian. > -----Original Message----- > From: reportlab-users-bounces at lists2.reportlab.com > [mailto:reportlab-users-bounces at lists2.reportlab.com] On > Behalf Of Robin Becker > Sent: October 28, 2009 7:02 AM > To: Support list for users of Reportlab software > Subject: Re: [reportlab-users] Intermittent failure to find > font, followed by IOError > > Stevens, Ian wrote: > > Hi all. Earlier this year, I posted a problem we had been > having with our production servers. > > > ........ > > IOError: Cannot open resource > "/usr/lib/python2.5/site-packages/reportlab/fonts/DarkGardenMK.afm" > > > ........ > > If it helps, I can say that we used to run Django via > mod_python, but did not see this particular issue. > > First off it seems particularly strange that you see > DarkGardenMK.afm(or earlier > LetError) mentioned. We include this font purely as an > exemplar of a type 1 font. So far as I know none of the > standard library code is actually using it. I believe it may > be mentioned in reportlab/graphics/testshapes.py. Are you > importing that module or are you explicitly using this font? > > Apache+mod_python presumably runs as a special user say www; > does that > Apache+cause any > problems of reading etc etc? > > Secondly as your apache test seems to imply this may be a > threading issue. The base ReportLab toolkit is not thread > safe. Thus if one thread is in the process of reading a file > when another thread attempts to open the same file it's > entirely possible that something odd may happen. Calling the > reset function may actually make things worse for > multi-threaded programs. > > We run django using flup > (http://www.saddi.com/projects/index.html) in prefork mode > and have never had any serious issues. > > My experience of the mod_python approach was that we did > encounter some problems related to threading and/or > encapsulation (ie privacy between apps). In the flup prefork > approach at least I believe the django wsgi server is running > single threaded; also since we control the startup of the > server as a normal user then only the flup socket needs to be > writable by www. > -- > Robin Becker > _______________________________________________ > reportlab-users mailing list > reportlab-users at lists2.reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > From Robert at AbilitySys.com Wed Oct 28 18:05:35 2009 From: Robert at AbilitySys.com (Robert Young) Date: Wed, 28 Oct 2009 15:05:35 -0700 Subject: [reportlab-users] Page headings in platypus Message-ID: <387B7630D8F908498B9F02EE181EDB290A9520@ability-ntn.AbilitySys.local> I am trying to write code that will place a "continued" heading on a page. I have added all the "paragraphs" to a "story" and once they are all added, I use the build method and can place global page headers with no p[problem. However, I want to add a section heading when the data flows on to the next page. For example, the data looks like this: Section 1 Line 1 Line 2 Line 3 ... Line n Section 2 Line 1 Line 2 Line 3 ... Line n When a section flows on to a new page, I want to add the heading "Section 1 (continued)." The problem is, the pagination occurs long after the "story" is built, so I have no idea where the break is occurring, and I don't really want to hard code a break anyhow. How can I detect during the build where a break occurs, and how can I determine the appropriate data to print at that time? Is there such an attribute as a paragraph header? Thanks in advance, - Robert -------------- next part -------------- An HTML attachment was scrubbed... URL: From gherman at darwin.in-berlin.de Thu Oct 29 06:12:14 2009 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 29 Oct 2009 11:12:14 +0100 Subject: [reportlab-users] Gantt charts? Message-ID: <20091029111214.94212ke1eydy4rjy@webmail.in-berlin.de> Hi, does anybody here know of a Gantt charts [1] module using reportlab, maybe one that pimps up the existing bar charts? Thanks, Dinu [1] http://en.wikipedia.org/wiki/Gantt From robin at reportlab.com Thu Oct 29 07:46:56 2009 From: robin at reportlab.com (Robin Becker) Date: Thu, 29 Oct 2009 11:46:56 +0000 Subject: [reportlab-users] Intermittent failure to find font, followed by IOError In-Reply-To: <935E6400826049439C33D7BC3DC930360CEF7F7D@GMEXMBS1.globeandmail.net> References: <956003ae0901191437pe94829ctd39af7b19a8bb50c@mail.gmail.com> <956003ae0901200939g3d13a289ob80296b40e2923cc@mail.gmail.com><4976168A.2050406@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> <4AE824C5.5070102@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F7D@GMEXMBS1.globeandmail.net> Message-ID: <4AE980B0.2090005@chamonix.reportlab.co.uk> Stevens, Ian wrote: > Thanks for taking the time to think about this issue, Robin. I admit it's an odd behaviour, especially seeing as though we never make use of that font or any fonts included with Reportlab. We also don't use the reportlab.graphics.testshapes module. It feels like a symptom of a larger problem. > > The fonts are owned by root, but readable by everyone. If something were altering the rights for those files, then presumably the error would not have gone away when we changed MaxRequestsPerChild to 1. > > With respect to multi-threading, I spoke to our operations dept. I had thought we were using Apache prefork, but they have it set up for worker instead. They had it set up with prefork at one point but apparently the errors still occurred, and were more frequent. I instructed them to switch back to prefork. The font errors immediately started coming through with increased frequency. That is odd as I would expect the errors to occur more under worker than prefork. > > I'll check out the WSGI with flup option and see if that fixes things. > > Thanks, > Ian. ........ If as you suggest the code is currently running single threaded then this cannot be a threading issue. Thinking about this more clearly for a second I came to the conclusion that it's not required for your code actually to want to use this font. What's happening is that some other font is being requested that is not known about and the brute force search code is attempting to read afm files to try and figure out if the name embedded therein corresponds to the requested font name. Of course we expect that DarkGarden is not the required font and the brute force search should open the file, read it and reject and then continue to look for other fonts. Apparantly the bruteforce search program was able to locate the file DarkGardenMK.afm and is attempting to read it, but when that fails the error is propagated up the tree. What is annoying is that the traceback doesn't give information about exactly what font is being requested. It should be possible to instrument brute force search to indicate which font is being requested ie change the code in pdfmetrics.py to look like ####################### def bruteForceSearchForAFM(faceName): """Looks in all AFM files on path for face with given name. Returns AFM file name or None. Ouch!""" from reportlab.rl_config import T1SearchPath for dirname in T1SearchPath: if not rl_isdir(dirname): continue possibles = rl_glob(dirname + os.sep + '*.[aA][fF][mM]') for possible in possibles: try: topDict, glyphDict = parseAFMFile(possible) except: import sys t,v,b=sys.exc_info() v.args = v.args + (' while looking for faceName=%r' % faceName) raise if topDict['FontName'] == faceName: return possible ####################### that should at least enable you to figure out why the brute force is being done. However, that doesn't answer the question why the brute force search fails to read this file. In fact it could be argued that a simple failure to parse the file shouldn't result in a failure at all, but we wouldn't want to ignore all errors here any how. To see exactly why that happens, I suspect you need to dump out quite a lot of stuff about the running process when the error actually occurs. It so happens that reportlab contains a utility class for this purpose. So if your experts concur you can try putting this extra code in place at the error site def open_for_read(name,mode='b', urlopen=urllib.urlopen): '''attempt to open a file or URL for reading''' if hasattr(name,'read'): return name try: return open_for_read_by_name(name,mode) except: try: return getStringIO(urlopen(name).read()) except: ################### start extra code if name=="/usr/lib/python2.5/site-packages/reportlab/fonts/DarkGardenMK.afm": dbg = DebugMemo(fn='/tmp/dbgmemo.dbg') dbg.dump() ################### end extra code raise IOError('Cannot open resource "%s"' % name) hopefully this will create a file called /tmp/dbgmemo.dbg when the error occurs (The DebugMemo class is in utils.py already so shouldn't need importing etc etc). In order to decode the result you need a tiny script that looks like #!/usr/bin/python def main(): from reportlab.lib.utils import DebugMemo dbg = DebugMemo(fn='/tmp/dbgmemo.dbg',mode='r') dbg.load() dbg.show() if __name__=='__main__': main() perhaps that will give some clue as to why the running process cannot actually read these files. -- Robin Becker From robin at reportlab.com Thu Oct 29 10:43:10 2009 From: robin at reportlab.com (Robin Becker) Date: Thu, 29 Oct 2009 14:43:10 +0000 Subject: [reportlab-users] Intermittent failure to find font, followed by IOError In-Reply-To: <935E6400826049439C33D7BC3DC930360CEF7F7D@GMEXMBS1.globeandmail.net> References: <956003ae0901191437pe94829ctd39af7b19a8bb50c@mail.gmail.com> <956003ae0901200939g3d13a289ob80296b40e2923cc@mail.gmail.com><4976168A.2050406@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F30@GMEXMBS1.globeandmail.net> <4AE824C5.5070102@chamonix.reportlab.co.uk> <935E6400826049439C33D7BC3DC930360CEF7F7D@GMEXMBS1.globeandmail.net> Message-ID: <4AE9A9FE.6040306@chamonix.reportlab.co.uk> My hack to bruteForceSearchForAFM missed out a comma, here's a better version def bruteForceSearchForAFM(faceName): """Looks in all AFM files on path for face with given name. Returns AFM file name or None. Ouch!""" from reportlab.rl_config import T1SearchPath for dirname in T1SearchPath: if not rl_isdir(dirname): continue possibles = rl_glob(dirname + os.sep + '*.[aA][fF][mM]') for possible in possibles: try: topDict, glyphDict = parseAFMFile(possible) if topDict['FontName'] == faceName: return possible except: t,v,b=sys.exc_info() v.args = (' '.join(v.args)+', while looking for faceName=%r' % faceName,) raise -- Robin Becker From jtk at yahoo.com Sat Oct 31 12:22:09 2009 From: jtk at yahoo.com (Jeff Kowalczyk) Date: Sat, 31 Oct 2009 09:22:09 -0700 (PDT) Subject: [reportlab-users] Reportlab SVN repository inaccessible via https with recent svn/neon versions Message-ID: <7128.32590.qm@web63408.mail.re1.yahoo.com> The reportlab SVN repository is inaccessible via https for users with recent versions of neon, a dependency of subversion. Regenerating the server certificate should correct the problem, details below: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548773 Debian Bug report logs - #548773 [libneon27-gnutls] authentication to subversion via https fails with "Insecure Algorithm" error An example of the error message on my system: $ svn co https://svn.reportlab.com/svn/public/reportlab/trunk reportlab svn: OPTIONS of 'https://svn.reportlab.com/svn/public/reportlab/trunk': Certificate verification error: signed using insecure algorithm (https://svn.reportlab.com) $ git svn clone -s https://svn.reportlab.com/svn/public/reportlab Initialized empty Git repository in /software/reportlab/.git/ RA layer request failed: OPTIONS of 'https://svn.reportlab.com/svn/public/reportlab': Certificate verification error: signed using insecure algorithm (https://svn.reportlab.com) at /usr/libexec/git-core/git-svn line 1869 with the following versions of neon and subversion: net-misc/neon-0.29.0 USE="expat gnutls nls ssl zlib -doc -kerberos -libproxy -pkcs11" LINGUAS="-cs -de -fr -ja -nn -pl -ru -tr -zh_CN" dev-util/subversion-1.6.6 USE="apache2 bash-completion gnome-keyring nls perl python ruby sasl webdav-neon -berkdb -ctypes-python -debug -doc -dso -emacs -extras -java -kde -test -vim-syntax -webdav-serf" Thanks, Jeff From jeff.oneill at openstv.org Sat Oct 31 14:51:54 2009 From: jeff.oneill at openstv.org (Jeffrey O'Neill) Date: Sat, 31 Oct 2009 14:51:54 -0400 Subject: [reportlab-users] restart page numbering Message-ID: I have a document with a title page, a TOC page, and then body pages with the substance of the report. I do the page numbers using platypus, and have set the page templates so that only the body pages have page numbers on them. Currently, the first body page starts with page number 3. Is there a way to change this so that the first body page is number 1? best, Jeff From ralsina at netmanagers.com.ar Sat Oct 31 16:02:18 2009 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Sat, 31 Oct 2009 18:02:18 -0200 Subject: [reportlab-users] Bug in invariant? Message-ID: <200910311702.19010.ralsina@netmanagers.com.ar> Hello, when trying to generate PDFs with invariant=1 in local_rl_config.py so that tests don't fail because of timestamps in rst2pdf we found that files still were different when generated by two persons. And the difference was this: $ ls -l 65* -rw-r--r-- 1 ralsina users 16703 2009-10-31 16:34 65_patrick.pdf -rw-r--r-- 1 ralsina users 16703 2009-10-31 16:35 65_roberto.pdf The only difference between them is... /CreationDate (D:20000101000000+06'00') /CreationDate (D:20000101000000+03'00') As you can see, the date is being fixed, but the timezone is not. I suspect when the support for gmt offset was added, this slipped. The fix is to change PDFDate like this (or something similar): class PDFDate: __PDFObject__ = True # gmt offset now suppported def __init__(self, invariant=rl_config.invariant, dateFormatter=None): if invariant: now = (2000,01,01,00,00,00,0) self.dhh = 0; self.dmm = 0 else: import time now = tuple(time.localtime(_getTimeStamp())[:6]) from time import timezone self.dhh, self.dmm = timezone // 3600, (timezone % 3600) % 60 self.date = now[:6] self.dateFormatter = dateFormatter def format(self, doc): dfmt = self.dateFormatter or ( lambda yyyy,mm,dd,hh,m,s: "D:%04d%02d%02d%02d%02d%02d%+03d'%02d'" % (yyyy,mm,dd,hh,m,s,self.dhh,self.dmm)) return format(PDFString(dfmt(*self.date)), doc) -- ("\''/").__..-''"`-. . Roberto Alsina `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH) (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007)