From IStevens at globeandmail.com Fri Aug 1 13:54:52 2008 From: IStevens at globeandmail.com (Stevens, Ian) Date: Fri, 1 Aug 2008 13:54:52 -0400 Subject: [reportlab-users] French formatting of decimal for chart label axis Message-ID: Hi everyone. I have a plot, specifying the label format as a percent for the yValueAxis like so: plot.yValueAxis.labelTextFormat = '%1.1f%%' That's fine for English decimals, eg. 3.5%, but now there's a requirement for French decimal format, eg. 3,5%. How would I acheive this using the labelTextFormat property? thanks, Ian. -------------- next part -------------- An HTML attachment was scrubbed... URL: From haraldarminmassa at gmail.com Fri Aug 1 14:27:06 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Fri, 1 Aug 2008 20:27:06 +0200 Subject: [reportlab-users] French formatting of decimal for chart label axis In-Reply-To: References: Message-ID: <7be3f35d0808011127u60240269ka1a623c2393b460@mail.gmail.com> Ian, If you have floating point numbers, you can use locale from the python standard lib. If you are using Decimals from decimal.Decimal, the most effective way is to use pybabel. I tried to avoid another dependencie, but everything else takes even more time. So: be as wise as I am now, not as I was before, and use pybabel from the start :) Harald On Fri, Aug 1, 2008 at 19:54, Stevens, Ian wrote: > Hi everyone. I have a plot, specifying the label format as a percent for > the yValueAxis like so: > > plot.yValueAxis.labelTextFormat = '%1.1f%%' > > That's fine for English decimals, eg. 3.5%, but now there's a requirement > for French decimal format, eg. 3,5%. How would I acheive this using the > labelTextFormat property? > > thanks, > Ian. > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From IStevens at globeandmail.com Fri Aug 1 15:58:50 2008 From: IStevens at globeandmail.com (Stevens, Ian) Date: Fri, 1 Aug 2008 15:58:50 -0400 Subject: [reportlab-users] French formatting of decimal for chart labelaxis In-Reply-To: <7be3f35d0808011127u60240269ka1a623c2393b460@mail.gmail.com> Message-ID: Thanks. I didn't use locales as they are not properly set up on the server from which I'm running Reportlab. Howver, I just realised that labelTextFormat also accepts a function so I will be using that to my advantage. Ian. > -----Original Message----- > From: reportlab-users-bounces at reportlab.com > [mailto:reportlab-users-bounces at reportlab.com] On Behalf Of > Harald Armin Massa > Sent: Friday, August 01, 2008 2:27 PM > To: Support list for users of Reportlab software > Subject: Re: [reportlab-users] French formatting of decimal > for chart labelaxis > > Ian, > > If you have floating point numbers, you can use locale from > the python standard lib. > > If you are using Decimals from decimal.Decimal, the most > effective way is to use pybabel. I tried to avoid another > dependencie, but everything else takes even more time. So: be > as wise as I am now, not as I was before, and use pybabel > from the start :) > > Harald > > On Fri, Aug 1, 2008 at 19:54, Stevens, Ian > wrote: > > Hi everyone. I have a plot, specifying the label format as > a percent > > for the yValueAxis like so: > > > > plot.yValueAxis.labelTextFormat = '%1.1f%%' > > > > That's fine for English decimals, eg. 3.5%, but now there's a > > requirement for French decimal format, eg. 3,5%. How would > I acheive > > this using the labelTextFormat property? > > > > thanks, > > Ian. > > > > _______________________________________________ > > reportlab-users mailing list > > reportlab-users at reportlab.com > > http://two.pairlist.net/mailman/listinfo/reportlab-users > > > > > > > > -- > GHUM Harald Massa > persuadere et programmare > Harald Armin Massa > Spielberger Stra?e 49 > 70435 Stuttgart > 0173/9409607 > no fx, no carrier pigeon > - > EuroPython 2009 will take place in Birmingham - Stay tuned! > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > From labaker at teleport.com Mon Aug 4 12:43:34 2008 From: labaker at teleport.com (Lang Baker) Date: Mon, 4 Aug 2008 09:43:34 -0700 Subject: [reportlab-users] balanced text columns References: Message-ID: <006b01c8f651$412cd460$8065fea9@n9l9t1> Hi, Is there an easy way to equalize the height of adjacent text columns? For example, on page 4 of the output from the dodyssey.py demo, all text is in the left column. In that example, I'd like for half of the text on page 4 appear in the right column so the two columns would be the same height. Thanks for any help, Lang From nathan.stocks at gmail.com Wed Aug 6 15:07:34 2008 From: nathan.stocks at gmail.com (Nathan) Date: Wed, 6 Aug 2008 13:07:34 -0600 Subject: [reportlab-users] Is Reportlab Toolkit still live? Message-ID: <96c9d6a80808061207h2b577b41q71c1ebb7f5c8bad2@mail.gmail.com> Hi, I'm new to the mailing list. Is Reportlab Toolkit still an active project? The release notes list the last release as being in 2004, the downloads page has links to a release in 2007, and the link to the user's guide on the download page is simply broken. The web page seems to have been mostly abandoned. http://www.reportlab.org/rsrc/userguide.pdf I'm just looking for a good pdf-generation solution that works with python, but I don't want to invest my time in reportlab if it has been abandoned. Should I be looking elsewhere, or is reportlab worth looking into? ~ Nathan From timr at probo.com Wed Aug 6 15:19:21 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 06 Aug 2008 12:19:21 -0700 Subject: [reportlab-users] Is Reportlab Toolkit still live? In-Reply-To: <96c9d6a80808061207h2b577b41q71c1ebb7f5c8bad2@mail.gmail.com> References: <96c9d6a80808061207h2b577b41q71c1ebb7f5c8bad2@mail.gmail.com> Message-ID: <4899F939.2040406@probo.com> Nathan wrote: > Hi, I'm new to the mailing list. > > Is Reportlab Toolkit still an active project? The release notes list > the last release as being in 2004, the downloads page has links to a > release in 2007, and the link to the user's guide on the download page > is simply broken. The web page seems to have been mostly abandoned. > > http://www.reportlab.org/rsrc/userguide.pdf > > I'm just looking for a good pdf-generation solution that works with > python, but I don't want to invest my time in reportlab if it has been > abandoned. Should I be looking elsewhere, or is reportlab worth > looking into? > I'm always amazed when I encounter this kind of sentiment, and it is very common in the open source world. We rag on Microsoft for releasing new versions every year with a bazillion features that we'll never use, but when an open source product reaches a state of maturity, we start to complain about it being abandoned. Reportlab serves a rather well-focused purpose: it allows Python programs to create PDF files. Once a project has reached a point where it fulfills the purpose for which it was designed without major bugs, why should there continue to be 6 releases a year? I, for one, don't want to see gratuitous revolutions in the APIs I rely on. In summary, the ReportLab toolkit does its job very well. The developers and maintainers are active on this mailing list, and will gladly answer technical questions. Beyond that, I don't know what kind of development you would expect to see. (By the way, the Reportlab toolkit is one version of a product that the Reportlab team sells commercially, so as long as the company is still in business, the open source version will continue to be supported.) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From nathan.stocks at gmail.com Wed Aug 6 15:35:06 2008 From: nathan.stocks at gmail.com (Nathan) Date: Wed, 6 Aug 2008 13:35:06 -0600 Subject: [reportlab-users] Is Reportlab Toolkit still live? In-Reply-To: <4899F939.2040406@probo.com> References: <96c9d6a80808061207h2b577b41q71c1ebb7f5c8bad2@mail.gmail.com> <4899F939.2040406@probo.com> Message-ID: <96c9d6a80808061235k4789ee1cg5418252fffd597e3@mail.gmail.com> On Wed, Aug 6, 2008 at 1:19 PM, Tim Roberts wrote: > I'm always amazed when I encounter this kind of sentiment, and it is very > common in the open source world. We rag on Microsoft for releasing new > versions every year with a bazillion features that we'll never use, but when > an open source product reaches a state of maturity, we start to complain > about it being abandoned. I think you've misunderstood my question. The question was "is reportlab an active project?" with a followup of "these are the reason's I'm not confident that it's an active project by looking at the web site." I didn't ask for more releases or for more features. > In summary, the ReportLab toolkit does its job very well. The developers > and maintainers are active on this mailing list, and will gladly answer > technical questions. Good. That's the information I was looking for. Thanks! > Beyond that, I don't know what kind of development you > would expect to see. Given my first response above, responding to this question would be nonsensical. However, if your question were "what would you expect to see on a web site of a typical active open source project," then my answer would be "not something that appeared to have only had a couple of download links updated since 2004." If no one wants to update the web site, I don't really care much, but you shouldn't be surprised to get questions about it from new or potential users reading about the "2-3 month" release cycle that only produced one _apparent_ release on the site over the last four years (the release notes page lists latest release as being in 2004, while the download page links to a 2007 release). > (By the way, the Reportlab toolkit is one version of a product that the > Reportlab team sells commercially, so as long as the company is still in > business, the open source version will continue to be supported.) Also good to know, thanks. I really wasn't trying to complain, you know! I just wanted to make sure that someone was really out there... ~ Nathan From clazzery at mfsadmin.com Thu Aug 7 17:00:33 2008 From: clazzery at mfsadmin.com (Christopher Lazzery) Date: Thu, 7 Aug 2008 17:00:33 -0400 Subject: [reportlab-users] Newbie syntax help Message-ID: <0747426EBA960C4891A2A5A4DB1B584D30F46E@meridiannyc.mfsadmin.local> Hi everyone. I'm brand new to Python and ReportLab and I am just trying to find some good tutorials out there to get me started. After reading up, I tried to start working with some of the functions to see if I could make something simple. I was hoping someone could explain some of the parameters in this one function: def box(flt, center=False): box_style = [('BOX', (0, 0), (-1, -1), .5, colors.lightgrey)] if center: box_style += [('ALIGN', (0, 0), (-1, -1), 'CENTER')] return Table([[flt]], style=box_style) elements = [] styles = getSampleStyleSheet() doc = SimpleDocTemplate('simplebox.pdf') elements.append(box(Paragraph("Some Text Goes Here", styles['Title']))) doc.build(elements) Now, that builds a simple string of text with a thin grey box around it, as I'm sure you can tell. I'm confused about the "(0, 0), (-1,-1)" in the box function though. From what I've read, I think those are coordinates, but I have no idea what they do (if they even are coordinates). If I change any of the numbers, the box doesn't move. It disappears. So, what are these parameters? Are they coordinates? I know this seems like a silly question, but neither the User Guide nor any other documentation I have found seems to explain it. Thanks for any help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Thu Aug 7 17:19:08 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 07 Aug 2008 14:19:08 -0700 Subject: [reportlab-users] Newbie syntax help In-Reply-To: <0747426EBA960C4891A2A5A4DB1B584D30F46E@meridiannyc.mfsadmin.local> References: <0747426EBA960C4891A2A5A4DB1B584D30F46E@meridiannyc.mfsadmin.local> Message-ID: <489B66CC.4060208@probo.com> Christopher Lazzery wrote: > > Hi everyone. I'm brand new to Python and ReportLab and I am just > trying to find some good tutorials out there to get me started. > > After reading up, I tried to start working with some of the functions > to see if I could make something simple. > > I was hoping someone could explain some of the parameters in this one > function: > > def box(flt, center=False): > box_style = [('BOX', (0, 0), (-1, -1), .5, colors.lightgrey)] > if center: > box_style += [('ALIGN', (0, 0), (-1, -1), 'CENTER')] > > return Table([[flt]], style=box_style) > > elements = [] > styles = getSampleStyleSheet() > doc = SimpleDocTemplate('simplebox.pdf') > > elements.append(box(Paragraph("Some Text Goes Here", > styles['Title']))) > > doc.build(elements) > > Now, that builds a simple string of text with a thin grey box around > it, as I'm sure you can tell. I'm confused about the "(0, 0), (-1,-1)" > in the box function though. From what I've read, I think those are > coordinates, but I have no idea what they do (if they even are > coordinates). If I change any of the numbers, the box doesn't move. It > disappears. So, what are these parameters? Are they coordinates? I > know this seems like a silly question, but neither the User Guide nor > any other documentation I have found seems to explain it. > The general rule in Python is that negative coordinates start counting from the end. [0] is the first of something, [-1] is the last of something. The two tuples in the style declarations give the coordinates of two corners of the rectangle of cells that this style should apply to. So, (0,0) means the cell at column 0, row 0; upper left hand corner. (-1,-1) means the cell in the right-most column, bottom-most row; lower right hand corner. So, both of these styles apply to the whole table. If you change the first one to (1,0),(-1,-1), it would apply to all cells except the first column. It is common to want a different style for the top row ( (0,0),(-1,0) ), or the left column ( (0,0),(0,-1) ). -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From andy at reportlab.com Fri Aug 8 10:19:03 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 8 Aug 2008 16:19:03 +0200 Subject: [reportlab-users] Is Reportlab Toolkit still live? In-Reply-To: <96c9d6a80808061235k4789ee1cg5418252fffd597e3@mail.gmail.com> References: <96c9d6a80808061207h2b577b41q71c1ebb7f5c8bad2@mail.gmail.com> <4899F939.2040406@probo.com> <96c9d6a80808061235k4789ee1cg5418252fffd597e3@mail.gmail.com> Message-ID: <956003ae0808080719r13d02dcck7e31546e21d2747a@mail.gmail.com> 2008/8/6 Nathan : > I really wasn't trying to complain, you know! I just wanted to make > sure that someone was really out there... The main problem is that we at ReportLab have been rather too successful and our commercial customers keep us working flat out on solutions we maintain for them (which all use the underlying library), and never seem to get time to produce new releases or update the docs. However the SVN history should reveal that we make minor fixes and enhancements from time to time. We are hoping to do a release later this year and document the last 18 months of minor fixes, but I do not want to make a firm promise. Rest assured that patches get reviewed, reproducible bugs get fixed fast, and you will get answers on this list - often from our star users like Tim. Best Regards, -- Andy Robinson CEO/Chief Architect ReportLab Europe Ltd. 165 The Broadway, Wimbledon, London SW19 1NE, UK Tel +44-20-8544-8049 From volker.haas at brainbot.com Fri Aug 8 10:30:07 2008 From: volker.haas at brainbot.com (Volker Haas) Date: Fri, 08 Aug 2008 16:30:07 +0200 Subject: [reportlab-users] underlining text broken? Message-ID: <489C586F.4070907@brainbot.com> I have the impression that underlining text is broken. In the below example the space behind the underlined word is also underlined: from reportlab.platypus.paragraph import Paragraph from reportlab.platypus.doctemplate import SimpleDocTemplate from reportlab.lib.styles import ParagraphStyle doc = SimpleDocTemplate('test.pdf') elements = [Paragraph('blub underlined blub', ParagraphStyle('Normal'))] doc.build(elements) -- volker haas brainbot technologies ag fon +49 6131 2116394 boppstra?e 64 fax +49 6131 2116392 55118 mainz volker.haas at brainbot.com http://www.brainbot.com/ From wilk at flibuste.net Fri Aug 8 10:35:59 2008 From: wilk at flibuste.net (William Dode) Date: Fri, 8 Aug 2008 14:35:59 +0000 (UTC) Subject: [reportlab-users] error in tables.py (rl 1.21.2) References: <487B1587.6060306@chamonix.reportlab.co.uk> Message-ID: Hi, Could you reproduce this bug ? I switched to reportlab 2.1 (debian lenny) and it's still present. > from reportlab.platypus import BaseDocTemplate, Frame, Paragraph, NextPageTemplate, PageBreak, PageTemplate, Spacer, KeepTogether, Flowable > from reportlab.lib.pagesizes import A4, landscape, portrait, cm > from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle > from reportlab.lib.enums import TA_LEFT, TA_CENTER > from reportlab.lib import colors > from reportlab.platypus.tables import TableStyle, LongTable, Table > f=open('/tmp/t.pdf','w') > frame = Frame(2 * cm, 2 * cm , A4[0] - 4 * cm, A4[1] - 6*cm) > doc = BaseDocTemplate(f, pagesize=A4) > doc.addPageTemplates(PageTemplate('i',frame)) > style_para = getSampleStyleSheet()['Normal'] > style_para.spaceAfter = 12 > > elements = [] > for z in (3,6,3,5,12,7,3,4,6,3,8): > elements.append( Paragraph('toto',style_para)) > elements.append(LongTable([('x') for x in range(z)], repeatRows=1)) > > doc.build(elements) File "/usr/lib/python2.5/site-packages/reportlab/platypus/tables.py", line 1139, in _getFirstPossibleSplitRowPosition if h+rh>availHeight: TypeError: unsupported operand type(s) for +: 'int' and 'NoneType' bye -- William Dod? - http://flibuste.net Informaticien Ind?pendant From robin at reportlab.com Fri Aug 8 11:59:34 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 08 Aug 2008 16:59:34 +0100 Subject: [reportlab-users] underlining text broken? In-Reply-To: <489C586F.4070907@brainbot.com> References: <489C586F.4070907@brainbot.com> Message-ID: <489C6D66.6040803@chamonix.reportlab.co.uk> Volker Haas wrote: > I have the impression that underlining text is broken. > > In the below example the space behind the underlined word is also > underlined: > > from reportlab.platypus.paragraph import Paragraph > from reportlab.platypus.doctemplate import SimpleDocTemplate > from reportlab.lib.styles import ParagraphStyle > > doc = SimpleDocTemplate('test.pdf') > elements = [Paragraph('blub underlined blub', > ParagraphStyle('Normal'))] > doc.build(elements) > > Yes I think you're right. I think the difficulty is that we split into words at spaces so that we don't normally have the spaces in the internal representation at all so if you wanted Paragraph('blub underlined blub') we would have a real difficulty. I suppose we ought to be able to handle these cases properly. -- Robin Becker From nathan.stocks at gmail.com Fri Aug 8 12:24:23 2008 From: nathan.stocks at gmail.com (Nathan) Date: Fri, 8 Aug 2008 10:24:23 -0600 Subject: [reportlab-users] Is Reportlab Toolkit still live? In-Reply-To: <956003ae0808080719r13d02dcck7e31546e21d2747a@mail.gmail.com> References: <96c9d6a80808061207h2b577b41q71c1ebb7f5c8bad2@mail.gmail.com> <4899F939.2040406@probo.com> <96c9d6a80808061235k4789ee1cg5418252fffd597e3@mail.gmail.com> <956003ae0808080719r13d02dcck7e31546e21d2747a@mail.gmail.com> Message-ID: <96c9d6a80808080924h1290e865t17f385eb5beea814@mail.gmail.com> On Fri, Aug 8, 2008 at 8:19 AM, Andy Robinson wrote: > 2008/8/6 Nathan : >> I really wasn't trying to complain, you know! I just wanted to make >> sure that someone was really out there... > > The main problem is that we at ReportLab have been rather too > successful and our commercial customers keep us working flat out on > solutions we maintain for them (which all use the underlying library), > and never seem to get time to produce new releases or update the docs. > However the SVN history should reveal that we make minor fixes and > enhancements from time to time. We are hoping to do a release later > this year and document the last 18 months of minor fixes, but I do not > want to make a firm promise. > > Rest assured that patches get reviewed, reproducible bugs get fixed > fast, and you will get answers on this list - often from our star > users like Tim. Sounds like a good problem to have for a business! Thanks for the in-depth response. I'll be going ahead and trying reportlab out when I start my project next week. It's nothing special (yet); so far, I just need to create a bunch of single-page pdf's with a logo at the top and text on the rest of the page. ~ Nathan From volker.haas at brainbot.com Mon Aug 11 06:26:58 2008 From: volker.haas at brainbot.com (Volker Haas) Date: Mon, 11 Aug 2008 12:26:58 +0200 Subject: [reportlab-users] too many open files with inline images Message-ID: <48A013F2.5050403@brainbot.com> I get an error (too many open files) when using lots of inline images inside paragraphs. Sample code: from reportlab.platypus.paragraph import Paragraph from reportlab.platypus.doctemplate import SimpleDocTemplate from reportlab.lib.styles import ParagraphStyle import os doc = SimpleDocTemplate('test.pdf') elements = [] for count in range(1024): print len(os.listdir("/proc/%d/fd" % os.getpid())) p = Paragraph('text ' , ParagraphStyle('Normal')) elements.append(p) doc.build(elements) OUTPUT: Traceback (most recent call last): File "test_fd.py", line 13, in OSError: [Errno 24] Too many open files: '/proc/32336/fd' If the print statement is omitted (which isn't really platform independent ;)) I get an IOError (IOError: Cannot open resource "math.png" fileName=math.png) . But I am pretty sure this only happens because no new file handle could be aquired. The sample code works if less images are used (my machines limit for open file handles is 1024 per process). I am not attaching the sample image, b/c the sample code behaves in the same way when the image file is not existent. Regards, Volker -- volker haas brainbot technologies ag fon +49 6131 2116394 boppstra?e 64 fax +49 6131 2116392 55118 mainz volker.haas at brainbot.com http://www.brainbot.com/ From aaron.barlow at gmail.com Mon Aug 11 14:00:48 2008 From: aaron.barlow at gmail.com (Aaron Barlow) Date: Mon, 11 Aug 2008 12:00:48 -0600 Subject: [reportlab-users] Support for OpenType Fonts Message-ID: I hopefully have a quick question. Does ReportLab support OpenType Fonts. I can't seem to find a definite yes or no in the documentation or Google. If there is support, how does one use them in ReportLab or RML? Thanks in advance. -- Aaron Barlow -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2427 bytes Desc: not available Url : From timr at probo.com Mon Aug 11 14:49:23 2008 From: timr at probo.com (Tim Roberts) Date: Mon, 11 Aug 2008 11:49:23 -0700 Subject: [reportlab-users] Support for OpenType Fonts In-Reply-To: References: Message-ID: <48A089B3.4030603@probo.com> Aaron Barlow wrote: > I hopefully have a quick question. Does ReportLab support OpenType > Fonts. I can't seem to find a definite yes or no in the documentation > or Google. If there is support, how does one use them in ReportLab or > RML? Thanks in advance. It's a bit of a trick question. OpenType fonts are really either TrueType or Type 1. On XP and beyond, for example, Arial is an OpenType font, and it works perfectly well in ReportLab. I'm not sure I have any OpenType fonts are that really Type 1 underneath, but I'd be surprised if they didn't work. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From robin at reportlab.com Tue Aug 12 05:53:59 2008 From: robin at reportlab.com (Robin Becker) Date: Tue, 12 Aug 2008 10:53:59 +0100 Subject: [reportlab-users] too many open files with inline images In-Reply-To: <48A013F2.5050403@brainbot.com> References: <48A013F2.5050403@brainbot.com> Message-ID: <48A15DB7.60809@chamonix.reportlab.co.uk> Volker Haas wrote: > I get an error (too many open files) when using lots of inline images > inside paragraphs. > > Sample code: > > from reportlab.platypus.paragraph import Paragraph > from reportlab.platypus.doctemplate import SimpleDocTemplate > from reportlab.lib.styles import ParagraphStyle > > import os > doc = SimpleDocTemplate('test.pdf') > elements = [] > > for count in range(1024): > print len(os.listdir("/proc/%d/fd" % os.getpid())) > p = Paragraph('text />' , ParagraphStyle('Normal')) > elements.append(p) > doc.build(elements) > > OUTPUT: > > Traceback (most recent call last): > File "test_fd.py", line 13, in > OSError: [Errno 24] Too many open files: '/proc/32336/fd' > I'm pretty sure this bug is not going to go away unless we rewrite the ImageReader fp handling stuff. The intent is that ImageReader should be able to handle a python file handle, a PIL image or a simple filename. To avoid excessive work we open the image at the front rather than at the back end. I suspect the only fix here is to delay opening(or reopen) in the case when when a path is given. In the cases when either a PIL image or an open file is passed I don't think there's any obvious way to cut down on the number of open files other than converting them into memory based objects. Of course it could be that we are being a bit stupid in not re-using the images if they're repeated often or that we are holding on to the image objects too long. > If the print statement is omitted (which isn't really platform > independent ;)) I get an IOError (IOError: Cannot open resource > "math.png" fileName=math.png) . But I am pretty sure this only happens > because no new file handle could be aquired. The sample code works if > less images are used (my machines limit for open file handles is 1024 > per process). > I am not attaching the sample image, b/c the sample code behaves in the > same way when the image file is not existent. > > Regards, > Volker > -- Robin Becker From ralf at brainbot.com Tue Aug 12 06:41:16 2008 From: ralf at brainbot.com (Ralf Schmitt) Date: Tue, 12 Aug 2008 12:41:16 +0200 Subject: [reportlab-users] too many open files with inline images In-Reply-To: <48A15DB7.60809@chamonix.reportlab.co.uk> References: <48A013F2.5050403@brainbot.com> <48A15DB7.60809@chamonix.reportlab.co.uk> Message-ID: <48A168CC.6080606@brainbot.com> Robin Becker wrote: > Volker Haas wrote: >> I get an error (too many open files) when using lots of inline images >> inside paragraphs. >> >> Sample code: >> >> from reportlab.platypus.paragraph import Paragraph >> from reportlab.platypus.doctemplate import SimpleDocTemplate >> from reportlab.lib.styles import ParagraphStyle >> >> import os >> doc = SimpleDocTemplate('test.pdf') >> elements = [] >> >> for count in range(1024): >> print len(os.listdir("/proc/%d/fd" % os.getpid())) >> p = Paragraph('text > />' , ParagraphStyle('Normal')) >> elements.append(p) >> doc.build(elements) >> >> OUTPUT: >> >> Traceback (most recent call last): >> File "test_fd.py", line 13, in >> OSError: [Errno 24] Too many open files: '/proc/32336/fd' >> > > I'm pretty sure this bug is not going to go away unless we rewrite the > ImageReader fp handling stuff. The intent is that ImageReader should be > able to handle a python file handle, a PIL image or a simple filename. > To avoid excessive work we open the image at the front rather than at > the back end. I suspect the only fix here is to delay opening(or reopen) > in the case when when a path is given. In the cases when either a PIL > image or an open file is passed I don't think there's any obvious way to > cut down on the number of open files other than converting them into > memory based objects. > Have a look at http://code.pediapress.com/wiki/attachment/ticket/214/lazy-reader.diff This implements lazy reading in case PIL is used and a file name is passed as argument. While I'm here: The following makes reportlab's setup.py work with virtualenv: ~/reportlab/ hg diff -r 2c0ab57eba39 ralf at red ok diff --git a/reportlab/setup.py b/reportlab/setup.py --- a/reportlab/setup.py +++ b/reportlab/setup.py @@ -5,20 +5,14 @@ import os, sys, distutils, glob from distutils.core import setup, Extension - -# from Zope - App.Common.package_home -def package_home(globals_dict): - __name__=globals_dict['__name__'] - m=sys.modules[__name__] - r=os.path.split(m.__path__[0])[0] - return r +from distutils.sysconfig import get_python_lib pjoin = os.path.join abspath = os.path.abspath isfile = os.path.isfile isdir = os.path.isfile dirname = os.path.dirname -package_path = pjoin(package_home(distutils.__dict__), 'site-packages', 'reportlab') +package_path = pjoin(get_python_lib(plat_specific=1), 'reportlab') def get_version(): #determine Version and one more: lot's of assert in reportlab's code have no effect: /home/ralf/py26/lib/python2.6/site-packages/mwlib.ext-0.8.2-py2.6-linux-x86_64.egg/mwlib/reportlab/pdfgen/pdfimages.py:108: SyntaxWarning: assertion is always true, perhaps remove parentheses? assert(len(raw) == imgwidth * imgheight, "Wrong amount of data for image") /home/ralf/py26/lib/python2.6/site-packages/mwlib.ext-0.8.2-py2.6-linux-x86_64.egg/mwlib/reportlab/graphics/renderPS.py:586: SyntaxWarning: assertion is always true, perhaps remove parentheses? assert(len(rawimage) == imgwidth*imgheight, 'Wrong amount of data for image') /home/ralf/py26/lib/python2.6/site-packages/mwlib.ext-0.8.2-py2.6-linux-x86_64.egg/mwlib/reportlab/graphics/renderPS.py:658: SyntaxWarning: assertion is always true, perhaps remove parentheses? assert(len(rawimage) == imwidth*imheight, 'Wrong amount of data for image') /home/ralf/py26/lib/python2.6/site-packages/mwlib.ext-0.8.2-py2.6-linux-x86_64.egg/mwlib/reportlab/pdfbase/pdfdoc.py:2056: SyntaxWarning: assertion is always true, perhaps remove parentheses? assert(len(raw) == self.width*self.height, "Wrong amount of data for image") /home/ralf/py26/lib/python2.6/site-packages/mwlib.ext-0.8.2-py2.6-linux-x86_64.egg/mwlib/reportlab/pdfbase/pdfutils.py:44: SyntaxWarning: assertion is always true, perhaps remove parentheses? assert(len(raw) == imgwidth * imgheight, "Wrong amount of data for image") Regards, - Ralf From p.j.a.cock at googlemail.com Tue Aug 12 12:53:18 2008 From: p.j.a.cock at googlemail.com (Peter Cock) Date: Tue, 12 Aug 2008 17:53:18 +0100 Subject: [reportlab-users] Problems with certain Greek letters and unicode Message-ID: <320fb6e00808120953w2aeef8cdq3afd42271af4b7fa@mail.gmail.com> I'm trying to include particular greek letters in a PDF file, and have been trying to do this with the canvas drawString and drawCentredString methods. In particular I want an upper case omega, Unicode u"\u03a9", but this is not the only problem I am seeing - upper case Delta and lower case mu are also failing. The following bit of code should illustrate the problem I am seeing using ReportLab 2.1 with Python 2.5.2 on Apple Mac OS X 10.5 Leopard, import reportlab from reportlab.pdfgen import canvas from reportlab.lib.units import cm y_scale=0.5*cm margin = 1*cm letters = [eval('u"\\u%04x"' % i) for i in \ range(int("0391",16), int("03a9",16)+1) +\ range(int("03b1",16),int("03c9",16)+1)] c = canvas.Canvas("greek.pdf", (8*cm, 2*margin + len(letters)*y_scale)) c.setFont('Helvetica', 12) for i,a in enumerate(letters) : c.drawString(1*cm, margin + i*y_scale, a) c.setFont('Symbol', 12) for i,a in enumerate(letters) : c.drawString(2*cm, margin + i*y_scale, a) c.setFont('Courier', 12) for i,a in enumerate(letters) : c.drawString(3*cm, margin + i*y_scale, a) c.setFont('Times-Roman', 12) for i,a in enumerate(letters) : c.drawString(4*cm, margin + i*y_scale, a) c.drawString(5*cm, margin + i*y_scale, repr(a)) c.drawCentredString(4*cm, margin + len(letters)*y_scale, "ReportLab %s" % reportlab.Version) c.showPage() c.save() This should print out the greek alphabet using their unicode values, however the following are showing as black rectangles (in all four fonts): U0394 - missing, upper case delta U03A2 - missing, because there is no uppercase variant of sigma at the end of a word U03A9 - missing, upper case omega U03BC - missing, lower case mu I can attach the PDF file if it helps. Any advice on how to get the missing three characters would be welcome. Thanks Peter From mjf at pearson.co.uk Wed Aug 13 05:22:02 2008 From: mjf at pearson.co.uk (Matt Folwell) Date: Wed, 13 Aug 2008 10:22:02 +0100 Subject: [reportlab-users] Problems with certain Greek letters and unicode In-Reply-To: <320fb6e00808120953w2aeef8cdq3afd42271af4b7fa@mail.gmail.com> References: <320fb6e00808120953w2aeef8cdq3afd42271af4b7fa@mail.gmail.com> Message-ID: <48A2A7BA.9040604@pearson.co.uk> Peter Cock wrote: > U0394 - missing, upper case delta > U03A2 - missing, because there is no uppercase variant of sigma at the > end of a word > U03A9 - missing, upper case omega > U03BC - missing, lower case mu Those (apart from sigma) are characters with more than 1 unicode codepoint, and the codec that reportlab registers for symbol only encodes the other one. The attached patch to rl_codecs.py will let you use those codepoints. Alternatively you can use U2126 OHM SIGN for Omega, U2206 INCREMENT for Delta and U00B5 MICRO SIGN for mu. As the other fonts don't contain the greek letters, reportlab's substituting them with symbol. Matt -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: symbol_codec.patch Url: From p.j.a.cock at googlemail.com Wed Aug 13 06:07:59 2008 From: p.j.a.cock at googlemail.com (Peter Cock) Date: Wed, 13 Aug 2008 11:07:59 +0100 Subject: [reportlab-users] Problems with certain Greek letters and unicode In-Reply-To: <48A2A7BA.9040604@pearson.co.uk> References: <320fb6e00808120953w2aeef8cdq3afd42271af4b7fa@mail.gmail.com> <48A2A7BA.9040604@pearson.co.uk> Message-ID: <320fb6e00808130307y6b9def2exf4d79b4ac0fcf491@mail.gmail.com> Hi Mat, On Wed, Aug 13, 2008 at 10:22 AM, Matt Folwell wrote: > Peter Cock wrote: > >> U0394 - missing, upper case delta >> U03A2 - missing, because there is no uppercase variant of sigma at the >> end of a word >> U03A9 - missing, upper case omega >> U03BC - missing, lower case mu > > Those (apart from sigma) are characters with more than 1 unicode codepoint, > and the codec that reportlab registers for symbol only encodes the other > one. The attached patch to rl_codecs.py will let you use those codepoints. I applied the patch by hand (diff didn't like it and it was trivial), and indeed that does solve my original problem. Could/should this be included in the official reportlab codebase? > Alternatively you can use U2126 OHM SIGN for Omega, U2206 INCREMENT > for Delta and U00B5 MICRO SIGN for mu. Using u"\u2206" for the increment (aka Delta) works, as does u"\u2126" for Ohms (aka Omega). Using u"\u00b5" for the micro sign (aka mu) works fine, but interestingly the four built in fonts I was using all seem to include their own versions of this character. Note that python will shorten this to just u'\xb5' which is equivalent (drops the leading double zero). Thanks for your help! Peter From Paul.Keating at nibc.com Wed Aug 13 08:13:38 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Wed, 13 Aug 2008 14:13:38 +0200 Subject: [reportlab-users] Page n of m? In-Reply-To: <48A2A7BA.9040604@pearson.co.uk> Message-ID: My users want a report that says "Page n of m" where m is the last page number. Is this possible? -- Paul Keating The Hague From yroman-reportlab at altalang.com Wed Aug 13 09:02:01 2008 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Wed, 13 Aug 2008 09:02:01 -0400 Subject: [reportlab-users] PTOContainer split problem Message-ID: <002001c8fd44$c6a82190$0502000a@ad.altalang.com> I'm running across a PTOContainer problem when the content is a single very large paragraph. Attached are two files: a simple Python script and a large text file (GNU GPL, in this case). If I try to use the doc.build([pto]) line, I get this: Traceback (most recent call last): File "pto_test.py", line 24, in doc.build([pto]) File "C:\Program Files\Python\lib\site-packages\reportlab\platypus\doctemplate .py", line 911, in build BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker) File "C:\Program Files\Python\lib\site-packages\reportlab\platypus\doctemplate .py", line 740, in build self.handle_flowable(flowables) File "C:\Program Files\Python\lib\site-packages\reportlab\platypus\doctemplate .py", line 671, in handle_flowable raise LayoutError(ident) reportlab.platypus.doctemplate.LayoutError: Flowable ... too large on page 2 The script runs fine if I skip the PTOContainer (i.e., use doc.build([p])). Am I doing something wrong or is there a bug somewhere? Thanks, -- Yoann Roman -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: pto_test.py Url: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: gnu.txt Url: From haraldarminmassa at gmail.com Wed Aug 13 09:25:09 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Wed, 13 Aug 2008 15:25:09 +0200 Subject: [reportlab-users] Page n of m? In-Reply-To: References: <48A2A7BA.9040604@pearson.co.uk> Message-ID: <7be3f35d0808130625r67557b4fg74215da2dfe418ea@mail.gmail.com> Yes, it is possible. Usually the solution is: 1) add "Page of" to the footer of your Page canv.drawRightString(10*cm, 0.75*cm, u"Page %s of % (doc.page,)) 2) add a PDF-Form to the place right of the "of" canv.doForm("pageCount") 3) render the PDF 4) after the rendering, fill the Number of Pages into PDF-Form which gets drawn after the "of" def _endBuild(self): self.canv.beginForm("pageCount") self.canv.setFont(fontnormal,7) self.canv.drawString(12*cm,0.75*cm u"%s" % (self.canv.getPageNumber(),)) self.canv.endForm() BaseDocTemplate._endBuild(self) Best wishes, Harald On Wed, Aug 13, 2008 at 14:13, wrote: > My users want a report that says "Page n of m" where m is the last page > number. > > Is this possible? > > -- > Paul Keating > The Hague > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From robin at reportlab.com Wed Aug 13 09:43:11 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 13 Aug 2008 14:43:11 +0100 Subject: [reportlab-users] PTOContainer split problem In-Reply-To: <002001c8fd44$c6a82190$0502000a@ad.altalang.com> References: <002001c8fd44$c6a82190$0502000a@ad.altalang.com> Message-ID: <48A2E4EF.8080207@chamonix.reportlab.co.uk> Yoann Roman wrote: > I'm running across a PTOContainer problem when the content is a single very > large paragraph. Attached are two files: a simple Python script and a large > text file (GNU GPL, in this case). > > If I try to use the doc.build([pto]) line, I get this: > > Traceback (most recent call last): > File "pto_test.py", line 24, in > doc.build([pto]) > File "C:\Program > Files\Python\lib\site-packages\reportlab\platypus\doctemplate > .py", line 911, in build > BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker) > File "C:\Program > Files\Python\lib\site-packages\reportlab\platypus\doctemplate > .py", line 740, in build > self.handle_flowable(flowables) > File "C:\Program > Files\Python\lib\site-packages\reportlab\platypus\doctemplate > .py", line 671, in handle_flowable > raise LayoutError(ident) > reportlab.platypus.doctemplate.LayoutError: Flowable 0x13cf508 > frame=normal>... too large on page 2 > > The script runs fine if I skip the PTOContainer (i.e., use doc.build([p])). > > Am I doing something wrong or is there a bug somewhere? > > Thanks, ...... there's nothing wrong with your example. I'm not sure what's causing the problem. It should be able to split the large paragraph. -- Robin Becker From robin at reportlab.com Wed Aug 13 09:57:26 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 13 Aug 2008 14:57:26 +0100 Subject: [reportlab-users] PTOContainer split problem In-Reply-To: <002001c8fd44$c6a82190$0502000a@ad.altalang.com> References: <002001c8fd44$c6a82190$0502000a@ad.altalang.com> Message-ID: <48A2E846.8030302@chamonix.reportlab.co.uk> Yoann Roman wrote: > I'm running across a PTOContainer problem when the content is a single very > large paragraph. Attached are two files: a simple Python script and a large > text file (GNU GPL, in this case). > > If I try to use the doc.build([pto]) line, I get this: ....... In fact I tried your large text by inserting this into our standard test case reportlab/test/test_platypus_pleaseturnover.py at line 127 textxxx=open('/tmp/yoannroman/gnu.txt','r').read() ptoblob('First Try at a PTO',[Paragraph(textxxx,bt)],t0,h0) and this works even if the style is a bit busted. -- Robin Becker From yroman-reportlab at altalang.com Wed Aug 13 10:33:35 2008 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Wed, 13 Aug 2008 10:33:35 -0400 Subject: [reportlab-users] PTOContainer split problem Message-ID: <003e01c8fd51$916fa310$0502000a@ad.altalang.com> Robin Becker wrote: > Yoann Roman wrote: > > I'm running across a PTOContainer problem when the content is a single very > > large paragraph. Attached are two files: a simple Python script and a large > > text file (GNU GPL, in this case). > > > > If I try to use the doc.build([pto]) line, I get this: > ....... > In fact I tried your large text by inserting this into our standard test case > reportlab/test/test_platypus_pleaseturnover.py at line 127 > > > textxxx=open('/tmp/yoannroman/gnu.txt','r').read() > ptoblob('First Try at a PTO',[Paragraph(textxxx,bt)],t0,h0) > > and this works even if the style is a bit busted. I was taking a similar approach this morning in troubleshooting this. Turns out I was importing Paragraph as: from reportlab.platypus.para import Paragraph Whereas test_platypus_pleaseturnover.py uses: from reportlab.platypus.paragraph import Paragraph I hadn't noticed the former was experimental. Changing my pto_test.py file to use the latter fixes the problem. I'm not sure what the official status of para.py is, so this may not be a bug at all. Thanks for the help, -- Yoann Roman From robin at reportlab.com Wed Aug 13 10:47:37 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 13 Aug 2008 15:47:37 +0100 Subject: [reportlab-users] PTOContainer split problem In-Reply-To: <003e01c8fd51$916fa310$0502000a@ad.altalang.com> References: <003e01c8fd51$916fa310$0502000a@ad.altalang.com> Message-ID: <48A2F409.7070501@chamonix.reportlab.co.uk> Yoann Roman wrote: > Robin Becker wrote: >> Yoann Roman wrote: >>> I'm running across a PTOContainer problem when the content is a single > very >>> large paragraph. Attached are two files: a simple Python script and a > large >>> text file (GNU GPL, in this case). >>> >>> If I try to use the doc.build([pto]) line, I get this: >> ....... >> In fact I tried your large text by inserting this into our standard test > case >> reportlab/test/test_platypus_pleaseturnover.py at line 127 >> >> >> textxxx=open('/tmp/yoannroman/gnu.txt','r').read() >> ptoblob('First Try at a PTO',[Paragraph(textxxx,bt)],t0,h0) >> >> and this works even if the style is a bit busted. > > I was taking a similar approach this morning in troubleshooting this. Turns > out I was importing Paragraph as: > > from reportlab.platypus.para import Paragraph > > Whereas test_platypus_pleaseturnover.py uses: > > from reportlab.platypus.paragraph import Paragraph > > I hadn't noticed the former was experimental. Changing my pto_test.py file > to use the latter fixes the problem. I'm not sure what the official status > of para.py is, so this may not be a bug at all. > > Thanks for the help, > Well spotted; that explains a lot. I suppose that para.py is no good in this instance for some reason. -- Robin Becker From haraldarminmassa at gmail.com Wed Aug 13 18:19:05 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Thu, 14 Aug 2008 00:19:05 +0200 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? Message-ID: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> Tried to update my reportlab 2.0 trunk libraries... but svn announces could not connect to server something broken? something moved? Best wishes HArald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From robin at reportlab.com Thu Aug 14 05:14:12 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 14 Aug 2008 10:14:12 +0100 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? In-Reply-To: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> References: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> Message-ID: <48A3F764.5020603@chamonix.reportlab.co.uk> Harald Armin Massa wrote: > Tried to update my reportlab 2.0 trunk libraries... but svn announces > > could not connect to server > > something broken? something moved? > > Best wishes > > HArald > We changed our external IP address on www.reportlab.co.uk about two weeks ago. Still have mailgate.reportlab.co.uk pointed wrongly, but I've just checked and the server is up and working to an external site. The new IP is 77.44.121.240. -- Robin Becker From haraldarminmassa at gmail.com Thu Aug 14 07:36:39 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Thu, 14 Aug 2008 13:36:39 +0200 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? In-Reply-To: <48A3F764.5020603@chamonix.reportlab.co.uk> References: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> <48A3F764.5020603@chamonix.reportlab.co.uk> Message-ID: <7be3f35d0808140436r51f3b28dkdbe83a1dece2927c@mail.gmail.com> Robin, thanks for the head up ... indeed, C:\libraries>ping www.reportlab.co.uk Ping www.reportlab.co.uk [77.44.121.240] mit 32 Bytes Daten ping gets 77.44.121.240. svn co http://www.reportlab.co.uk/svn/public/reportlab/trunk still fails with svn: PROPFIND request failed on '/svn/public/reportlab/trunk' svn: PROPFIND of '/svn/public/reportlab/trunk': could not connect to server (http://www.reportlab.co.uk) (I tried from 4 different ISPs) what else can I do? Harald > We changed our external IP address on www.reportlab.co.uk about two weeks > ago. Still have mailgate.reportlab.co.uk pointed wrongly, but I've just > checked and the server is up and working to an external site. The new IP is > 77.44.121.240. -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From robin at reportlab.com Thu Aug 14 08:21:20 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 14 Aug 2008 13:21:20 +0100 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? In-Reply-To: <7be3f35d0808140436r51f3b28dkdbe83a1dece2927c@mail.gmail.com> References: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> <48A3F764.5020603@chamonix.reportlab.co.uk> <7be3f35d0808140436r51f3b28dkdbe83a1dece2927c@mail.gmail.com> Message-ID: <48A42340.1080009@chamonix.reportlab.co.uk> Harald Armin Massa wrote: > Robin, > > thanks for the head up ... indeed, > > C:\libraries>ping www.reportlab.co.uk > Ping www.reportlab.co.uk [77.44.121.240] mit 32 Bytes Daten > > ping gets 77.44.121.240. > > svn co http://www.reportlab.co.uk/svn/public/reportlab/trunk > > still fails with > svn: PROPFIND request failed on '/svn/public/reportlab/trunk' > svn: PROPFIND of '/svn/public/reportlab/trunk': could not connect to > server (http://www.reportlab.co.uk) > > (I tried from 4 different ISPs) > > what else can I do? > > Harald > ...... OK I'm investigating. I've been using https to connect so perhaps something broke related to http. I don't recall having done anything related to this except for this ip address change. Can you check your working repository to see if it really was the http version? -- Robin Becker From robin at reportlab.com Thu Aug 14 09:15:27 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 14 Aug 2008 14:15:27 +0100 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? In-Reply-To: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> References: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> Message-ID: <48A42FEF.4030100@chamonix.reportlab.co.uk> Harald Armin Massa wrote: > Tried to update my reportlab 2.0 trunk libraries... but svn announces > > could not connect to server > > something broken? something moved? > > Best wishes > > HArald > I can only tell you that it seems not to be related to SVN access, but it seems port 80 is somehow blocked. I've checked and port 443 is OK so you should have read access via https. It might be related to some special port 80 handling somehere in the isp, but I don't know as yet. -- Robin Becker From reportlab at richardshea.fastmail.fm Fri Aug 15 02:19:35 2008 From: reportlab at richardshea.fastmail.fm (reportlab at richardshea.fastmail.fm) Date: Fri, 15 Aug 2008 18:19:35 +1200 Subject: [reportlab-users] Filling a frame from the bottom ? (Platypus) Message-ID: <1218781175.21531.1268763813@webmail.messagingengine.com> Hi - I would like to fill a frame from the bottom upwards (so that if there is one line of text it's at the bottom of the page and if there are, say, 15 the last line of text is at the bottom of the page and the first line is, say, 25% of the way up from the bottom. Is this possible ? I thought at first of a one cell table with VALIGN set to BOTTOM but then you've got to persuade the table to position itself at the bottom of the frame ... or occupy all of the frame ... which as far as I can see is not possible ? Any ideas welcomed ! regards Richard. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The Cuba Group PO Box 1864 Wellington New Zealand PH +64 4 496 5205 MO +64 21 296 6839 FX +64 4 496 5209 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From andy at reportlab.com Fri Aug 15 02:34:12 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 15 Aug 2008 07:34:12 +0100 Subject: [reportlab-users] Filling a frame from the bottom ? (Platypus) In-Reply-To: <1218781175.21531.1268763813@webmail.messagingengine.com> References: <1218781175.21531.1268763813@webmail.messagingengine.com> Message-ID: <956003ae0808142334r2295bff3u4cc1e3556d0492b6@mail.gmail.com> 2008/8/15 : > Hi - I would like to fill a frame from the bottom upwards (so that if > there is one line of text it's at the bottom of the page and if there > are, say, 15 the last line of text is at the bottom of the page and the > first line is, say, 25% of the way up from the bottom. > > Is this possible ? I thought at first of a one cell table with VALIGN > set to BOTTOM but then you've got to persuade the table to position > itself at the bottom of the frame ... or occupy all of the frame ... > which as far as I can see is not possible ? There is no really elegant way to do it. But with a table, you can specify the rowheights, so you can force your one-cell table to be the height of the frame. This should do the job as long as you can ensure the table is the only thing in the frame. - Andy From haraldarminmassa at gmail.com Fri Aug 15 03:40:02 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Fri, 15 Aug 2008 09:40:02 +0200 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? In-Reply-To: <48A42FEF.4030100@chamonix.reportlab.co.uk> References: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> <48A42FEF.4030100@chamonix.reportlab.co.uk> Message-ID: <7be3f35d0808150040m3212471qa0583d89cb5f25a8@mail.gmail.com> Robin, > I can only tell you that it seems not to be related to SVN access, but it > seems port 80 is somehow blocked. I've checked and port 443 is OK so you > should have read access via https. > > It might be related to some special port 80 handling somehere in the isp, > but I don't know as yet. So rebasing to https://www.reportlab.co.uk/svn/public/reportlab/trunk will make existing checkouts work and allow new ones... at least checking out new works. Would you mind to change the website to reflect this while finding out about the http:// problem? So new users do not get frustrated ... and it is a nice symbol anyway to use that https:// , isn't it? :) Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From andy at reportlab.com Fri Aug 15 04:02:46 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 15 Aug 2008 09:02:46 +0100 Subject: [reportlab-users] svn @ http://www.reportlab.co.uk/svn/public/reportlab/trunk is down? In-Reply-To: <7be3f35d0808150040m3212471qa0583d89cb5f25a8@mail.gmail.com> References: <7be3f35d0808131519r2e69505dy3c0a9b896c537a68@mail.gmail.com> <48A42FEF.4030100@chamonix.reportlab.co.uk> <7be3f35d0808150040m3212471qa0583d89cb5f25a8@mail.gmail.com> Message-ID: <956003ae0808150102m405e7d80v3e6c5c90f36f2a6a@mail.gmail.com> 2008/8/15 Harald Armin Massa : > Would you mind to change the website to reflect this while finding out > about the http:// problem? So new users do not get frustrated ... and > it is a nice symbol anyway to use that https:// , isn't it? :) We have asked our ISP to look into this yesterday and I would rather wait until Monday morning to see if they fix it. Port 80 really ought to work; if not maybe we need a new office building :-( - Andy From reportlab at richardshea.fastmail.fm Fri Aug 15 06:56:36 2008 From: reportlab at richardshea.fastmail.fm (reportlab at richardshea.fastmail.fm) Date: Fri, 15 Aug 2008 22:56:36 +1200 Subject: [reportlab-users] Filling a frame from the bottom ? (Platypus) In-Reply-To: <956003ae0808142334r2295bff3u4cc1e3556d0492b6@mail.gmail.com> References: <1218781175.21531.1268763813@webmail.messagingengine.com> <956003ae0808142334r2295bff3u4cc1e3556d0492b6@mail.gmail.com> Message-ID: <1218797796.2486.1268791185@webmail.messagingengine.com> On Fri, 15 Aug 2008 07:34:12 +0100, "Andy Robinson" said: > 2008/8/15 : > > Hi - I would like to fill a frame from the bottom upwards (so that if > > there is one line of text it's at the bottom of the page and if there > > are, say, 15 the last line of text is at the bottom of the page and the > > first line is, say, 25% of the way up from the bottom. > > > > Is this possible ? I thought at first of a one cell table with VALIGN > > set to BOTTOM but then you've got to persuade the table to position > > itself at the bottom of the frame ... or occupy all of the frame ... > > which as far as I can see is not possible ? > > There is no really elegant way to do it. But with a table, you can > specify > the rowheights, so you can force your one-cell table to be the height of > the frame. This should do the job as long as you can ensure the table > is the only thing in the frame. > That's a great idea, thanks. I had overlooked the Table constructor argument which allows you to set rowheights that will do just fine for me. thanks again Richard. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ The Cuba Group PO Box 1864 Wellington New Zealand PH +64 4 496 5205 MO +64 21 296 6839 FX +64 4 496 5209 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ From mjf at pearson.co.uk Fri Aug 15 11:50:08 2008 From: mjf at pearson.co.uk (Matt Folwell) Date: Fri, 15 Aug 2008 16:50:08 +0100 Subject: [reportlab-users] Problems with certain Greek letters and unicode In-Reply-To: <320fb6e00808130307y6b9def2exf4d79b4ac0fcf491@mail.gmail.com> References: <320fb6e00808120953w2aeef8cdq3afd42271af4b7fa@mail.gmail.com> <48A2A7BA.9040604@pearson.co.uk> <320fb6e00808130307y6b9def2exf4d79b4ac0fcf491@mail.gmail.com> Message-ID: <48A5A5B0.1060609@pearson.co.uk> Peter Cock wrote: > Hi Mat, > > On Wed, Aug 13, 2008 at 10:22 AM, Matt Folwell wrote: >> Peter Cock wrote: >> >>> U0394 - missing, upper case delta >>> U03A2 - missing, because there is no uppercase variant of sigma at the >>> end of a word >>> U03A9 - missing, upper case omega >>> U03BC - missing, lower case mu >> Those (apart from sigma) are characters with more than 1 unicode codepoint, >> and the codec that reportlab registers for symbol only encodes the other >> one. The attached patch to rl_codecs.py will let you use those codepoints. > > I applied the patch by hand (diff didn't like it and it was trivial), > and indeed that does solve my original problem. Could/should this be > included in the official reportlab codebase? > Yes it can, if the ReportLab folks want it. >> Alternatively you can use U2126 OHM SIGN for Omega, U2206 INCREMENT >> for Delta and U00B5 MICRO SIGN for mu. > > Using u"\u2206" for the increment (aka Delta) works, as does u"\u2126" > for Ohms (aka Omega). Using u"\u00b5" for the micro sign (aka mu) > works fine, but interestingly the four built in fonts I was using all > seem to include their own versions of this character. Note that > python will shorten this to just u'\xb5' which is equivalent (drops > the leading double zero). That makes sense, as micro sign is in the WinAnsi encoding. I suppose the WinAnsi codec could also encode \u03bc. Would that be useful, or would it be better to leave it out, so if you're using the greek alphabet codepoints you get consistent substitution behaviour? Matt From IStevens at globeandmail.com Fri Aug 15 16:05:58 2008 From: IStevens at globeandmail.com (Stevens, Ian) Date: Fri, 15 Aug 2008 16:05:58 -0400 Subject: [reportlab-users] Superscript text in chart Legend Message-ID: I'm looking to include superscript text in a Legend based on a chart. Specifically, I need to be able to include the French superscripted "marque de commerce", or MC. Unfortunately, Legend doesn't seem to use Paragraph to draw its text so using doesn't work. Is there another way I can get superscripts to be drawn? thanks, Ian. -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at thinkwave.com Sun Aug 17 20:54:06 2008 From: john at thinkwave.com (john at thinkwave.com) Date: Sun, 17 Aug 2008 17:54:06 -0700 (PDT) Subject: [reportlab-users] Images in PDFs in Google Appengine Message-ID: <677279.16360.qm@web808.biz.mail.mud.yahoo.com> Hello I am using Google Appengine, and am successfully generating text-based PDF documents using Platypus and ReportLab. Now, I'd like to include images in the reports, and am getting stuck. First: Google does not support PIL. It does provide it's own module to save an image to a blobproperty as a jpeg file. From what I understand, if I use a jpeg file from the datastore, it should render, even if PIL is not installed? But I'm having problems getting this to work. If I assign the model.blob value to a variable, and place the variable in the table ([item]) - I get UnicodeDecodeError exceptions. If I try to retrieve the image from my handler (which outputs the image as a mimetype image/jpg) - I get Imaging Library not available errors. Can someone provide me with some pointers how I'd go about successfully taking a jpeg stored in a blobproperty, and getting it included into a platypus table, without having the application start loading PIL modules? Thanks - johnP -------------- next part -------------- An HTML attachment was scrubbed... URL: From Paul.Keating at nibc.com Mon Aug 18 05:48:58 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Mon, 18 Aug 2008 11:48:58 +0200 Subject: [reportlab-users] Page n of m? In-Reply-To: <7be3f35d0808130625r67557b4fg74215da2dfe418ea@mail.gmail.com> Message-ID: Harald, Thanks for the help. I'd never have worked that out for myself. One other question: is it possible to retrieve and store the cursor position of the page number, so that when I do the drawString() later, I have the exact coordinates and don't need to recompute them? My problem is the position of the page number isn't fixed, it depends on what is above it in the frame. Regards P > Yes, it is possible. > > Usually the solution is: > > 1) add "Page of" to the footer of your Page > canv.drawRightString(10*cm, 0.75*cm, u"Page %s of % (doc.page,)) > > 2) add a PDF-Form to the place right of the "of" > canv.doForm("pageCount") > > 3) render the PDF > 4) after the rendering, fill the Number of Pages into PDF-Form which > gets drawn after the "of" > def _endBuild(self): > self.canv.beginForm("pageCount") > self.canv.setFont(fontnormal,7) > self.canv.drawString(12*cm,0.75*cm u"%s" % (self.canv. > getPageNumber(),)) > self.canv.endForm() > BaseDocTemplate._endBuild(self) From robin at reportlab.com Mon Aug 18 06:11:09 2008 From: robin at reportlab.com (Robin Becker) Date: Mon, 18 Aug 2008 11:11:09 +0100 Subject: [reportlab-users] Images in PDFs in Google Appengine In-Reply-To: <677279.16360.qm@web808.biz.mail.mud.yahoo.com> References: <677279.16360.qm@web808.biz.mail.mud.yahoo.com> Message-ID: <48A94ABD.7080003@chamonix.reportlab.co.uk> john at thinkwave.com wrote: > Hello > > I am using Google Appengine, and am successfully generating text-based PDF documents using Platypus and ReportLab. Now, I'd like to include images in the reports, and am getting stuck. > > First: Google does not support PIL. It does provide it's own module to save an image to a blobproperty as a jpeg file. From what I understand, if I use a jpeg file from the datastore, it should render, even if PIL is not installed? > > But I'm having problems getting this to work. If I assign the model.blob value to a variable, and place the variable > in the table ([item]) - I get UnicodeDecodeError exceptions. If I try > to retrieve the image from my handler (which outputs the image as a mimetype image/jpg) - I get Imaging Library not > available errors. > > Can someone provide me with some pointers how I'd go about successfully taking a jpeg stored in a blobproperty, and getting it included into a platypus table, without having the application start loading PIL modules? Thanks - > > johnP > ........ Most images can be supported as internal objects/files, but the problem is that we then have use PIL to detect the image type/size of the file. If it's a jpeg we revert to using it directly so no conversion to rgb is done. We have a check for jpeg info in python so it should not be required to use PIL. If you want to use an image in platypus you normally have to create an ImageFlowable ie ImageFlowable(filename, width=None, height=None) filename can be a filelike object, but currently we don't support specifying that it contains an image of a specific type. I suppose we could complicate matters to allow that to be done so then you can wrap your blob in something that looks like a file, but also indicates that it's a natively supported jpeg. -- Robin Becker From haraldarminmassa at gmail.com Mon Aug 18 07:34:42 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Mon, 18 Aug 2008 13:34:42 +0200 Subject: [reportlab-users] Page n of m? In-Reply-To: References: <7be3f35d0808130625r67557b4fg74215da2dfe418ea@mail.gmail.com> Message-ID: <7be3f35d0808180434s6335e493j2f2089226c9158ab@mail.gmail.com> Paul, > Thanks for the help. I'd never have worked that out for myself. you are welcome > One other question: is it possible to retrieve and store the cursor > position of the page number, so that when I do the drawString() later, I am not aware of any method to do this. And with the described method it will also be impossible, as the FORM gets drawn ONLY once per document, and somehwo PDF defines "show it everywhere". i.E.: there are no different "of N" for different pages, there is only ON within your document. But more important: I recommend strongly not to do this. "jumping pages numbers" are a major frustration for anybody reading the document. Page numbers are usually used for reference, and it is really bad if they are "somewhere" on the page. It is "verboten" to do this. :) Harald > have the exact coordinates and don't need to recompute them? My problem is > the position of the page number isn't fixed, it depends on what is above it > in the frame. > > Regards > > P > > >> Yes, it is possible. >> >> Usually the solution is: >> >> 1) add "Page of" to the footer of your Page >> canv.drawRightString(10*cm, 0.75*cm, u"Page %s of % (doc.page,)) >> >> 2) add a PDF-Form to the place right of the "of" >> canv.doForm("pageCount") >> >> 3) render the PDF >> 4) after the rendering, fill the Number of Pages into PDF-Form which >> gets drawn after the "of" >> def _endBuild(self): >> self.canv.beginForm("pageCount") >> self.canv.setFont(fontnormal,7) >> self.canv.drawString(12*cm,0.75*cm u"%s" % (self.canv. >> getPageNumber(),)) >> self.canv.endForm() >> BaseDocTemplate._endBuild(self) > > > > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From Paul.Keating at nibc.com Mon Aug 18 08:31:32 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Mon, 18 Aug 2008 14:31:32 +0200 Subject: [reportlab-users] Page n of m? In-Reply-To: <7be3f35d0808180434s6335e493j2f2089226c9158ab@mail.gmail.com> Message-ID: Harald, I quite agree but it's house style. I'm not the designer, just the humble programmer. The jump is between page 1 and subsequent pages, so it's not quite as bad as it sounds. I've managed to make it work using two separate PDF forms. My main difficulty is that the baseline of the total page count wanders slightly if I change magnifications. I know what causes this: I haven't got the position exactly right, but at some magnifications it doesn't matter, because the rendering process makes them come out the same. But measuring a correcting offset off the printed page doesn't help, for the same reason. The offset I'm trying to measure has already been quantized and so it isn't accurate either. Looks like I'll have to try and get the hand calculation right. Regards > Paul, > > > But more important: I recommend strongly not to do this. > > "jumping pages numbers" are a major frustration for anybody reading the document. From haraldarminmassa at gmail.com Mon Aug 18 09:05:10 2008 From: haraldarminmassa at gmail.com (Harald Armin Massa) Date: Mon, 18 Aug 2008 15:05:10 +0200 Subject: [reportlab-users] Page n of m? In-Reply-To: References: <7be3f35d0808180434s6335e493j2f2089226c9158ab@mail.gmail.com> Message-ID: <7be3f35d0808180605k7efacf08pee9c74b57a4b99b1@mail.gmail.com> Paul, > I change magnifications. I know what causes this: I haven't got the > position exactly right, but at some magnifications it doesn't matter, > because the rendering process makes them come out the same. But measuring a > correcting offset off the printed page doesn't help, for the same reason. > The offset I'm trying to measure has already been quantized and so it isn't > accurate either. > > Looks like I'll have to try and get the hand calculation right. maybe it would help to print enlarged? Maybe Acrobat Reader or SOME of your printer drivers support it? Another option: draw a stairway into the form. Then magnify, and you will see which step is on the right level... best wishes, Harald -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Stra?e 49 70435 Stuttgart 0173/9409607 no fx, no carrier pigeon - EuroPython 2009 will take place in Birmingham - Stay tuned! From Paul.Keating at nibc.com Tue Aug 19 07:05:27 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Tue, 19 Aug 2008 13:05:27 +0200 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute Message-ID: For my current project I needed to make charSpace available at the level of paragraph style. Would there be any interest in including this tiny enhancement in the package, and if so, who should I submit the patch to? Paul Keating ______________________________________________________________ The information contained in this e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail. Please delete this e-mail and do not disclose its contents to any person. NIBC Holding N.V. nor its subsidiaries accept liability for any errors, omissions, delays of receipt or viruses in the contents of this message which arise as a result of e-mail transmission. De informatie in dit e-mailbericht is vertrouwelijk en uitsluitend bestemd voor de geadresseerde. Wanneer u dit bericht per abuis ontvangt, gelieve onmiddellijk contact op te nemen met de afzender per kerende e-mail. Wij verzoeken u dit e-mailbericht te vernietigen en de inhoud ervan aan niemand openbaar te maken. NIBC Holding N.V. noch haar dochterondernemingen aanvaarden enige aansprakelijkheid voor onjuiste, onvolledige dan wel ontijdige overbrenging van de inhoud van een verzonden e-mailbericht, noch voor door haar daarbij overgebrachte virussen. From robin at reportlab.com Tue Aug 19 07:34:23 2008 From: robin at reportlab.com (Robin Becker) Date: Tue, 19 Aug 2008 12:34:23 +0100 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute In-Reply-To: References: Message-ID: <48AAAFBF.7080102@chamonix.reportlab.co.uk> Paul.Keating at nibc.com wrote: > For my current project I needed to make charSpace available at the level of > paragraph style. > > Would there be any interest in including this tiny enhancement in the > package, and if so, who should I submit the patch to? > > Paul Keating > ....... If you have working code then by all means submit it here. -- Robin Becker From Paul.Keating at nibc.com Tue Aug 19 07:51:54 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Tue, 19 Aug 2008 13:51:54 +0200 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute In-Reply-To: <48AAAFBF.7080102@chamonix.reportlab.co.uk> Message-ID: To the mailing list? reportlab-users-bounces at reportlab.com wrote on 2008-08-19 13:34:23: > If you have working code then by all means submit it here. > -- > Robin Becker From robin at reportlab.com Tue Aug 19 10:20:35 2008 From: robin at reportlab.com (Robin Becker) Date: Tue, 19 Aug 2008 15:20:35 +0100 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute In-Reply-To: References: Message-ID: <48AAD6B3.9090005@chamonix.reportlab.co.uk> Paul.Keating at nibc.com wrote: > To the mailing list? > > reportlab-users-bounces at reportlab.com wrote on 2008-08-19 13:34:23: > >> If you have working code then by all means submit it here. >> -- >> Robin Becker Or to me directly; if you show in the mailing list more eyes will get to see it and they may have valid insights/criticisms. -- Robin Becker From gert at sensepost.com Wed Aug 20 05:20:40 2008 From: gert at sensepost.com (Gert Burger) Date: Wed, 20 Aug 2008 11:20:40 +0200 Subject: [reportlab-users] Force table not to split Message-ID: <48ABE1E8.5060801@sensepost.com> Hi I am creating reports which contain many small tables, each fit the width of the page and are about 1/4 of its length. Each table only contains 2 rows of which the first is the header. By default it seems to split between rows, which is exactly not what I require. I would rather have it move the whole table to the next page. The documentation(userguide.pdf Chapter 7 Introduction) mentions a canSplit attribute but nothing more about it. How would one force reportlab not to split tables? -- Regards Gert Burger ** CRM114 Whitelisted by: From gert at sensepost.com ** From Paul.Keating at nibc.com Wed Aug 20 05:35:06 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Wed, 20 Aug 2008 11:35:06 +0200 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute In-Reply-To: <48AAD6B3.9090005@chamonix.reportlab.co.uk> Message-ID: Ok, here it is: The charSpace attribute is already present in and supported at canvas level. This little patch surfaces it as a pargraph style attribute. Increased character spacing is occasionally useful for making all-caps headings in sans fonts more legible at small point sizes. I needed to put it in because it's a house-style requirement for a project I'm working on. Typical use is as follows, last line of example: styleSheet.add( ParagraphStyle('Heading Rubrics', styleSheet['Normal'], fontSize=6, leading=7, spaceAfter=0, charSpace=1)) I'v run the standard test suite against it and it doesn't appear to break anything, though that is of course hard to judge because the visual tests rely on one knowing exactly what they should look like. Index: lib/styles.py =================================================================== --- lib/styles.py (revision 3252) +++ lib/styles.py (working copy) @@ -75,6 +75,7 @@ 'alignment':TA_LEFT, 'spaceBefore':0, 'spaceAfter':0, + 'charSpace': 0, 'bulletFontName':'Times-Roman', 'bulletFontSize':10, 'bulletIndent':0, Index: pdfgen/canvas.py =================================================================== --- pdfgen/canvas.py (revision 3252) +++ pdfgen/canvas.py (working copy) @@ -1306,8 +1306,11 @@ font = pdfmetrics.getFont(self._fontname) if not font._dynamicFont: pdffontname = self._doc.getInternalFontName(psfontname) - self._code.append('BT %s %s Tf %s TL ET' % (pdffontname, fp_str(size), fp_str(leading))) + self._code.append('BT %s %s Tf %s TL %s Tc ET' % (pdffontname, fp_str(size), fp_str(leading), fp_str(self._charSpace))) + def setCharSpace(self, charSpace): + self._charSpace = charSpace + def setFontSize(self, size=None, leading=None): '''Sets font size or leading without knowing the font face''' if size is None: size = self._fontsize Index: platypus/paragraph.py =================================================================== --- platypus/paragraph.py (revision 3252) +++ platypus/paragraph.py (working copy) @@ -1288,6 +1288,8 @@ #now the font for the rest of the paragraph tx.setFont(f.fontName, f.fontSize, leading) + if style.charSpace: tx.setCharSpace(style.charSpace) + ws = lines[0][0] t_off = dpl( tx, offset, ws, lines[0][1], noJustifyLast and nLines==1) if f.underline or f.link or f.strike: reportlab-users-bounces at reportlab.com wrote on 2008-08-19 16:20:35: > >> If you have working code then by all means submit it here. ... > Or to me directly; if you show in the mailing list more eyes will > get to see it > and they may have valid insights/criticisms. > -- > Robin Becker From robin at reportlab.com Wed Aug 20 06:02:33 2008 From: robin at reportlab.com (Robin Becker) Date: Wed, 20 Aug 2008 11:02:33 +0100 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute In-Reply-To: References: Message-ID: <48ABEBB9.8090202@chamonix.reportlab.co.uk> Paul.Keating at nibc.com wrote: > Ok, here it is: > > The charSpace attribute is already present in and supported at canvas > level. > > This little patch surfaces it as a pargraph style attribute. Increased > character spacing is occasionally useful for making all-caps headings in > sans fonts more legible at small point sizes. I needed to put it in because > it's a house-style requirement for a project I'm working on. > > Typical use is as follows, last line of example: > > styleSheet.add( > ParagraphStyle('Heading Rubrics', styleSheet['Normal'], > fontSize=6, > leading=7, > spaceAfter=0, > charSpace=1)) > > I'v run the standard test suite against it and it doesn't appear to break > anything, though that is of course hard to judge because the visual tests > rely on one knowing exactly what they should look like. Presumably this is the initial/default charSpace that gets used where the default style applies. Is it your intention that that space should apply to places where fonts change etc etc or should we allow charSpace to be changed with the font / para attributes and similar. > > Index: lib/styles.py > =================================================================== > --- lib/styles.py (revision 3252) > +++ lib/styles.py (working copy) > @@ -75,6 +75,7 @@ > 'alignment':TA_LEFT, > 'spaceBefore':0, > 'spaceAfter':0, > + 'charSpace': 0, > 'bulletFontName':'Times-Roman', > 'bulletFontSize':10, > 'bulletIndent':0, > Index: pdfgen/canvas.py > =================================================================== > --- pdfgen/canvas.py (revision 3252) > +++ pdfgen/canvas.py (working copy) > @@ -1306,8 +1306,11 @@ > font = pdfmetrics.getFont(self._fontname) > if not font._dynamicFont: > pdffontname = self._doc.getInternalFontName(psfontname) > - self._code.append('BT %s %s Tf %s TL ET' % (pdffontname, > fp_str(size), fp_str(leading))) > + self._code.append('BT %s %s Tf %s TL %s Tc ET' % (pdffontname, > fp_str(size), fp_str(leading), fp_str(self._charSpace))) > > + def setCharSpace(self, charSpace): > + self._charSpace = charSpace > + > def setFontSize(self, size=None, leading=None): > '''Sets font size or leading without knowing the font face''' > if size is None: size = self._fontsize > Index: platypus/paragraph.py > =================================================================== > --- platypus/paragraph.py (revision 3252) > +++ platypus/paragraph.py (working copy) > @@ -1288,6 +1288,8 @@ > > #now the font for the rest of the paragraph > tx.setFont(f.fontName, f.fontSize, leading) > + if style.charSpace: tx.setCharSpace(style.charSpace) > + > ws = lines[0][0] > t_off = dpl( tx, offset, ws, lines[0][1], noJustifyLast > and nLines==1) > if f.underline or f.link or f.strike: > > > reportlab-users-bounces at reportlab.com wrote on 2008-08-19 16:20:35: > >>>> If you have working code then by all means submit it here. > ... >> Or to me directly; if you show in the mailing list more eyes will >> get to see it >> and they may have valid insights/criticisms. >> -- >> Robin Becker > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > -- Robin Becker From Paul.Keating at nibc.com Wed Aug 20 06:49:11 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Wed, 20 Aug 2008 12:49:11 +0200 Subject: [reportlab-users] Adding charSpace as a paragraph style attribute In-Reply-To: <48ABEBB9.8090202@chamonix.reportlab.co.uk> Message-ID: reportlab-users-bounces at reportlab.com wrote on 2008-08-20 12:02:33: > Presumably this is the initial/default charSpace that gets used where the > default style applies. Is it your intention that that space should apply to > places where fonts change etc etc or should we allow charSpace to be changed > with the font / para attributes and similar. I more or less had it in mind that it would be similar to leading, that is, not something one would want to change on the fly. I know some European houses still use letter spacing for emphasis in mid-paragraph where an English printer would use italics, but that wasn't what I was aiming at, mainly because it just didn't occur to me. -- Paul Keating The Hague From bfreeman at appropriatesolutions.com Wed Aug 20 09:24:47 2008 From: bfreeman at appropriatesolutions.com (Bill Freeman) Date: Wed, 20 Aug 2008 09:24:47 -0400 Subject: [reportlab-users] Force table not to split In-Reply-To: <48ABE1E8.5060801@sensepost.com> References: <48ABE1E8.5060801@sensepost.com> Message-ID: <48AC1B1F.9060404@appropriatesolutions.com> Gert Burger wrote: > Hi > > I am creating reports which contain many small tables, each fit the > width of the page and are about 1/4 of its length. Each table only > contains 2 rows of which the first is the header. > > By default it seems to split between rows, which is exactly not what I > require. I would rather have it move the whole table to the next page. > The documentation(userguide.pdf Chapter 7 Introduction) mentions a > canSplit attribute but nothing more about it. > > How would one force reportlab not to split tables? > One possibility is to calculate the height of the table, and, if you don't have that much space left in the frame, force the next frame. (If there is an easier way, this is still what's going on under the hood, I'll bet.) Bill From gert at sensepost.com Wed Aug 20 09:28:19 2008 From: gert at sensepost.com (Gert Burger) Date: Wed, 20 Aug 2008 15:28:19 +0200 Subject: [reportlab-users] Force table not to split In-Reply-To: <48AC1B1F.9060404@appropriatesolutions.com> References: <48ABE1E8.5060801@sensepost.com> <48AC1B1F.9060404@appropriatesolutions.com> Message-ID: <48AC1BF3.6080508@sensepost.com> Bill Freeman wrote: > Gert Burger wrote: >> Hi >> >> I am creating reports which contain many small tables, each fit the >> width of the page and are about 1/4 of its length. Each table only >> contains 2 rows of which the first is the header. >> >> By default it seems to split between rows, which is exactly not what I >> require. I would rather have it move the whole table to the next page. >> The documentation(userguide.pdf Chapter 7 Introduction) mentions a >> canSplit attribute but nothing more about it. >> >> How would one force reportlab not to split tables? >> > One possibility is to calculate the height of the table, and, if you > don't have that much space left > in the frame, force the next frame. (If there is an easier way, this > is still what's going on under > the hood, I'll bet.) > > Bill > > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > I guessed it would be something like that, but how would one do that in platypus? -- Regards Gert Burger ** CRM114 Whitelisted by: From gert at sensepost.com ** From Paul.Keating at nibc.com Wed Aug 20 09:59:35 2008 From: Paul.Keating at nibc.com (Paul.Keating at nibc.com) Date: Wed, 20 Aug 2008 15:59:35 +0200 Subject: [reportlab-users] Force table not to split In-Reply-To: <48AC1BF3.6080508@sensepost.com> Message-ID: I don't have an example handy but I remember that something like this seemed to do what you want. (It wasn't what I wanted which is why I don't have the code anymore.) A Table is a Flowable and you can set Flowable.keepWithNext. If you put a zero-height Spacer after the table then I think this forces the whole table onto the page where the the spacer is, which of course must be the next page, since it won't fit on this one. reportlab-users-bounces at reportlab.com wrote on 2008-08-20 15:28:19: > > I guessed it would be something like that, but how would one do that in > platypus? -- Paul Keating The Hague From bfreeman at appropriatesolutions.com Thu Aug 21 14:51:34 2008 From: bfreeman at appropriatesolutions.com (Bill Freeman) Date: Thu, 21 Aug 2008 14:51:34 -0400 Subject: [reportlab-users] Force table not to split In-Reply-To: <48AC1BF3.6080508@sensepost.com> References: <48ABE1E8.5060801@sensepost.com> <48AC1B1F.9060404@appropriatesolutions.com> <48AC1BF3.6080508@sensepost.com> Message-ID: <48ADB936.7030507@appropriatesolutions.com> Gert Burger wrote: > Bill Freeman wrote: > >> Gert Burger wrote: >> >>> Hi >>> >>> I am creating reports which contain many small tables, each fit the >>> width of the page and are about 1/4 of its length. Each table only >>> contains 2 rows of which the first is the header. >>> >>> By default it seems to split between rows, which is exactly not what I >>> require. I would rather have it move the whole table to the next page. >>> The documentation(userguide.pdf Chapter 7 Introduction) mentions a >>> canSplit attribute but nothing more about it. >>> >>> How would one force reportlab not to split tables? >>> >>> >> One possibility is to calculate the height of the table, and, if you >> don't have that much space left >> in the frame, force the next frame. (If there is an easier way, this >> is still what's going on under >> the hood, I'll bet.) >> >> Bill >> >> >> _______________________________________________ >> reportlab-users mailing list >> reportlab-users at reportlab.com >> http://two.pairlist.net/mailman/listinfo/reportlab-users >> >> > I guessed it would be something like that, but how would one do that in > platypus? > I'm not sure what it would mean to do it in platypus, so let me be clearer about what I was thinking. I once explored the innards of the table class, trying to figure out how to make it split by columns, as the documentation implies that it can. I found no code to do this, and nothing that even looks at the constructor argument that says which way to split first (so I guess that the documentation if for a feature that will happen someday, or a feature that was too much trouble to keep working and was elided). But I did wind up with some understanding of split by rows. There is already code that calculates the table size (row heights, in particular), and code that compares that to the height available. When it decides to split, it returns a list of flowables to insert into the flowables list in place of itself. So the general solution would be to create a derived class that uses the portions of the underlying functionality to calculate size, and if things aren't going to fit (you may have to duplicate most of a fairly large method to catch it at just this point), and instead of letting it split the table, return a list of a spacer or other page/frame/column ending flowable, and your table. (IIRC, the page break flowables work by adding a spacer sized to take the remaining space.) I'm afraid that I don't recall details like what method to look at, but it's just Python code. On the other hand, it sounds as though all your tables might be of the same height, so you might take a short cut by having a simpler subclass that just looks to see that you have that much room, and inserts a spacer if not. Best of luck, Bill And I hope the list will correct any misinformation I've offered. From philippe.robitaille at sheridanc.on.ca Fri Aug 22 13:32:05 2008 From: philippe.robitaille at sheridanc.on.ca (Philippe Robitaille) Date: Fri, 22 Aug 2008 13:32:05 -0400 Subject: [reportlab-users] KeepInFrame Shrinkage Message-ID: <1d05e3e05d21f02c.48aebfd5@sheridanc.on.ca> Hello: I am building an application that calls for some flowables to keep together in the same frame. I opted for the shrink action to take when the text is too long. This action seemed like the least offensive relative to masking, overflowing or raising an error. I have two points to be made about this. First, for the most part, shrinking the flowables renders beautifully with text that has a small recuction in point size. Very elegant. However, on some instances I yield PDF output where the keepInFrame objects are shrunk to some ridiculously small point size. I can't see that there is a way to specify maximum shrinkage. But I think there should be. I will not be able to use shrink if it renders even a small percentage of instances as un-readable. Secondly, I am wondering if you should not consider another form of action for KeepInFrame. If you have a flowable with a dozen lines of text, it might be reasonable to offer a "reduce leading" action as well. And of course there might be a "tighten kerning" action although this does not seem to be a primitive supported at all. All good things in time, I suppose. Are there any words of advice? Maybe I should be considering some contortions with a Try/Except using the raise error action. Regards, phil robitaille From yroman-reportlab at altalang.com Fri Aug 22 14:18:07 2008 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Fri, 22 Aug 2008 14:18:07 -0400 Subject: [reportlab-users] Implementation of drawImage anchoring Message-ID: <00b101c90483$6d074670$0502000a@ad.altalang.com> I've been reading (and re-reading) the doc for drawImage in Canvas, and I'm pretty sure the implementation doesn't match what's described. To quote: New post version 2.0: drawImage can center the image in a box you provide. This saves developers from doing lots of math in their code. You can define a box with x,y,width and height. If 'preserveAspectRatio' is set, the image will be scaled up or down as needed in proportion to fit entirely within the box. Unless the aspect ratio perfectly matches the box, this will leave some space. So, the boxAnchor property defines how the image should be anchored in the box, using imaginary points of the compass. 'sw' for SouthWest is the default, but 'c' for center will center it in the given box. What happens if I use 'c', though, is the image is centered on (x, y) not within the box defined by x, y, width, and height (visually displayed here with rect for testing): canvas = Canvas('canvas.pdf', pagesize=LETTER) canvas.rect(x, y, width, height, fill=1) size = canvas.drawImage('test.png', x, y, width, height, \ preserveAspectRatio=1, anchor='c') canvas.save() I've got a patch for lib.boxstuff to get it to do what's stated in the doc, but I wanted to verify whether the doc or the implementation was incorrect. In my case, I needed what was stated in the doc. Thanks, -- Yoann Roman From robin at reportlab.com Fri Aug 22 15:33:28 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 22 Aug 2008 20:33:28 +0100 Subject: [reportlab-users] KeepInFrame Shrinkage In-Reply-To: <1d05e3e05d21f02c.48aebfd5@sheridanc.on.ca> References: <1d05e3e05d21f02c.48aebfd5@sheridanc.on.ca> Message-ID: <48AF1488.3050809@jessikat.plus.net> Philippe Robitaille wrote: > Hello: > > I am building an application that calls for some flowables to keep together in the same frame. I opted for the shrink action to take when the text is too long. This action seemed like the least offensive relative to masking, overflowing or raising an error. > > I have two points to be made about this. > > First, for the most part, shrinking the flowables renders beautifully with text that has a small recuction in point size. Very elegant. However, on some instances I yield PDF output where the keepInFrame objects are shrunk to some ridiculously small point size. I can't see that there is a way to specify maximum shrinkage. But I think there should be. I will not be able to use shrink if it renders even a small percentage of instances as un-readable. > > Secondly, I am wondering if you should not consider another form of action for KeepInFrame. If you have a flowable with a dozen lines of text, it might be reasonable to offer a "reduce leading" action as well. And of course there might be a "tighten kerning" action although this does not seem to be a primitive supported at all. All good things in time, I suppose. > > Are there any words of advice? Maybe I should be considering some contortions with a Try/Except using the raise error action. > > Regards, > phil robitaille ...... There are some things to consider here. First off the shrinkage is determined by an algorithm which considers both width and height. We use a newton style algorithm to home in on the appropriate shrink factor. If you have some fixed width elements they may overwhelm the rest of the content. Secondly you can already specify the leading in the styles of paragraphs etc etc. No matter what if you try to cram 5inches of test into 1in of width the results are likely to be laughable. An example of what you consider bad behaviour is welcome if it leads to a better solution. -- Robin Becker From andy at reportlab.com Sat Aug 23 03:24:31 2008 From: andy at reportlab.com (Andy Robinson) Date: Sat, 23 Aug 2008 08:24:31 +0100 Subject: [reportlab-users] KeepInFrame Shrinkage In-Reply-To: <1d05e3e05d21f02c.48aebfd5@sheridanc.on.ca> References: <1d05e3e05d21f02c.48aebfd5@sheridanc.on.ca> Message-ID: <956003ae0808230024y4440d95cx1aa45b42fab3abdc@mail.gmail.com> 2008/8/22 Philippe Robitaille : > Hello: > > Secondly, I am wondering if you should not consider another form of action for KeepInFrame. If you have a flowable with a dozen lines of text, it might be reasonable to offer a "reduce leading" action as well. And of course there might be a "tighten kerning" action although this does not seem to be a primitive supported at all. All good things in time, I suppose. We don't actually reduce the font size. We actually 'scale the coordinates' and try again to flow in the ext, or whatever is there. Thus, text reflows, but fixed-width tables and images also get scaled down to fit. We also try this in a fairly dumb manner, reducing 10% each time until there is no more error. This avoids us having to work out special shrinking rules separately for each kind of flowable. Can you explain further the special case it fails to work for, or post a brief example? Maybe there is something in your content which we can point out. - Andy -- Andy Robinson CEO/Chief Architect ReportLab Europe Ltd. 165 The Broadway, Wimbledon, London SW19 1NE, UK Tel +44-20-8544-8049 From ralsina at netmanagers.com.ar Sun Aug 24 23:03:30 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Mon, 25 Aug 2008 00:03:30 -0300 Subject: [reportlab-users] Announce: rst2pdf version 0.3 Message-ID: <200808250003.31420.ralsina@netmanagers.com.ar> I have the pleasure of announcing version 0.3 of rst2pdf, a tool to go directly from restructured text to PDF, via reportlab. This release includes the following features: * Full pygments-based syntax highlighter (code-block directive) support. * User can provide custom stylesheets, including TrueType fonts to embed in the PDF, and fully personalize the text styles using a simple syntax. * Hyphenation and justification (optional, requires WordAxe). * Simple installation from PyPI * Support for all ReST features, AFAIK. If I missed one, let me know ;-) For more information, please check the `manual `_ or the googlecode `page `_. Any comments are appreciated, specially feature requests or bug reports. Best regards, -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From philippe.robitaille at sheridanc.on.ca Mon Aug 25 14:08:32 2008 From: philippe.robitaille at sheridanc.on.ca (Philippe Robitaille) Date: Mon, 25 Aug 2008 14:08:32 -0400 Subject: [reportlab-users] KeepInFrame Shrinkage Message-ID: <757e879546205e00.48b2bce0@sheridanc.on.ca> Hi All: Attached is a sample where the KeepInFrame was not invoked (No_Shrink_micro_calendar.pdf). It is the bulletin shaded in blue. As you can see, it is nothing more than a few para's of text set in a frame of about 3.5 inches. All appears fine and well. Also attached is a sample where the KeepInFrame shrinkage yields ridiculously small content (Shrink_micro_calendar.pdf). The only difference between the two samples is that I introduced an image at top of the former to force the bulletin down and onto a new frame. Any thoughts? Regards, phil robitaille -------------- next part -------------- A non-text attachment was scrubbed... Name: No_Shrink_micro_calendar.pdf Type: application/pdf Size: 20271 bytes Desc: not available Url : -------------- next part -------------- A non-text attachment was scrubbed... Name: Shrink_micro_calendar.pdf Type: application/pdf Size: 6176 bytes Desc: not available Url : From bignose+hates-spam at benfinney.id.au Mon Aug 25 22:35:12 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Tue, 26 Aug 2008 12:35:12 +1000 Subject: [reportlab-users] Announce: rst2pdf version 0.3 References: <200808250003.31420.ralsina@netmanagers.com.ar> Message-ID: <87ej4ctsf3.fsf@benfinney.id.au> [Apologies if anyone gets essentially identical messages, I'm having trouble getting this message to appear on the list.] Roberto Alsina writes: > I have the pleasure of announcing version 0.3 of rst2pdf, a tool to > go directly from restructured text to PDF, via reportlab. Thank you for this! I have long suspected that the Reportlab toolkit was a good way to implement a reST-to-PDF renderer, but never found the time to implement anything. > Any comments are appreciated, specially feature requests or bug reports. I would very much like this functionality to be suitable for inclusion in the core Docutils distribution. However, looking over the code it seems there is a fair amount of deviation from the PEP 8 style guidelines , which likely will harm its chances of inclusion. I think it would be good to address this and have the code conform to PEP 8 from this point forward. Would you like me to work on converting the code base to conform with PEP 8? -- \ ?It's a good thing we have gravity or else when birds died | `\ they'd just stay right up there. Hunters would be all | _o__) confused.? ?Steven Wright | Ben Finney From ralsina at netmanagers.com.ar Tue Aug 26 07:52:34 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Tue, 26 Aug 2008 08:52:34 -0300 Subject: [reportlab-users] Announce: rst2pdf version 0.3 In-Reply-To: <87ej4ctsf3.fsf@benfinney.id.au> References: <200808250003.31420.ralsina@netmanagers.com.ar> <87ej4ctsf3.fsf@benfinney.id.au> Message-ID: <200808260852.35668.ralsina@netmanagers.com.ar> On Monday 25 August 2008 23:35:12 Ben Finney wrote: > [Apologies if anyone gets essentially identical messages, I'm having > trouble getting this message to appear on the list.] > > Roberto Alsina writes: > > I have the pleasure of announcing version 0.3 of rst2pdf, a tool to > > go directly from restructured text to PDF, via reportlab. > > Thank you for this! I have long suspected that the Reportlab toolkit > was a good way to implement a reST-to-PDF renderer, but never found > the time to implement anything. > > > Any comments are appreciated, specially feature requests or bug reports. > > I would very much like this functionality to be suitable for inclusion > in the core Docutils distribution. However, looking over the code it > seems there is a fair amount of deviation from the PEP 8 style > guidelines , which likely > will harm its chances of inclusion. It will hurt much more that it's not a writer written using the visitor pattern, or that the interface is completely different from all other writers :-) > I think it would be good to address this and have the code conform to > PEP 8 from this point forward. Would you like me to work on converting > the code base to conform with PEP 8? Please go ahead, in fact there is a issue in the tracker about it, mail me privately a googlecode account and I will add you to the project. -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From robin at reportlab.com Tue Aug 26 08:46:46 2008 From: robin at reportlab.com (Robin Becker) Date: Tue, 26 Aug 2008 13:46:46 +0100 Subject: [reportlab-users] KeepInFrame Shrinkage In-Reply-To: <757e879546205e00.48b2bce0@sheridanc.on.ca> References: <757e879546205e00.48b2bce0@sheridanc.on.ca> Message-ID: <48B3FB36.9000102@chamonix.reportlab.co.uk> Philippe Robitaille wrote: > Hi All: > > Attached is a sample where the KeepInFrame was not invoked (No_Shrink_micro_calendar.pdf). It is the bulletin shaded in blue. As you can see, it is nothing more than a few para's of text set in a frame of about 3.5 inches. All appears fine and well. > > Also attached is a sample where the KeepInFrame shrinkage yields ridiculously small content (Shrink_micro_calendar.pdf). The only difference between the two samples is that I introduced an image at top of the former to force the bulletin down and onto a new frame. > > Any thoughts? > > Regards, > phil robitaille ...... The problem with your second example is that there was a small amount of space at the end of the frame into which a non-zero height object could fit. Since the keepInFrame could fit there it did and because the content was actually quite large a high shrinkage was required. I'm not actually sure why you're using the keepInFrame thing here instead of a normal set of paragraphs. If you really want to use the keepInFrame then you probably need to ensure it has a certain minimum space available using one of the various condition checking flowables. -- Robin Becker From philippe.robitaille at sheridanc.on.ca Tue Aug 26 12:28:48 2008 From: philippe.robitaille at sheridanc.on.ca (Philippe Robitaille) Date: Tue, 26 Aug 2008 12:28:48 -0400 Subject: [reportlab-users] KeepInFrame Shrinkage Message-ID: <797f60263a32b88c.48b3f700@sheridanc.on.ca> Thanks to Robin for looking into the KeepInFrame. To answer the question, I am using the KeepInFrame to ensure that the blue bulletins do not split across frames. I understand that this is the way to do that - essentially bind the few paragraphs together with KeepInFrame. If I need to assess the minimum space available, that's ok. But can you point me to the so-called "various condition checking flowables". Thanks, phil robitaille From ralsina at netmanagers.com.ar Tue Aug 26 22:33:54 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Tue, 26 Aug 2008 23:33:54 -0300 Subject: [reportlab-users] The tag Message-ID: <200808262333.55179.ralsina@netmanagers.com.ar> Using reportlab 2.1, the tag mentioned in the docs seems to do nothing, but using SVN trunk it works. Is that a known issue? Here's the flowables I am generating (sorry, I can't give you python code for them, they are created from rst source): [Paragraph( 'style' 'bulletText' None 'text' 'Here you should see a biohazard symbol: ' 'encoding' 'utf8' 'caseSensitive' 1 'debug' 0 'frags' [ParaFrag( 'fontName' 'Helvetica' 'sub' 0 'text' 'Here you should see a biohazard symbol: ' 'rise' 0 'greek' 0 'link' None 'italic' 0 'strike' 0 'fontSize' 8 'textColor' Color(0,0,0) 'super' 0 'underline' 0 'bold' 0 ) #ParaFrag] ) #Paragraph] -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From andy at reportlab.com Wed Aug 27 02:52:23 2008 From: andy at reportlab.com (Andy Robinson) Date: Wed, 27 Aug 2008 07:52:23 +0100 Subject: [reportlab-users] The tag In-Reply-To: <200808262333.55179.ralsina@netmanagers.com.ar> References: <200808262333.55179.ralsina@netmanagers.com.ar> Message-ID: <956003ae0808262352l329e3ecj7b6a46ce538f18a1@mail.gmail.com> 2008/8/27 Roberto Alsina : > Using reportlab 2.1, the tag mentioned in the docs seems to do nothing, but using SVN trunk it works. Is that a known > issue? Yes. SVN is better than trunk by about 15 months. Of course, we have already 'fixed it' so there's not much we can do. We hope to get a new release out in early September. - Andy From dirk.holtwick at gmail.com Wed Aug 27 02:55:01 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Wed, 27 Aug 2008 08:55:01 +0200 Subject: [reportlab-users] The tag In-Reply-To: <956003ae0808262352l329e3ecj7b6a46ce538f18a1@mail.gmail.com> References: <200808262333.55179.ralsina@netmanagers.com.ar> <956003ae0808262352l329e3ecj7b6a46ce538f18a1@mail.gmail.com> Message-ID: <48B4FA45.20106@gmail.com> Andy Robinson schrieb: > 2008/8/27 Roberto Alsina : >> Using reportlab 2.1, the tag mentioned in the docs seems to do nothing, but using SVN trunk it works. Is that a known >> issue? > > Yes. SVN is better than trunk by about 15 months. Of course, we have > already 'fixed it' so there's not much we can do. We hope to get a > new release out in early September. A new release would really be wonderful ;) Dirk From andy at reportlab.com Wed Aug 27 02:56:56 2008 From: andy at reportlab.com (Andy Robinson) Date: Wed, 27 Aug 2008 07:56:56 +0100 Subject: [reportlab-users] The tag In-Reply-To: <48B4FA45.20106@gmail.com> References: <200808262333.55179.ralsina@netmanagers.com.ar> <956003ae0808262352l329e3ecj7b6a46ce538f18a1@mail.gmail.com> <48B4FA45.20106@gmail.com> Message-ID: <956003ae0808262356y4a4482f9t8f1d30661e8de1e@mail.gmail.com> 2008/8/27 Dirk Holtwick : > A new release would really be wonderful ;) For us too. We just need to invent the 9-day week first, and not tell our customers about the other two ;-) There's a reasonable chance we'll get it out by PyCon (12 Sep) as I am giving a tutorial there. But no promises. - Andy From ralsina at netmanagers.com.ar Wed Aug 27 11:47:27 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Wed, 27 Aug 2008 12:47:27 -0300 Subject: [reportlab-users] [ANN] rst2pdf version 0.5 released Message-ID: <200808271247.28270.ralsina@netmanagers.com.ar> I just released version 0.5 of this Rst-to-PDF-via-reportlab tool. There are some new features and many bugs fixed, specially since I didn't announce 0.4 ;-) You can get it via PyPI (package rst2pdf) or from Google Code: http://rst2pdf.googlecode.com Here's the changelog: New in 0.5 ---------- * Support for :widths: in tables * Support for captions in tables * Support for multi-row headers in tables * Improved definition lists * Fixed bug in image directive * Whitespace conforming to PEP8 * Fixed bug in text size on code-block * Package is more setuptools compliant * Fix for option groups in option lists * Citations support * Title reference role fix New in 0.4 ---------- * Fixed bullet and item lists indentation/nesting. * Implemented citations * Working links between footnotes and its references * Justification enabled by default * Fixed table bug (demo.txt works now) * Title and author support in PDF properties * Support for document title in header/footer * Custom page sizes and margins Best regards, -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From ralsina at netmanagers.com.ar Thu Aug 28 00:17:26 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Thu, 28 Aug 2008 01:17:26 -0300 Subject: [reportlab-users] [Docutils-users] [ANN] rst2pdf version 0.5 released In-Reply-To: <30vdxlx037.fsf@Clio.twb.ath.cx> References: <200808271247.28270.ralsina@netmanagers.com.ar> <30vdxlx037.fsf@Clio.twb.ath.cx> Message-ID: <200808280117.26757.ralsina@netmanagers.com.ar> On Thursday 28 August 2008 00:58:04 Trent W. Buck wrote: > Roberto Alsina writes: > > I just released version 0.5 of this Rst-to-PDF-via-reportlab tool. > > Can this tool do justification[0] and hyphenation[1]? These are two > features that I value very highly and are conspicuously absent in many > PDF writers that don't use TeX. Yes. You need to install Wordaxe from http://deco-cow.sf.net and maybe an hyphenator, depending on you language. You can see it doing justification and hyphenation (as well as TTF font embedding) here: http://flickr.com/photos/ralsina/2805071804/sizes/l/ You can see a hyphen in the 5th line from the bottom. -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From trentbuck at gmail.com Thu Aug 28 00:34:57 2008 From: trentbuck at gmail.com (Trent W. Buck) Date: Thu, 28 Aug 2008 14:34:57 +1000 Subject: [reportlab-users] [ANN] rst2pdf version 0.5 released References: <200808271247.28270.ralsina@netmanagers.com.ar> <30vdxlx037.fsf@Clio.twb.ath.cx> <200808280117.26757.ralsina@netmanagers.com.ar> Message-ID: <30ljyhwydq.fsf@Clio.twb.ath.cx> A non-text attachment was scrubbed... Name: tmp.pdf Type: application/pdf Size: 13981 bytes Desc: Example PDF with two-column, serifed fonts, justification and hyphenation. Url : From ralsina at netmanagers.com.ar Thu Aug 28 10:54:58 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Thu, 28 Aug 2008 11:54:58 -0300 Subject: [reportlab-users] Can a pagetemplate modify its frames? Message-ID: <200808281154.58702.ralsina@netmanagers.com.ar> I am trying to implement a "smart page" PageTemplate which does things like adjust margins and show/hide headers and footers depending on the content. Can I modify self.frames from a PageTemplate? I tried this to implement a "gutter margin" with no visible effect: def beforePage(self,canv,doc): print self.frames[0].__dict__ # Adjust gutter margins if doc.page%2: #Odd page gm=self.gm else: # Even page gm=-self.gm print gm for f in self.frames: f._x+=gm f._x1+=gm f._x2+=gm The values change but the frame doesn't move :-) -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From ralsina at netmanagers.com.ar Thu Aug 28 11:00:12 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Thu, 28 Aug 2008 12:00:12 -0300 Subject: [reportlab-users] Can a pagetemplate modify its frames? In-Reply-To: <200808281154.58702.ralsina@netmanagers.com.ar> References: <200808281154.58702.ralsina@netmanagers.com.ar> Message-ID: <200808281200.14831.ralsina@netmanagers.com.ar> On Thursday 28 August 2008 11:54:58 Roberto Alsina wrote: > I am trying to implement a "smart page" PageTemplate which does things like > adjust margins and show/hide headers and footers depending on the content. > > Can I modify self.frames from a PageTemplate? > > I tried this to implement a "gutter margin" with no visible effect: > > def beforePage(self,canv,doc): Make that beforeDrawPage (BTW, the manual is wrong here ;-) > print self.frames[0].__dict__ > > # Adjust gutter margins > if doc.page%2: #Odd page > gm=self.gm > else: # Even page > gm=-self.gm > > print gm > > for f in self.frames: > f._x+=gm > f._x1+=gm > f._x2+=gm > > The values change but the frame doesn't move :-) -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From robin at reportlab.com Thu Aug 28 11:36:59 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 28 Aug 2008 16:36:59 +0100 Subject: [reportlab-users] Can a pagetemplate modify its frames? In-Reply-To: <200808281200.14831.ralsina@netmanagers.com.ar> References: <200808281154.58702.ralsina@netmanagers.com.ar> <200808281200.14831.ralsina@netmanagers.com.ar> Message-ID: <48B6C61B.5010509@chamonix.reportlab.co.uk> Roberto Alsina wrote: > On Thursday 28 August 2008 11:54:58 Roberto Alsina wrote: >> I am trying to implement a "smart page" PageTemplate which does things like >> adjust margins and show/hide headers and footers depending on the content. >> >> Can I modify self.frames from a PageTemplate? >> >> I tried this to implement a "gutter margin" with no visible effect: >> >> def beforePage(self,canv,doc): > > Make that beforeDrawPage (BTW, the manual is wrong here ;-) > >> print self.frames[0].__dict__ >> >> # Adjust gutter margins >> if doc.page%2: #Odd page >> gm=self.gm >> else: # Even page >> gm=-self.gm >> >> print gm >> >> for f in self.frames: >> f._x+=gm >> f._x1+=gm >> f._x2+=gm >> >> The values change but the frame doesn't move :-) > you're messing with bad stuff here. These classes were created before python had properties etc etc so I think you'll need either to overwrite the frame with a new instance or to adjust the external properties x1, y1 etc etc and force the geometry to recalculate. If you do f.a=z where a is one of ('x1', 'y1', 'width', 'height', 'leftPadding', 'bottomPadding', 'rightPadding', 'topPadding') then the underlying _a variable is actually set and the frame recalculates its geometry. According to Andy the right way to do this sort of odd/even page stuff is to use a pagetemplate cycle basically need to use NextPageTemplate(['left','right']) PageBreak() in the story and then we iterate left & right templates. -- Robin Becker From ralsina at netmanagers.com.ar Thu Aug 28 11:42:18 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Thu, 28 Aug 2008 12:42:18 -0300 Subject: [reportlab-users] Can a pagetemplate modify its frames? In-Reply-To: <48B6C61B.5010509@chamonix.reportlab.co.uk> References: <200808281154.58702.ralsina@netmanagers.com.ar> <200808281200.14831.ralsina@netmanagers.com.ar> <48B6C61B.5010509@chamonix.reportlab.co.uk> Message-ID: <200808281242.18404.ralsina@netmanagers.com.ar> On Thursday 28 August 2008 12:36:59 Robin Becker wrote: > Roberto Alsina wrote: > > On Thursday 28 August 2008 11:54:58 Roberto Alsina wrote: > >> I am trying to implement a "smart page" PageTemplate which does things > >> like adjust margins and show/hide headers and footers depending on the > >> content. > >> > >> Can I modify self.frames from a PageTemplate? > >> > >> I tried this to implement a "gutter margin" with no visible effect: > >> > >> def beforePage(self,canv,doc): > > > > Make that beforeDrawPage (BTW, the manual is wrong here ;-) > > > >> print self.frames[0].__dict__ > >> > >> # Adjust gutter margins > >> if doc.page%2: #Odd page > >> gm=self.gm > >> else: # Even page > >> gm=-self.gm > >> > >> print gm > >> > >> for f in self.frames: > >> f._x+=gm > >> f._x1+=gm > >> f._x2+=gm > >> > >> The values change but the frame doesn't move :-) > > you're messing with bad stuff here. These classes were created before > python had properties etc etc so I think you'll need either to overwrite > the frame with a new instance That's more than good enough if it works. > or to adjust the external properties x1, y1 > etc etc and force the geometry to recalculate. If you do > > f.a=z where a is one of ('x1', 'y1', 'width', 'height', 'leftPadding', > 'bottomPadding', 'rightPadding', 'topPadding') then the underlying _a > variable is actually set and the frame recalculates its geometry. > > According to Andy the right way to do this sort of odd/even page stuff is > to use a pagetemplate cycle basically need to use > > NextPageTemplate(['left','right']) > PageBreak() > > in the story and then we iterate left & right templates. Yes, but I have problems here exposing that kind of thing to the user. The user already is going to have to switch for example, from "cover" to "contents" to "normal" templates. If he's going to have to switch from cover to contents-left, to normal-right, to normal-left, and so on, it's going to become annoying (not to mention that all page breaks would have to be manual). So, that doesn't really fit my idea of how the app will work. OTOH, recreating the frams? I have no problem with that ;-) -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From robin at reportlab.com Thu Aug 28 11:45:17 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 28 Aug 2008 16:45:17 +0100 Subject: [reportlab-users] KeepInFrame Shrinkage In-Reply-To: <797f60263a32b88c.48b3f700@sheridanc.on.ca> References: <797f60263a32b88c.48b3f700@sheridanc.on.ca> Message-ID: <48B6C80D.2080205@chamonix.reportlab.co.uk> Philippe Robitaille wrote: > Thanks to Robin for looking into the KeepInFrame. To answer the question, I am using the KeepInFrame to ensure that the blue bulletins do not split across frames. I understand that this is the way to do that - essentially bind the few paragraphs together with KeepInFrame. > > If I need to assess the minimum space available, that's ok. But can you point me to the so-called "various condition checking flowables". > > Thanks, > phil robitaille >..... There's something in flowables called CondPageBreak which is actually a conditional frame break. It's probably far too late to rename it now. You give it a length say 72 (for 72 points) and if there's less than 72 points available at wrap time then it either uses up all the space in the current frame or it adds a FrameBreak to the stream. Ther are trivial modifications to this to make it into a real PageBreak. -- Robin Becker From andy at reportlab.com Thu Aug 28 11:47:31 2008 From: andy at reportlab.com (Andy Robinson) Date: Thu, 28 Aug 2008 16:47:31 +0100 Subject: [reportlab-users] Can a pagetemplate modify its frames? In-Reply-To: <200808281242.18404.ralsina@netmanagers.com.ar> References: <200808281154.58702.ralsina@netmanagers.com.ar> <200808281200.14831.ralsina@netmanagers.com.ar> <48B6C61B.5010509@chamonix.reportlab.co.uk> <200808281242.18404.ralsina@netmanagers.com.ar> Message-ID: <956003ae0808280847s6050dc82w7c870f4cb33c0dd6@mail.gmail.com> 2008/8/28 Roberto Alsina : > If he's going to have to switch from cover to contents-left, to normal-right, > to normal-left, and so on, it's going to become annoying (not to mention that > all page breaks would have to be manual). No, the framework does that for you. You'd need to create the contents-left and contents-right page templates and their frames, but it should cycle through them each time a new page starts. At least it works that way in RML - I hope we implemented cleanly it in Platypus ;-) - Andy From gherman at darwin.in-berlin.de Thu Aug 28 11:52:09 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 28 Aug 2008 17:52:09 +0200 Subject: [reportlab-users] [ANN] rst2pdf version 0.5 released In-Reply-To: <30ljyhwydq.fsf@Clio.twb.ath.cx> References: <200808271247.28270.ralsina@netmanagers.com.ar> <30vdxlx037.fsf@Clio.twb.ath.cx> <200808280117.26757.ralsina@netmanagers.com.ar> <30ljyhwydq.fsf@Clio.twb.ath.cx> Message-ID: Trent W. Buck wrote: > Ooh, lovely. I presume it's also easy to customize for a larger, > serif > font, and two-column style? Attached is an example of the sort of > look > I'm going for. Trent, it won't give you the boxes since they're not available in RL paragraphs, but I'm glad to add them to the todo list for my alternative paragraphs package ;-) http://pypi.python.org/pypi/alterparagraphs/0.2.0 Here you can also read a presentation about it: http://www.dinu-gherman.net/tmp/ Regards, Dinu From yroman-reportlab at altalang.com Thu Aug 28 12:22:24 2008 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Thu, 28 Aug 2008 12:22:24 -0400 Subject: [reportlab-users] Implementation of drawImage anchoring Message-ID: <005501c9092a$41370110$0502000a@ad.altalang.com> Yoann Roman wrote... > I've been reading (and re-reading) the doc for drawImage in Canvas, and I'm > pretty sure the implementation doesn't match what's described. To quote: > > [snip] > > I've got a patch for lib.boxstuff to get it to do what's stated in the doc, > but I wanted to verify whether the doc or the implementation was incorrect. > In my case, I needed what was stated in the doc. Anyone have any ideas on this? If the implementation is correct, what's the proper way to get the behavior described in the doc (i.e., centering an image within a box anchored at x, y)? Thanks, -- Yoann Roman From robin at reportlab.com Thu Aug 28 13:03:50 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 28 Aug 2008 18:03:50 +0100 Subject: [reportlab-users] Implementation of drawImage anchoring In-Reply-To: <005501c9092a$41370110$0502000a@ad.altalang.com> References: <005501c9092a$41370110$0502000a@ad.altalang.com> Message-ID: <48B6DA76.4030601@chamonix.reportlab.co.uk> Yoann Roman wrote: > Yoann Roman wrote... >> I've been reading (and re-reading) the doc for drawImage in Canvas, and > I'm >> pretty sure the implementation doesn't match what's described. To quote: >> >> [snip] >> >> I've got a patch for lib.boxstuff to get it to do what's stated in the > doc, >> but I wanted to verify whether the doc or the implementation was > incorrect. >> In my case, I needed what was stated in the doc. > > Anyone have any ideas on this? If the implementation is correct, what's the > proper way to get the behavior described in the doc (i.e., centering an > image within a box anchored at x, y)? > > Thanks, > So your original box corners are (x,y), (x+width,y+width) you wish to place the centre of the image at the centre of the box so use anchor 'c' and then use x+width*0.5, y+height*0.5; that should place the centre of the image on the centre of the original box. If the image or object doesn't support anchoring then you'll need to know the size of the image or box in order to display it properly using some other anchor point. It seems that drawImage does so you should be OK here. -- Robin Becker From yroman-reportlab at altalang.com Thu Aug 28 13:40:56 2008 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Thu, 28 Aug 2008 13:40:56 -0400 Subject: [reportlab-users] Implementation of drawImage anchoring Message-ID: <006101c90935$39e7a990$0502000a@ad.altalang.com> Robin Becker wrote... > >> I've been reading (and re-reading) the doc for drawImage in Canvas, and > >> I'm pretty sure the implementation doesn't match what's described. To > >> quote: > >> > >> [snip] > >> > >> I've got a patch for lib.boxstuff to get it to do what's stated in the > >> doc, but I wanted to verify whether the doc or the implementation was > >> incorrect. In my case, I needed what was stated in the doc. > > > > Anyone have any ideas on this? If the implementation is correct, what's > > the proper way to get the behavior described in the doc (i.e., centering > > an image within a box anchored at x, y)? > > So your original box corners are > > (x,y), (x+width,y+width) > > you wish to place the centre of the image at the centre of the box so use > anchor 'c' and then use x+width*0.5, y+height*0.5; that should place the > centre of the image on the centre of the original box. > > If the image or object doesn't support anchoring then you'll need to know > the size of the image or box in order to display it properly using some > other anchor point. It seems that drawImage does so you should be OK here. So centering the image was a poor example. What I was looking for was a generic way to anchor an image anywhere in a *virtual* box with a given (x, y) and (width, height). As I understood it, that's what drawImage's anchor was for. As an alternate example, if I want to anchor my (100, 50) image in the northeast corner of a (200, 200) box, I'd expect to do this: canvas = Canvas('canvas.pdf', pagesize=LETTER) canvas.rect(0, 0, 200, 200, fill=1) # for illustration only size = canvas.drawImage('test.png', 0, 0, 200, 200, \ preserveAspectRatio=1, anchor='ne') canvas.save() In this case, the image ends up off the page with *its* northeast corner anchored at (0, 0). To get it right, the (x, y) for drawImage would have to be (200, 250) or (width, height + imgHeight). I could wrap all my drawImage calls to translate the (x, y) coordinates to the appropriate values for each anchor, but I'd need to know the dimensions of the image, which I don't get back until *after* drawImage. It feels like I'd need to duplicate a lot of drawImage's image loading code to do this translation. Am I just missing something? Thanks, -- Yoann Roman From robin at reportlab.com Thu Aug 28 16:53:04 2008 From: robin at reportlab.com (Robin Becker) Date: Thu, 28 Aug 2008 21:53:04 +0100 Subject: [reportlab-users] Implementation of drawImage anchoring In-Reply-To: <006101c90935$39e7a990$0502000a@ad.altalang.com> References: <006101c90935$39e7a990$0502000a@ad.altalang.com> Message-ID: <48B71030.4090003@jessikat.plus.net> Yoann Roman wrote: ...... > > Am I just missing something? > > Thanks, > In this context anchor is saying what point of the image the x,y you give refers to. The x and y are absolute as are the width and height. In these cases x,y defines a reference point. Width & height define how big the image should be. You choose to regard x,y, width & height as defining a box. Unfortunately that's not how we regard them. The so called box that you refer to doesn't actually exist, but if it did and we could refer to its anchor point then there would be two anchors and presumably all sorts of possibilities. Since you have absolute control over this virtual box I don't believe you really need control over what its x and y should anchor to. If I renamed anchor to referencePoint would it make more sense for you? -- Robin Becker From yroman at altalang.com Thu Aug 28 18:58:06 2008 From: yroman at altalang.com (Yoann Roman) Date: Thu, 28 Aug 2008 18:58:06 -0400 Subject: [reportlab-users] Implementation of drawImage anchoring In-Reply-To: <48B71030.4090003@jessikat.plus.net> References: <006101c90935$39e7a990$0502000a@ad.altalang.com> <48B71030.4090003@jessikat.plus.net> Message-ID: <00f901c90961$888f7330$0502000a@ad.altalang.com> Robin Becker wrote... > > Am I just missing something? > > > In this context anchor is saying what point of the image the x,y you > give refers to. The x and y are absolute as are the width and height. > In these cases x,y defines a reference point. Width & height define how > big the image should be. You choose to regard x,y, width & height as > defining a box. Unfortunately that's not how we regard them. I was going off this section in the docstring for drawImage: New post version 2.0: drawImage can center the image in a box you provide. This saves developers from doing lots of math in their code. You can define a box with x,y,width and height. If 'preserveAspectRatio' is set, the image will be scaled up or down as needed in proportion to fit entirely within the box. Unless the aspect ratio perfectly matches the box, this will leave some space. So, the boxAnchor property defines how the image should be anchored in the box, using imaginary points of the compass. 'sw' for SouthWest is the default, but 'c' for center will center it in the given box. This refers to a boxAnchor property, which I assumed should just be anchor. > The so called box that you refer to doesn't actually exist, but if it > did and we could refer to its anchor point then there would be two > anchors and presumably all sorts of possibilities. This confusion is probably why I'm lost in the first place :-). > Since you have absolute control over this virtual box I don't believe > you really need control over what its x and y should anchor to. This came about from porting Access reports, where there's the concept of an "image container" in which the image can be left (nw), centered (n), or right (sw) aligned. I was trying to replicate this behavior, and the docstring above led me to drawImage's anchor property. I'm getting what I want now by overriding the methods in lib.boxstuff in my app only, so I'm just trying to understand the reasoning at this point. > If I renamed anchor to referencePoint would it make more sense for you? Personally, replacing the above docstring with the explanation you just gave me would do it for me. It might help others if you added another property that would tell drawImage to use this alternate model I described. All this needs to do is switch the two lib.boxstuff calls it makes. I'd be happy to provide my patch for this. Thanks again, -- Yoann Roman From dirk.holtwick at gmail.com Fri Aug 29 02:16:05 2008 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Fri, 29 Aug 2008 08:16:05 +0200 Subject: [reportlab-users] [ANN] rst2pdf version 0.5 released In-Reply-To: References: <200808271247.28270.ralsina@netmanagers.com.ar> <30vdxlx037.fsf@Clio.twb.ath.cx> <200808280117.26757.ralsina@netmanagers.com.ar> <30ljyhwydq.fsf@Clio.twb.ath.cx> Message-ID: <48B79425.3080009@gmail.com> Dinu Gherman schrieb: > http://www.dinu-gherman.net/tmp/ Hi Dinu, sounds promising, but I cannot reach your site. Is it offline? Dirk From andy at reportlab.com Fri Aug 29 04:38:12 2008 From: andy at reportlab.com (Andy Robinson) Date: Fri, 29 Aug 2008 09:38:12 +0100 Subject: [reportlab-users] [ANN] rst2pdf version 0.5 released In-Reply-To: <48B79425.3080009@gmail.com> References: <200808271247.28270.ralsina@netmanagers.com.ar> <30vdxlx037.fsf@Clio.twb.ath.cx> <200808280117.26757.ralsina@netmanagers.com.ar> <30ljyhwydq.fsf@Clio.twb.ath.cx> <48B79425.3080009@gmail.com> Message-ID: <956003ae0808290138s2ed6872cof69b7bce1e86af63@mail.gmail.com> 2008/8/29 Dirk Holtwick : > Dinu Gherman schrieb: >> >> http://www.dinu-gherman.net/tmp/ > > Hi Dinu, > > sounds promising, but I cannot reach your site. Is it offline? > I had the same problem, today and in the past when I checked. - Andy From ralsina at netmanagers.com.ar Sat Aug 30 01:59:09 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Sat, 30 Aug 2008 02:59:09 -0300 Subject: [reportlab-users] [ANN] rst2pdf version 0.6 released Message-ID: <200808300259.10245.ralsina@netmanagers.com.ar> I just released version 0.6 of this Rst-to-PDF-via-reportlab tool. This is a major features release, and a major improvement over 0.5. You can get it via PyPI (package rst2pdf) or from Google Code: http://rst2pdf.googlecode.com Here are some of the features it provides: * User-defined page layout. Multiple frames per page, multiple layouts per document. * Cascading stylesheet mechanism, define only what you want changed * Supports TTF font embedding using a custom stylesheet * Any number of paragraph styles using the class directive * Any number of character styles using text roles * Custom page sizes and margins using a custom stylesheet. * Syntax highlighter for many languages, using Pygments * Supports hyphenation (using wordaxe) * Full user's manual Here's the changelog for the last two versions: New in 0.6 ---------- * Stylesheet-defined page layout (For example, multicolumn) and layout switching * Cascading Stylesheets (change exactly what you need changed) * PDF table of contents * Current section names and numbers in headers/footers * Support for compressed PDF files * Link color is configurable * Fixed bugs in color handling * Multilingual hyphenation * Auto-guessing image size, support for sizes in % * Gutter margins * Big refactoring * More tolerant of minor problems * Limited _raw_ directive (you can insert pagebreaks and vertical space) * Implemented a "traditional" docutils writer * Offer a reasonable API for use as a library * Fixed copyright/licensing * code-block now supports including files (whole or in part) so you can highlight external code. New in 0.5 ---------- * Support for :widths: in tables * Support for captions in tables * Support for multi-row headers in tables * Improved definition lists * Fixed bug in image directive * Whitespace conforming to PEP8 * Fixed bug in text size on code-block * Package is more setuptools compliant * Fix for option groups in option lists * Citations support * Title reference role fix Hope you enjoy it and/or find it useful. Best regards, -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From gherman at darwin.in-berlin.de Sat Aug 30 11:38:25 2008 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Sat, 30 Aug 2008 17:38:25 +0200 Subject: [reportlab-users] [ANN] rst2pdf version 0.5 released In-Reply-To: <48B79425.3080009@gmail.com> References: <200808271247.28270.ralsina@netmanagers.com.ar> <30vdxlx037.fsf@Clio.twb.ath.cx> <200808280117.26757.ralsina@netmanagers.com.ar> <30ljyhwydq.fsf@Clio.twb.ath.cx> <48B79425.3080009@gmail.com> Message-ID: <3B9FA123-EDD2-467D-979E-ADD9B9E88CBD@darwin.in-berlin.de> Dirk Holtwick: > Hi Dinu, > sounds promising, but I cannot reach your site. Is it offline? The site isn't yet very well set up, but it should work now... Regards, Dinu From ralsina at netmanagers.com.ar Sun Aug 31 08:07:00 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Sun, 31 Aug 2008 09:07:00 -0300 Subject: [reportlab-users] Problem with KeepInFrame in 2.1 Message-ID: <200808310907.00446.ralsina@netmanagers.com.ar> Hello, When using a KeppInFrame in "truncate" mode, it eats the border of a XPreformatted inside it. I am generating the KeepInFrame like this: KeepInFrame(2000*cm,2000*cm,content=[XPreformatted(text,style)],mode="truncate") I use the silly 2000*cm so it's actually using the size of the frame it's in at wrapping time. Here's an example PDF with the problem (look at the code fragments): http://rst2pdf.googlecode.com/svn/trunk/doc/manual.pdf Any suggestions? -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Docutils-users mailing list Docutils-users at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/docutils-users Please use "Reply All" to reply to the list. From robin at reportlab.com Sun Aug 31 08:59:01 2008 From: robin at reportlab.com (Robin Becker) Date: Sun, 31 Aug 2008 13:59:01 +0100 Subject: [reportlab-users] Problem with KeepInFrame in 2.1 In-Reply-To: <200808310907.00446.ralsina@netmanagers.com.ar> References: <200808310907.00446.ralsina@netmanagers.com.ar> Message-ID: <48BA9595.2000509@jessikat.plus.net> Roberto Alsina wrote: > Hello, > > When using a KeppInFrame in "truncate" mode, it eats the border of a > XPreformatted inside it. > > I am generating the KeepInFrame like this: > > KeepInFrame(2000*cm,2000*cm,content=[XPreformatted(text,style)],mode="truncate") > > I use the silly 2000*cm so it's actually using the size of the frame it's in > at wrapping time. > I'm not certain exactly what you mean by eats the border since I don't see anything obviously wrong in your 15 page example and I don't know what you intend things to look like. Can you say which page contains the eaten xpreformatted and what it should look like. > Here's an example PDF with the problem (look at the code fragments): > > http://rst2pdf.googlecode.com/svn/trunk/doc/manual.pdf > > Any suggestions? > -- Robin Becker From ralsina at netmanagers.com.ar Sun Aug 31 10:49:11 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Sun, 31 Aug 2008 11:49:11 -0300 Subject: [reportlab-users] Problem with KeepInFrame in 2.1 In-Reply-To: <48BA9595.2000509@jessikat.plus.net> References: <200808310907.00446.ralsina@netmanagers.com.ar> <48BA9595.2000509@jessikat.plus.net> Message-ID: <200808311149.12881.ralsina@netmanagers.com.ar> On Sunday 31 August 2008 09:59:01 Robin Becker wrote: > Roberto Alsina wrote: > > Hello, > > > > When using a KeppInFrame in "truncate" mode, it eats the border of a > > XPreformatted inside it. > > > > I am generating the KeepInFrame like this: > > > > > > KeepInFrame(2000*cm,2000*cm,content=[XPreformatted(text,style)],mode="tru > >ncate") > > > > I use the silly 2000*cm so it's actually using the size of the frame it's > > in at wrapping time. > > I'm not certain exactly what you mean by eats the border since I don't > see anything obviously wrong in your 15 page example and I don't know > what you intend things to look like. Can you say which page contains the > eaten xpreformatted and what it should look like. Sorry I was not clear. Look at the preformatted code fragments (the ones with beige background). They are supposed to have a border all around them, but only the left edge is shown,and the rest is not visible. If I make the border thicker, it is visible all around, but the left edge is always thicker. Looking a bit harder, it seems the problem is that the border is apparently drawn "outside" the XPreformatted's area. Since the KeepInFrame clips like this: p = canv.beginPath() p.rect(x, y, self.width,self.height) canv.clipPath(p,stroke=0) The border gets clipped. I don't know why the left edge is still visible, though. -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan From ralsina at netmanagers.com.ar Sun Aug 31 13:46:36 2008 From: ralsina at netmanagers.com.ar (Roberto Alsina) Date: Sun, 31 Aug 2008 14:46:36 -0300 Subject: [reportlab-users] Page numbers of bookmarks Message-ID: <200808311446.37491.ralsina@netmanagers.com.ar> I don't know if this is possible, but I am trying to produce a book-like table of contents, like this: 1. The first section ..........................1 2. The second.................................14 And link each one to the correct place in the document. The hard part is, of course, figuring out the "1" and the "14" :-) Any hints as to where I should look? -- ("\''/").__..-''"`-. . 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) Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan