From apatt at simplegeek.net Mon Mar 2 00:05:43 2009 From: apatt at simplegeek.net (Adam Patt) Date: Mon, 2 Mar 2009 00:05:43 -0500 Subject: [reportlab-users] keepWithNext causing first page to be blank Message-ID: <3DD465868BC3B54EB280A0B56D3AE4FE0BFB0C@golden.2manydogs.local> I have two paragraphs and then a really long table that spans multiple pages. I set keepWithNext=True for the first two paragraph parts, but when I render the page, it will create the first page as blank and start on the second page. How do I keep this from happening? If I can't keep it from happening, is there a way for me to remove the first page before I write to disk? the code is something like doc = SimpleDocTemplate(filename, leftMargin=qinch,rightMargin=qinch,topMargin=qinch,bottomMargin=qinch) styles = getSampleStyleSheet() Story = [] text = Paragraph("Schedule", styles['Heading1']) text.keepWithNext = True Story.append(text) data = t = Table(data, repeatRows=1, repeatCols=1) Story.appen(t) doc.pagesize = landscape(LETTER) doc.build(Story) If I don't use keepWithNext, the table will be pushed to the next page and if I don't have the text there, the table starts on the first page just fine. Is there some mystery object I need to set the keepWithNext on that would go before my first bit of text? No virus found in this outgoing message. Checked by AVG. Version: 7.5.557 / Virus Database: 270.11.3/1974 - Release Date: 2/26/2009 2:51 PM From henning.vonbargen at arcor.de Wed Mar 4 16:44:07 2009 From: henning.vonbargen at arcor.de (Henning von Bargen) Date: Wed, 4 Mar 2009 22:44:07 +0100 Subject: [reportlab-users] ANN: wordaxe-0.3.2 released References: Message-ID: <8B759C63EB5347ABAF2C9F10AFDA317E@max> I'm proud to present release 0.3.2 of the wordaxe hyphenation library for Python. wordaxe adds hyphenation support to the ReportLab and rst2pdf Python libraries. wordaxe supports using hyphenation dictionaries from Open Office through the pyhyphen library as well as a pure-Python hyphenation algorithm for the German language. About release wordaxe-0.3.2: Bug fixes and small improvements. Using wordaxe within rst2pdf should work fine now. Special thanks to Christoph Zwerschke and Harald Armin Massa. * Support for nobr tag: not exactly how nobr works in HTML, but in a way that allows disabling hyphenation for some words within a Paragraph with hyphenation enabled, like this: "Use the --with-error-correction option to automatically correct all program errors." * In order to make it easier to package applications with py2exe, the German hyphenation dictionary used by DCWHyphenator is now a Python file. * Fixed problems with multibuild. * Fixed: If a paragraph contained explicit line breaks ("
"), the width was not calculated correctly. * Cleaned up the test suite. * Added missing attributes/methods. Henning von Bargen http://sourceforge.net/projects/deco-cow From gherman at darwin.in-berlin.de Fri Mar 6 04:32:02 2009 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Fri, 6 Mar 2009 10:32:02 +0100 Subject: [reportlab-users] Tons of table questions In-Reply-To: <956003ae0902261304g7101d870t1f4db00543bb469e@mail.gmail.com> References: <77A9E75DA75C564D82BDC4B18A7D8525305765@ROHRPOSTIX.tup.ads> <956003ae0902260846r383a076bl13278d70cc2de72e@mail.gmail.com> <956003ae0902261304g7101d870t1f4db00543bb469e@mail.gmail.com> Message-ID: Andy Robinson: > I just reviewed the code and that's exactly what the longTable > option does. > > In my opinion this should be 'on' by default (in fact should have been > years ago). Can anyone here see problems if we change this for the > next release? Not sure I understand this. Does the current LongTable show non-linear performance or not? In any case I'm missing some- thing like a "next action" (in GTD parlance)... Regards, Dinu From andy at reportlab.com Fri Mar 6 05:40:06 2009 From: andy at reportlab.com (Andy Robinson) Date: Fri, 6 Mar 2009 10:40:06 +0000 Subject: [reportlab-users] Tons of table questions In-Reply-To: References: <77A9E75DA75C564D82BDC4B18A7D8525305765@ROHRPOSTIX.tup.ads> <956003ae0902260846r383a076bl13278d70cc2de72e@mail.gmail.com> <956003ae0902261304g7101d870t1f4db00543bb469e@mail.gmail.com> Message-ID: <956003ae0903060240q663a3ec1m90032368ea5737c1@mail.gmail.com> 2009/3/6 Dinu Gherman : > Not sure I understand this. Does the current LongTable show > non-linear performance or not? I believe (without having detailed benchmarks) that changing a 0 to a 1 in rl_config.py will improve performance, and is unlikely to adversely affect any real-world scripts. I am asking if anyone else is concerned, before making the change. If someone's document relied on the table algorithm correctly spotting an extra-wide table cell on row 500 of a long table, and allowing for it right from the beginning, this change would impact them. Since nobody has answered I now take it that this change is safe, so will probably do it today (I'm not somewhere I can code now). IMHO further improvements beyond that need a benchmarking script, with a bunch of different options (given or calculated column widths, simple versus more complex cell content), as well as a theoretical analysis which might miss part of the problem. > In any case I'm missing some- > thing like a "next action" (in GTD parlance)... I have added it to the tracker. I cannot say when we will do anything about it, nor what, but if anyone wants to contribute a benchmarking script then it would probably happen sooner or encourage others to hack on it. - Andy From reportlab at chatin.info Fri Mar 6 23:23:37 2009 From: reportlab at chatin.info (reportlab) Date: Sat, 07 Mar 2009 06:43:37 0180 Subject: [reportlab-users] 16508 C-A-N-A-D-l-A-N P-H-A-R-M-A-C-Y Message-ID: <510701c99ed6$e5dac700$7a2f2dbd@maxsuel-1df9bd7> An HTML attachment was scrubbed... URL: -------------- next part -------------- About this mailing: You are receiving this e-mail because you subscribed to MSN Featured Offers. Microsoft respects your privacy. If you do not wish to receive this MSN Featured Offers e-mail, please click the "Unsubscribe" link below. This will not unsubscribe you from e-mail communications from third-party advertisers that may appear in MSN Feature Offers. This shall not constitute an offer by MSN. MSN shall not be responsible or liable for the advertisers' content nor any of the goods or service advertised. Prices and item availability subject to change without notice. ?2009 Microsoft | Unsubscribe at http://jijhalih.cn | More news at http://jijhalih.cn | Prvacy at http://jijhalih.cn Microsoft Corporation, One Microsoft Way, Redmond, WA 98052 From reportlab at chatin.info Fri Mar 6 23:23:37 2009 From: reportlab at chatin.info (reportlab) Date: Sat, 07 Mar 2009 06:43:37 0180 Subject: [reportlab-users] 16508 C-A-N-A-D-l-A-N P-H-A-R-M-A-C-Y Message-ID: <510601c99ed6$e5dac700$7a2f2dbd@maxsuel-1df9bd7> An HTML attachment was scrubbed... URL: -------------- next part -------------- About this mailing: You are receiving this e-mail because you subscribed to MSN Featured Offers. Microsoft respects your privacy. If you do not wish to receive this MSN Featured Offers e-mail, please click the "Unsubscribe" link below. This will not unsubscribe you from e-mail communications from third-party advertisers that may appear in MSN Feature Offers. This shall not constitute an offer by MSN. MSN shall not be responsible or liable for the advertisers' content nor any of the goods or service advertised. Prices and item availability subject to change without notice. ?2009 Microsoft | Unsubscribe at http://jijhalih.cn | More news at http://jijhalih.cn | Prvacy at http://jijhalih.cn Microsoft Corporation, One Microsoft Way, Redmond, WA 98052 From thegisguy at gmail.com Mon Mar 9 15:02:38 2009 From: thegisguy at gmail.com (Matt McKimmy) Date: Mon, 9 Mar 2009 15:02:38 -0400 Subject: [reportlab-users] Script not working as scheduled task? Message-ID: <870487bc0903091202w7207eff5rf3edd6872509d349@mail.gmail.com> I have a python script which runs fine from Pythonwin 2.4. However when I create a schedualed task to run the script the task runs, but the script crashes during the importing of the reportlab parts. Running Version 2.2. Here is what I'm importing: from reportlab.platypus import Paragraph, SimpleDocTemplate, Spacer from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib.pagesizes import letter from reportlab.lib.units import cm, mm, inch, pica The script simply reads in the contents of a text file, then writes the contents of the text file line by line into a PDF. As I said it works fine if I run it from PythonWin, but when I try to run it as a task it crashes in the imports above. Ideas? Thanks... -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul.barrass at safeonlinebilling.com Mon Mar 9 15:11:02 2009 From: paul.barrass at safeonlinebilling.com (Paul Barrass) Date: Mon, 09 Mar 2009 19:11:02 +0000 Subject: [reportlab-users] Script not working as scheduled task? In-Reply-To: <870487bc0903091202w7207eff5rf3edd6872509d349@mail.gmail.com> References: <870487bc0903091202w7207eff5rf3edd6872509d349@mail.gmail.com> Message-ID: <49B569C6.8030607@safeonlinebilling.com> Matt McKimmy wrote: > I have a python script which runs fine from Pythonwin 2.4. However > when I create a schedualed task to run the script the task runs, but > the script crashes during the importing of the reportlab parts. > Running Version 2.2. > Sounds to me like the paths aren't correct when being run as a scheduled task [though I'm not too familiar with the Windows way of doing things, using cron here...]. How/where is ReportLab installed - in the site-packages (or Win equivalent) or locally? Can you import non-RL third party modules? What exactly is the error - the dump from python would perhaps give a lot of information as to what's failing to load, and why. Paul Barrass. From robin at reportlab.com Tue Mar 10 06:09:20 2009 From: robin at reportlab.com (Robin Becker) Date: Tue, 10 Mar 2009 10:09:20 +0000 Subject: [reportlab-users] Script not working as scheduled task? In-Reply-To: <49B569C6.8030607@safeonlinebilling.com> References: <870487bc0903091202w7207eff5rf3edd6872509d349@mail.gmail.com> <49B569C6.8030607@safeonlinebilling.com> Message-ID: <49B63C50.5070109@chamonix.reportlab.co.uk> Paul Barrass wrote: > Matt McKimmy wrote: >> I have a python script which runs fine from Pythonwin 2.4. However >> when I create a schedualed task to run the script the task runs, but >> the script crashes during the importing of the reportlab parts. >> Running Version 2.2. >> > Sounds to me like the paths aren't correct when being run as a scheduled > task [though I'm not too familiar with the Windows way of doing things, > using cron here...]. How/where is ReportLab installed - in the > site-packages (or Win equivalent) or locally? Can you import non-RL > third party modules? What exactly is the error - the dump from python > would perhaps give a lot of information as to what's failing to load, > and why. > > Paul Barrass. ....... this is more than likely correct. One simple way to check this out is to get your startup script to print out (to a specified log file) some simple details about sys.path the current user etc etc. If your job is running as another user it might be that it cannot access files for some reason. -- Robin Becker From yroman-reportlab at altalang.com Tue Mar 10 17:34:19 2009 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Tue, 10 Mar 2009 17:34:19 -0400 Subject: [reportlab-users] [PATCH] TTFontParser does not support unicode filenames Message-ID: <008401c9a1c7$f82f19d0$0502000a@ad.altalang.com> Attached is a pretty basic patch that adds support for unicode TTF filenames in src\reportlab\pdfbase\ttfonts.py. It's based off the trunk. Thanks, -- Yoann Roman -------------- next part -------------- A non-text attachment was scrubbed... Name: ttfonts.patch Type: application/octet-stream Size: 672 bytes Desc: not available Url : From robin at reportlab.com Wed Mar 11 06:43:07 2009 From: robin at reportlab.com (Robin Becker) Date: Wed, 11 Mar 2009 10:43:07 +0000 Subject: [reportlab-users] [PATCH] TTFontParser does not support unicode filenames In-Reply-To: <008401c9a1c7$f82f19d0$0502000a@ad.altalang.com> References: <008401c9a1c7$f82f19d0$0502000a@ad.altalang.com> Message-ID: <49B795BB.5060906@chamonix.reportlab.co.uk> Yoann Roman wrote: > Attached is a pretty basic patch that adds support for unicode TTF > filenames in src\reportlab\pdfbase\ttfonts.py. It's based off the > trunk. > > Thanks, ...... A slight modification of the patch is now in the trunk. -- Robin Becker From yroman-reportlab at altalang.com Wed Mar 11 10:41:16 2009 From: yroman-reportlab at altalang.com (Yoann Roman) Date: Wed, 11 Mar 2009 10:41:16 -0400 Subject: [reportlab-users] [PATCH] TTFontParser does not support unicode filenames In-Reply-To: <49B795BB.5060906@chamonix.reportlab.co.uk> References: <008401c9a1c7$f82f19d0$0502000a@ad.altalang.com> <49B795BB.5060906@chamonix.reportlab.co.uk> Message-ID: <007901c9a257$6ec6b320$0502000a@ad.altalang.com> >> Attached is a pretty basic patch that adds support for unicode TTF >> filenames in src\reportlab\pdfbase\ttfonts.py. It's based off the >> trunk. >> >> Thanks, > ...... > A slight modification of the patch is now in the trunk. Thanks! -- Yoann Roman From david at westcontrol.com Thu Mar 12 05:43:22 2009 From: david at westcontrol.com (David Brown) Date: Thu, 12 Mar 2009 10:43:22 +0100 Subject: [reportlab-users] Merging parts of pdf files Message-ID: <49B8D93A.7000609@westcontrol.com> I've been using ReportLab to generate reports from a wxPython application. It's an extremely useful library, and gives much better quality pdfs than using postscript printouts and a postscript to pdf converter (and it's much easier and faster than other sophisticated pdf generators, like pdfLaTeX). One thing I am missing, however, is the ability to import an existing pdf page (or part of a page) as a Flowable in the same way that other images can be added to a page. I am not well versed in the details of the pdf format, but I believe it can handle embedded pdf files in the same way as embedded jpeg images. Certainly pdfLaTeX can handle imported pdf files in this way. Is such a Flowable possible to implement for future versions of ReportLab? At the moment, I'm using pyPdf to merge my generated pdf file with the imported pdf file, which works here but is not a very elegant solution. mvh., David Brown Norway. From andy at reportlab.com Thu Mar 12 08:10:17 2009 From: andy at reportlab.com (Andy Robinson) Date: Thu, 12 Mar 2009 12:10:17 +0000 Subject: [reportlab-users] Merging parts of pdf files In-Reply-To: <49B8D93A.7000609@westcontrol.com> References: <49B8D93A.7000609@westcontrol.com> Message-ID: <956003ae0903120510t677a2573t3556004944e95a72@mail.gmail.com> 2009/3/12 David Brown : > One thing I am missing, however, is the ability to import an existing pdf > page (or part of a page) as a Flowable in the same way that other images can > be added to a page. ?I am not well versed in the details of the pdf format, > but I believe it can handle embedded pdf files in the same way as embedded > jpeg images. Not exactly true - a lot of work is needed to reuse PDF files as graphics, involving fairly thorough parsing of all used fonts and external objects, whereas jpegs can just be slurped into the PDF inline at the right point. We have a commercial add-on, PageCatcher, which does this. Fees depend on volume and you can evaluate it without a commitment - feel free to email me directly, or our enquiries address here, and we can give you a login and a quotation: http://www.reportlab.com/contact/ > At the moment, I'm using pyPdf to merge my generated pdf file with the > imported pdf file, which works here but is not a very elegant solution. That is currently the usual the free solution. Best Regards, Andy Robinson, CEO, ReportLab From a.cappelli at gmail.com Thu Mar 12 09:56:04 2009 From: a.cappelli at gmail.com (Andrea Cappelli) Date: Thu, 12 Mar 2009 14:56:04 +0100 Subject: [reportlab-users] Height of a String Message-ID: <49B91474.3090403@gmail.com> Hi all, it's possible to get teh height of a string? (given font and size, obviously). If I have a text inside a flowable (like Paragraph) i can get width and height of the flowable widt wrapOn method, so i can place exactly the flowable within the page. I would do the same thing with a simple string, i get the length with stringWidth but i don't know how to get the maximun height, so i can for example calculate a rectangle in which the string fits exactly There is a way to do that? Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: not available Url : From andy at reportlab.com Thu Mar 12 10:16:24 2009 From: andy at reportlab.com (Andy Robinson) Date: Thu, 12 Mar 2009 14:16:24 +0000 Subject: [reportlab-users] Height of a String In-Reply-To: <49B91474.3090403@gmail.com> References: <49B91474.3090403@gmail.com> Message-ID: <956003ae0903120716o59c85e41t90223aa92d2488a@mail.gmail.com> 2009/3/12 Andrea Cappelli : > Hi all, > it's possible to get teh height of a string? (given font and size, > obviously). Not with perfect accuracy. For our own purposes, we assume text should fit in a box which extends by [fontsize] up from the baseline, and [leading - fontsize] downwards, but this box will have some extra white space. The font face objects have an 'ascent' and 'descent' specified by the designer of the font, which is in em-square units (1/1000th of the width of a letter 'm', the widest character. You can query this like so... >>> from reportlab.pdfbase import pdfmetrics >>> f = pdfmetrics.getFont('Helvetica') >>> f.face.ascent 718 >>> f.face.descent -207 >>> This means that if you drew a string in Helvetica 10 points it would mostly fit in 7.18 points above the baseline and 2.07 points below. However, this is the designer's metrics for the whole font. It does not cover each individual glyph in YOUR string, which may vary. If working with type 1 files, you might have an 'afm' file with readable text metrics. Otherwise, getting the precise size of a string requires libraries to read the detailed glyph sizes (Just van Rossum's fonttools is good). Our library doesn't go to this level of detail, sadly. - Andy From cameron at cdbdesign.net Thu Mar 12 11:25:43 2009 From: cameron at cdbdesign.net (Cameron Booth) Date: Thu, 12 Mar 2009 10:25:43 -0500 Subject: [reportlab-users] Problems installing ReportLab 2.2 on Ubuntu Hardy Message-ID: Hi there, I'm having some difficulty getting Reportlab 2.2 to install on my Ubuntu Hardy machine. I downloaded the ReportLab_2_3.tar.gz file, untarred it, and have run "python setup.py install", but it fails out with the following error: running build_ext building '_rl_accel' extension creating build/temp.linux-x86_64-2.5/usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c -o build/temp.linux-x86_64-2.5/usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.o /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:11:20: error: Python.h: No such file or directory /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:35: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:36: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:53: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:55: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c: In function 'find_encoding': /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:60: warning: implicit declaration of function 'strcasecmp' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c: At top level: /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:70: error: expected ')' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:80: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:106: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:126: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:168: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:189: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:219: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:269: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:337: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:411: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:484: error: expected ')' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:528: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:577: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:603: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:612: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:622: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:654: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:688: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:722: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:749: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:776: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1688: error: array type has incomplete element type /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1689: error: '_pdfmetrics_defaultEncoding' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1690: error: '_pdfmetrics_getFonts' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1691: error: '_pdfmetrics_getFontInfo' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1692: error: '_pdfmetrics_setFontInfo' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1693: error: '_pdfmetrics_stringWidth' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1694: error: '_pdfmetrics_instanceStringWidth' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1695: error: '_pdfmetrics__SWRecover' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1700: error: '_a85_encode' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1700: error: 'METH_VARARGS' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1701: error: '_a85_decode' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1702: error: 'escapePDF' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1703: error: '_instanceEscapePDF' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1704: error: '_fp_str' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1705: error: '_sameFrag' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1706: error: 'ttfonts_calcChecksum' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1707: error: 'ttfonts_calcChecksumL' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1708: error: 'ttfonts_add32' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1709: error: 'ttfonts_add32L' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1710: error: 'hex32' undeclared here (not in a function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c: In function 'init_rl_accel': /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1734: error: 'PyObject' undeclared (first use in this function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1734: error: (Each undeclared identifier is reported only once /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1734: error: for each function it appears in.) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1734: error: 'd' undeclared (first use in this function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1738: error: 'moduleObject' undeclared (first use in this function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1738: warning: implicit declaration of function 'Py_InitModule3' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1741: error: 'ErrorObject' undeclared (first use in this function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1742: warning: implicit declaration of function 'PyErr_NewException' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1745: warning: implicit declaration of function 'Py_INCREF' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1746: error: 'moduleVersion' undeclared (first use in this function) /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1746: warning: implicit declaration of function 'PyString_FromString' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1751: warning: implicit declaration of function 'PyModule_GetDict' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1752: warning: implicit declaration of function 'PyDict_SetItemString' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1765: warning: implicit declaration of function 'PyErr_Occurred' /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:1765: warning: implicit declaration of function 'Py_FatalError' error: command 'gcc' failed with exit status 1 Does anybody have any advice?? I'm feeling kind of stuck. Thanks in advance! Cameron -------------- next part -------------- An HTML attachment was scrubbed... URL: From federico at panizzolo.it Thu Mar 12 11:28:15 2009 From: federico at panizzolo.it (Federico Fanton) Date: Thu, 12 Mar 2009 16:28:15 +0100 Subject: [reportlab-users] Problems installing ReportLab 2.2 on Ubuntu Hardy In-Reply-To: References: Message-ID: <49B92A0F.6090006@panizzolo.it> Cameron Booth wrote: > Hi there, > > I'm having some difficulty getting Reportlab 2.2 to install on my Ubuntu > Hardy machine. I downloaded the ReportLab_2_3.tar.gz file, untarred it, > and have run "python setup.py install", but it fails out with the > following error: > > running build_ext > building '_rl_accel' extension > creating > build/temp.linux-x86_64-2.5/usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall > -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c > /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c > -o > build/temp.linux-x86_64-2.5/usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.o > /usr/lib/python2.5/site-packages/ReportLab_2_3/src/rl_addons/rl_accel/_rl_accel.c:11:20: > error: Python.h: No such file or directory sudo apt-get install python2.5-dev then retry "python setup.py install" :) From aklaver at comcast.net Thu Mar 12 11:30:26 2009 From: aklaver at comcast.net (Adrian Klaver) Date: Thu, 12 Mar 2009 08:30:26 -0700 Subject: [reportlab-users] Problems installing ReportLab 2.2 on Ubuntu Hardy In-Reply-To: References: Message-ID: <200903120830.26474.aklaver@comcast.net> On Thursday 12 March 2009 8:25:43 am Cameron Booth wrote: > Hi there, > I'm having some difficulty getting Reportlab 2.2 to install on my Ubuntu > Hardy machine. I downloaded the ReportLab_2_3.tar.gz file, untarred it, and > have run "python setup.py install", but it fails out with the following > error: > > > > Does anybody have any advice?? I'm feeling kind of stuck. Thanks in > advance! > > Cameron From README.txt: On Ubuntu, you will need at least build-essentials and python-devel. Check that you have these installed. -- Adrian Klaver aklaver at comcast.net From arkadi at smartbit.be Fri Mar 13 10:16:39 2009 From: arkadi at smartbit.be (Arkadi Colson) Date: Fri, 13 Mar 2009 15:16:39 +0100 Subject: [reportlab-users] table border bottom draw on split Message-ID: <49BA6AC7.3020901@smartbit.be> Hi all, I have a table with several rows, to many in fact to fit on 1 page. For the first row on page 1 I draw LINEABOVE, for the last row (on page 2) I draw LINEBELOW and for the rest between LINEAFTER and LINEBEFORE is called. This way I have a box around the rows. However on the page split I want to have the LINEBELOW also instead of an open table. Is this possible somehow? Or do I have to create a table in a table with BOX set and will the split function draw the LINEBELOW in that case? Can somebody advice me on that? Thanks and best regards, Arkadi Colson From damian at reportlab.com Fri Mar 13 11:48:10 2009 From: damian at reportlab.com (Damian Moore) Date: Fri, 13 Mar 2009 15:48:10 +0000 Subject: [reportlab-users] table border bottom draw on split In-Reply-To: <49BA6AC7.3020901@smartbit.be> References: <49BA6AC7.3020901@smartbit.be> Message-ID: <49BA803A.4020508@reportlab.com> Hi Arkadi, We have a magic coordinate for doing what you describe called 'splitlast'. An example of this can be seen on page 8 of the rml2pdf test_008_tables.pdf. You use this in the start and stop attributes of the line style as so: We recently discovered a side-effect bug in this code which draws an extra line at the top of the continuing table on the next page. If this affects you, a work-around is to use the (Please Turn Over) and tag to add extra elements where table breaks. The example below adds a short table with the same width and styles as the split one. Borders are draw on the left, right and bottom edges to gain some extra white space before the bottom line. You would wrap your long table like so: <-- Your existing long table --> You can read more about the features of PTO in rml2pdf's test_025_pto. Regards, Damian Arkadi Colson wrote: > Hi all, > > > I have a table with several rows, to many in fact to fit on 1 page. > For the first row on page 1 I draw LINEABOVE, for the last row (on > page 2) I draw LINEBELOW and for the rest between LINEAFTER and > LINEBEFORE is called. This way I have a box around the rows. However > on the page split I want to have the LINEBELOW also instead of an open > table. Is this possible somehow? > > Or do I have to create a table in a table with BOX set and will the > split function draw the LINEBELOW in that case? > > Can somebody advice me on that? > > > Thanks and best regards, > Arkadi Colson > > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users From kreno at yumaed.org Fri Mar 13 13:22:01 2009 From: kreno at yumaed.org (Kerri Reno) Date: Fri, 13 Mar 2009 11:22:01 -0600 Subject: [reportlab-users] text of paragraph sits at bottom of area. Message-ID: I'm creating a pay stub with reportlab, that has to fit on one page. I started with Jeff Bauer's hcfa1500.py from the reportlab web site - THANKS JEFF! I was able to modify it to fit my needs, even including a couple of paragraphs. My problem is that the paragraphs print in the bottom of the allowed area. I'm using stylesheet = getSampleStyleSheet() style = stylesheet['Normal'] style.fontName=self.text_font style.fontSize = self.text_size style.leading = int(self.text_size * 1.2) c = self.canvas # x, y = bottom left corner of area # width and height are the maximum area I want the # paragraph to use up p = Paragraph(v,style) f = KeepInFrame(width,height,[p],mode='shrink') f.wrapOn(c,width,height) f.drawOn(c,x,y) This works great, except if the text of the paragraph doesn't take up all the space, then it prints in the bottom portion of the area. I've searched the documentation and the web for an answer, and I just can't find it. I'd appreciate any help you can give me. Thanks in Advance! Kerri -- Yuma Educational Computer Consortium Compass Development Team Kerri Reno kreno at yumaed.org (928) 502-4240 .?:*??*:?. .?:*??*:?. .?:*??*:?. -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcoacarvalho at gmail.com Sun Mar 15 00:20:18 2009 From: marcoacarvalho at gmail.com (Marco Carvalho) Date: Sun, 15 Mar 2009 01:20:18 -0300 Subject: [reportlab-users] Trouble with EAN13 barcode Message-ID: <9c9ec91c0903142120m1789e79dn37f499a84319b9fa@mail.gmail.com> Hi, I'm trying to print EAN13 barcodes but bars are too thick when printed, so two adjacent thin bars appears as one large bar. The problem are the same with eanbc or createBarcodeDrawing Someone can tell me where I'm mistaken? The code I using is here: http://pastebin.com/m32118d6f I'm using a HP Laserjet P1005 printer. Thanks in advance and sorry for my terrible english. -- Marco Carvalho (macs) | marcoacarvalho(a)gmail.com Maceio - Alagoas - Brazil Debian GNU/Linux AMD64 unstable (Sid) GNU-PG ID:08D82127 - Linux Registered User #141545 Not?cias Semanais do Debian em Portugu?s: http://www.debian.org/News/weekly Alertas de Seguran?a Debian (DSA): http://www.debian.org/security Debian-BR-CDD - O seu Debian ? brasileira: http://cdd.debian-br.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From gogtesuyash at gmail.com Tue Mar 17 01:41:14 2009 From: gogtesuyash at gmail.com (Suyash Gogte) Date: Mon, 16 Mar 2009 22:41:14 -0700 (PDT) Subject: [reportlab-users] Invitation to connect on LinkedIn Message-ID: <1881748390.1731115.1237268474361.JavaMail.app@ech3-cdn12.prod> LinkedIn ------------ Support, I'd like to add you to my professional network on LinkedIn. - Suyash Learn more: https://www.linkedin.com/e/isd/521723043/gDeV2_a6/ ------------------------------------------ What is LinkedIn and why should you join? http://learn.linkedin.com/what-is-linkedin ------ (c) 2009, LinkedIn Corporation -------------- next part -------------- An HTML attachment was scrubbed... URL: From arkadi at smartbit.be Tue Mar 17 11:50:47 2009 From: arkadi at smartbit.be (Arkadi Colson) Date: Tue, 17 Mar 2009 16:50:47 +0100 Subject: [reportlab-users] pagenumber position on document with different page orintations Message-ID: <49BFC6D7.5040403@smartbit.be> Hi all, Is it possible to draw page numbers in a document with different page orientations inside? How can I know what page orientation is active on the current page? I need to know the x and y for using the canvas method to draw the page number. If I could request the template of frame ID for the current page, it would solve the problem also. Anybody encountered this problem already? best regards, Arkadi Colson From johntk1 at verizon.net Tue Mar 17 16:14:51 2009 From: johntk1 at verizon.net (John Keubler) Date: Tue, 17 Mar 2009 16:14:51 -0400 Subject: [reportlab-users] page break command Message-ID: <1CC33C8CD2B34D38A483393F3852AF28@winxpws> what is the command for a page break or a new page? -------------- next part -------------- An HTML attachment was scrubbed... URL: From eksortso at gmail.com Tue Mar 17 16:50:44 2009 From: eksortso at gmail.com (David Ostroske) Date: Tue, 17 Mar 2009 16:50:44 -0400 Subject: [reportlab-users] page break command In-Reply-To: <1CC33C8CD2B34D38A483393F3852AF28@winxpws> References: <1CC33C8CD2B34D38A483393F3852AF28@winxpws> Message-ID: 2009/3/17 John Keubler : > what is the command for a page break or a new page? If you're just using the canvas, then canvas.showPage() will take you to a new page. If you're using Platypus, you just need to put a PageBreak flowable into your story. If you're changing templates, make sure to insert NextPageTemplate before the PageBreak. Don't forget these! from reportlab.platypus.doctemplate import NextPageTemplate from reportlab.platypus.flowables import PageBreak -- Dave O From anthony at thefort.org Wed Mar 18 12:07:40 2009 From: anthony at thefort.org (Anthony Plunkett) Date: Wed, 18 Mar 2009 12:07:40 -0400 Subject: [reportlab-users] StringWidth Units Message-ID: <49C11C4C.3080509@thefort.org> New user here, I'm trying to get stringWidth to return the width of a string in mm, and I guess my assumptions are incorrect. I thought I could just multiply the output by the mm unit, and be done-- but doesn't seem so: c.stringWidth("OUTPUT","Courier",18) * mm returns 183.69. But that clearly isn't correct, it's actually more like 23mm. Could someone shed some light on what units it's returning, and ideally, how to get that into mm? Extended Example: from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import letter from reportlab.lib.units import mm from reportlab.pdfbase import pdfmetrics c=canvas.Canvas("output.pdf",pagesize=letter) c.setFont("Courier", 18) c.drawString(10 * mm, 10 * mm, "OUTPUT") print "MM:" + str(c.stringWidth("OUTPUT","Courier", 18)*mm) print "Base Unit: " + str(c.stringWidth("OUTPUT","Courier", 18)) c.showPage() c.save() >>> MM:183.68503937 Base Unit: 64.8 From paul.barrass at safeonlinebilling.com Wed Mar 18 12:15:12 2009 From: paul.barrass at safeonlinebilling.com (Paul Barrass) Date: Wed, 18 Mar 2009 16:15:12 +0000 Subject: [reportlab-users] StringWidth Units In-Reply-To: <49C11C4C.3080509@thefort.org> References: <49C11C4C.3080509@thefort.org> Message-ID: <49C11E10.1040806@safeonlinebilling.com> Anthony Plunkett wrote: > New user here, I'm trying to get stringWidth to return the width of a > string in mm, and I guess my assumptions are incorrect. I thought I > could just multiply the output by the mm unit, and be done-- but > doesn't seem so: > Divide, rather than multiply. -- Paul Barrass. From anthony at thefort.org Wed Mar 18 12:23:50 2009 From: anthony at thefort.org (Anthony Plunkett) Date: Wed, 18 Mar 2009 12:23:50 -0400 Subject: [reportlab-users] StringWidth Units In-Reply-To: <49C11E10.1040806@safeonlinebilling.com> References: <49C11C4C.3080509@thefort.org> <49C11E10.1040806@safeonlinebilling.com> Message-ID: <49C12016.2020009@thefort.org> Thanks Paul, was scratching my head about that for far too long. Paul Barrass wrote: > Divide, rather than multiply. > From peter at maubp.freeserve.co.uk Wed Mar 18 13:19:52 2009 From: peter at maubp.freeserve.co.uk (Peter) Date: Wed, 18 Mar 2009 17:19:52 +0000 Subject: [reportlab-users] External hyperlinks in SVG output In-Reply-To: <320fb6e00902240841h71869ed8p2bf397e82622dc83@mail.gmail.com> References: <320fb6e00901290737k1269fb4en92975edbcf87f88a@mail.gmail.com> <956003ae0901290838g6393c59dxb36e52626ff6429c@mail.gmail.com> <320fb6e00902120555i37c3e7c8ibb0332901c81c0b8@mail.gmail.com> <320fb6e00902121509n3233235dlf44cc1ba6604423b@mail.gmail.com> <320fb6e00902160451m190404c4j9afb3e76ee784f5f@mail.gmail.com> <4999657E.1050506@chamonix.reportlab.co.uk> <320fb6e00902160530y414c939dj2053e54018303cfe@mail.gmail.com> <320fb6e00902160923o7d609de9s903d9ea99db736a3@mail.gmail.com> <320fb6e00902240841h71869ed8p2bf397e82622dc83@mail.gmail.com> Message-ID: <320fb6e00903181019o3aceef5fpbe181ecaf62330fa@mail.gmail.com> On Tue, Feb 24, 2009 at 4:41 PM, Peter wrote: > I've attached a patch against the current SVN version of renderSVG.py > to support making links on closed SVG paths. ?Without this only the > simplest of vector shapes had working links (rectangles, polygons, > circles, etc), but by supporting closed paths this lets the user > create any complicated shape - and have it linkable :) I see this went into SVN on the 3rd of March :) Would the current trunk be used for the next ReportLab 2.3 release (i.e. 2.3.1), or will I have to wait until ReportLab 2.4 before these SVG link features are officially available? Thanks, Peter From andy at reportlab.com Wed Mar 18 13:23:33 2009 From: andy at reportlab.com (Andy Robinson) Date: Wed, 18 Mar 2009 17:23:33 +0000 Subject: [reportlab-users] StringWidth Units In-Reply-To: <49C11C4C.3080509@thefort.org> References: <49C11C4C.3080509@thefort.org> Message-ID: <956003ae0903181023v60302a31p2e8050ea0dc8b66b@mail.gmail.com> 2009/3/18 Anthony Plunkett : > > c.stringWidth("OUTPUT","Courier",18) * mm > returns 183.69. ?But that clearly isn't correct, it's actually more like > 23mm. It's returning the size in points. 'mm' is a numeric constant - the number of points in a millimetre - so you want to divide by mm not multiply by it. - Andy From andy at reportlab.com Wed Mar 18 13:29:26 2009 From: andy at reportlab.com (Andy Robinson) Date: Wed, 18 Mar 2009 17:29:26 +0000 Subject: [reportlab-users] External hyperlinks in SVG output In-Reply-To: <320fb6e00903181019o3aceef5fpbe181ecaf62330fa@mail.gmail.com> References: <320fb6e00901290737k1269fb4en92975edbcf87f88a@mail.gmail.com> <956003ae0901290838g6393c59dxb36e52626ff6429c@mail.gmail.com> <320fb6e00902120555i37c3e7c8ibb0332901c81c0b8@mail.gmail.com> <320fb6e00902121509n3233235dlf44cc1ba6604423b@mail.gmail.com> <320fb6e00902160451m190404c4j9afb3e76ee784f5f@mail.gmail.com> <4999657E.1050506@chamonix.reportlab.co.uk> <320fb6e00902160530y414c939dj2053e54018303cfe@mail.gmail.com> <320fb6e00902160923o7d609de9s903d9ea99db736a3@mail.gmail.com> <320fb6e00902240841h71869ed8p2bf397e82622dc83@mail.gmail.com> <320fb6e00903181019o3aceef5fpbe181ecaf62330fa@mail.gmail.com> Message-ID: <956003ae0903181029t3cf43fe6m84747bb85053752@mail.gmail.com> 2009/3/18 Peter : > Would the current trunk be used for the next ReportLab 2.3 release > (i.e. 2.3.1), or will I have to wait until ReportLab 2.4 before these > SVG link features are officially available? We don't usually do intermediate releases (2.3.1, 2.3.2) unless (a) people scream for one loud enough, or (b) we have a serious bug which needs fixing. Neither has happened at this moment and this is new functionality, so I'd be inclined to call our next release "2.4" - whenever we do one. I have not followed the SVG work closely. Is the new feature doing what you need? Also, do you need a release version soon for some reason (e.g. someone has a policy only to use released versions), and if so by when do you need it? We are very busy with end-of-financial-year projects but could potentially do a release in April. Best Regards, -- Andy Robinson CEO/Chief Architect ReportLab Europe Ltd. Media House, 3 Palmerston Road, Wimbledon, London SW19 1PG, UK Tel +44-20-8545-1570 From peter at maubp.freeserve.co.uk Thu Mar 19 06:36:06 2009 From: peter at maubp.freeserve.co.uk (Peter) Date: Thu, 19 Mar 2009 10:36:06 +0000 Subject: [reportlab-users] External hyperlinks in SVG output In-Reply-To: <956003ae0903181029t3cf43fe6m84747bb85053752@mail.gmail.com> References: <320fb6e00901290737k1269fb4en92975edbcf87f88a@mail.gmail.com> <320fb6e00902120555i37c3e7c8ibb0332901c81c0b8@mail.gmail.com> <320fb6e00902121509n3233235dlf44cc1ba6604423b@mail.gmail.com> <320fb6e00902160451m190404c4j9afb3e76ee784f5f@mail.gmail.com> <4999657E.1050506@chamonix.reportlab.co.uk> <320fb6e00902160530y414c939dj2053e54018303cfe@mail.gmail.com> <320fb6e00902160923o7d609de9s903d9ea99db736a3@mail.gmail.com> <320fb6e00902240841h71869ed8p2bf397e82622dc83@mail.gmail.com> <320fb6e00903181019o3aceef5fpbe181ecaf62330fa@mail.gmail.com> <956003ae0903181029t3cf43fe6m84747bb85053752@mail.gmail.com> Message-ID: <320fb6e00903190336s46e4e38dsf57935736df06546@mail.gmail.com> On Wed, Mar 18, 2009 at 5:29 PM, Andy Robinson wrote: > > 2009/3/18 Peter : >> Would the current trunk be used for the next ReportLab 2.3 release >> (i.e. 2.3.1), or will I have to wait until ReportLab 2.4 before these >> SVG link features are officially available? > > We don't usually do intermediate releases (2.3.1, 2.3.2) unless (a) > people scream for one loud enough, or (b) we have a serious bug which > needs fixing. ? ?Neither has happened at this moment and this is new > functionality, so I'd be inclined to call our next release "2.4" - > whenever we do one. OK, that makes sense. Thanks for clarifying your policy. > I have not followed the SVG work closely. ?Is the new feature doing > what you need? Also, do you need a release version soon for some > reason (e.g. someone has a policy only to use released versions), and > if so by when do you need it? ? ? We are very busy with > end-of-financial-year projects but could potentially do a release in > April. For our own in house use, I'm happy to use a locally patched or SVN copy of reportlab, and have been using both PNG+ImageMap and SVG output successfully on an internal web project. I don't see a new release of ReportLab as urgent, but rather nice to have, especially if I want to release some of this code publicly. So don't rush a release just on my account. On a related topic, would you be interested in an HTML image map renderer in ReportLab? This would return a fragment of HTML for using in combination with a PNG or other bitmap from renderPM as part of a webpage, both drawn from the same ReportLab object. I have something working (links for basic shapes like rectangles, polygons, circles), but there are still some rough edges and missing features (e.g. no links on string objects). It would be nice to have some basic URL support in PDF output, even just for plain (non rotated) rectangles would be useful to me - these could also be used in bar charts etc. I guess you guys have more pressing tasks right now though, and I don't know enough about PDF files and how ReportLab generates them to attempt this (even if I could justify the time). Regards, Peter From andy at reportlab.com Thu Mar 19 07:10:03 2009 From: andy at reportlab.com (Andy Robinson) Date: Thu, 19 Mar 2009 11:10:03 +0000 Subject: [reportlab-users] External hyperlinks in SVG output In-Reply-To: <320fb6e00903190336s46e4e38dsf57935736df06546@mail.gmail.com> References: <320fb6e00901290737k1269fb4en92975edbcf87f88a@mail.gmail.com> <320fb6e00902121509n3233235dlf44cc1ba6604423b@mail.gmail.com> <320fb6e00902160451m190404c4j9afb3e76ee784f5f@mail.gmail.com> <4999657E.1050506@chamonix.reportlab.co.uk> <320fb6e00902160530y414c939dj2053e54018303cfe@mail.gmail.com> <320fb6e00902160923o7d609de9s903d9ea99db736a3@mail.gmail.com> <320fb6e00902240841h71869ed8p2bf397e82622dc83@mail.gmail.com> <320fb6e00903181019o3aceef5fpbe181ecaf62330fa@mail.gmail.com> <956003ae0903181029t3cf43fe6m84747bb85053752@mail.gmail.com> <320fb6e00903190336s46e4e38dsf57935736df06546@mail.gmail.com> Message-ID: <956003ae0903190410j4def7bbbp181da7d8bc518cbd@mail.gmail.com> 2009/3/19 Peter : > On a related topic, would you be interested in an HTML image map > renderer in ReportLab? ?This would return a fragment of HTML for using > in combination with a PNG or other bitmap from renderPM as part of a > webpage, both drawn from the same ReportLab object. ?I have something > working (links for basic shapes like rectangles, polygons, circles), > but there are still some rough edges and missing features (e.g. no > links on string objects). Definitely nice to have. We should probably arrange it so each element in the image map could trigger a javascript function as well as being plain URLs, since Javascript is taking the world over right now.. > > It would be nice to have some basic URL support in PDF output, We do, but not linked in with charts. You can specify rectangles to act as 'hot zones' with hyperlinks to parts of the PDF or external documents. However, when we render a chart to PDF, we're not doing anything like this. It would be very neat if, say, a chart on page 3 of a PDF annual report could 'drill down' to a detailed table on page 17. I think if all these are put together, it would make a very nice extension to the graphics module. We'll probably get some time to think about this in April, but anything you can come up with in the next week or two will certainly get reviewed. We can set up a branch for it if you want to work heavily on this. Best Regards, -- Andy Robinson From a.cappelli at gmail.com Sat Mar 21 06:36:45 2009 From: a.cappelli at gmail.com (Andrea Cappelli) Date: Sat, 21 Mar 2009 11:36:45 +0100 Subject: [reportlab-users] Height of a String In-Reply-To: <956003ae0903120716o59c85e41t90223aa92d2488a@mail.gmail.com> References: <49B91474.3090403@gmail.com> <956003ae0903120716o59c85e41t90223aa92d2488a@mail.gmail.com> Message-ID: <49C4C33D.1070004@gmail.com> Andy Robinson ha scritto: > Not with perfect accuracy. For our own purposes, we assume text > should fit in a box which extends by [fontsize] up from the baseline, > and [leading - fontsize] downwards, but this box will have some > extra white space. > > So if in a Paragraph I set the font and the leading the same value i get lines with no space between? I my tries seems that the leading parameter of a Paragraph isn't the same measure unit of fontSize, but i could be wrong > This means that if you drew a string in Helvetica 10 points it would > mostly fit in 7.18 points above the baseline and 2.07 points below. > Why you say '10 points'? Is the reference fontSize? How can link 10 points to the ascent and the descent? > However, this is the designer's metrics for the whole font. It does > not cover each individual glyph in YOUR string, which may vary. > Ok > If working with type 1 files, you might have an 'afm' file with readable > text metrics. Otherwise, getting the precise size of a string requires > libraries to read the detailed glyph sizes (Just van Rossum's fonttools > is good). Our library doesn't go to this level of detail, sadly. > Thank you very much, i'll check this library From anthony at thefort.org Sat Mar 21 23:33:32 2009 From: anthony at thefort.org (Anthony Plunkett) Date: Sat, 21 Mar 2009 23:33:32 -0400 Subject: [reportlab-users] Congratulations Message-ID: <49C5B18C.1040708@thefort.org> I'm a newcomer to reportlab and I've been blown away by how simple it was to create a label making program. We're opening a new grocery store this coming Friday, and I was frustrated by our current off the shelf label program, so I thought I'd try making my own to automate the tagging process-- the result is: http://www.thefort.org/files/reportlab.pdf The program takes in a csv file and generals 32 labels per page, EAN format (though most the codes are UPC-A, but it's all compatible) everything works, scans fine, runs quickly, and looks great. Thanks to Paul and Andy for the StringWidth help, I used it to centre the descriptions and then work out if the Price area can be centred, or needs to be right justified depending on the length (to stop it running off the right edge of the tag). Reportlab is a fantastic addition to my toolbox and I'm already thinking of other projects to use it on, so I just wanted to say thank you for all the work everyone's done to get it to where it is today. Anthony. From peter at maubp.freeserve.co.uk Tue Mar 24 09:15:13 2009 From: peter at maubp.freeserve.co.uk (Peter) Date: Tue, 24 Mar 2009 13:15:13 +0000 Subject: [reportlab-users] What arguments does fp_str expect? Message-ID: <320fb6e00903240615h63521c9fgb5bf2b322e99aee1@mail.gmail.com> Hi all, Earlier today, I had a problem in the fp_str function in reportlab/lib/utils.py where it was being passed three floats held as strings (perhaps an RGB color tuple, I have not checked yet). The root problem may have been elsewhere (possibly in my own code), but it would help to know what arguments this function expects. There is no docstring, but the comment at the top suggests string arguments might be expected. This sample code shows the issue I am having. This is what I expected to happen: >>> from reportlab.lib.utils import fp_str >>> fp_str([0.123, 1.23, 12.3]) '.123 1.23 12.3' >>> fp_str((0.123, 1.23, 12.3)) '.123 1.23 12.3' >>> fp_str(["0.123", "1.23", "12.3"]) '.123 1.23 12.3' >>> fp_str(("0.123", "1.23", "12.3")) '.123 1.23 12.3' However, the last two examples fail with a TypeError from the abs line (see below): >>> abs("0.123") Traceback (most recent call last): File "", line 1, in TypeError: bad operand type for abs(): 'str' This is my copy of the relevant part of reportlab/lib/utils.py, with two lines of code changed to include a float() conversion. Otherwise it looks the same as that in SVN I think: http://svn.reportlab.com/cgi-bin/viewvc.cgi/public/reportlab/trunk/src/reportlab/lib/utils.py?view=log try: #raise ImportError ### NOTE! FP_STR SHOULD PROBABLY ALWAYS DO A PYTHON STR() CONVERSION ON ARGS ### IN CASE THEY ARE "LAZY OBJECTS". ACCELLERATOR DOESN'T DO THIS (YET) try: from _rl_accel import fp_str # in case of builtin version except ImportError: from reportlab.lib._rl_accel import fp_str # specific except ImportError: from math import log _log_10 = lambda x,log=log,_log_e_10=log(10.0): log(x)/_log_e_10 _fp_fmts = "%.0f", "%.1f", "%.2f", "%.3f", "%.4f", "%.5f", "%.6f" import re _tz_re = re.compile('0+$') del re def fp_str(*a): """Returns a space separated string of the given numbers.""" #PJC: extend this please if len(a)==1 and isSeqType(a[0]): a = a[0] s = [] A = s.append for i in a: sa =abs(float(i)) #PJC change to add float if sa<=1e-7: A('0') else: l = sa<=1 and 6 or min(max(0,(6-int(_log_10(sa)))),6) n = _fp_fmts[l]%float(i) #PJC change to add float if l: n = _tz_re.sub('',n) try: if n[-1]=='.': n = n[:-1] except: print i, n raise A((n[0]!='0' or len(n)==1) and n or n[1:]) return string.join(s) So, should the fp_str function cope with a sequence of numbers as strings (i.e. a list or tuple of strings)? If so, is my simple minded fix appropriate for when the _rl_accel module isn't being used? If not, then I will have to digg a little deeper into my problem to work out why I have a list/tuple of strings instead of a list/tuple of floats. Thanks, Peter From robin at reportlab.com Tue Mar 24 12:55:22 2009 From: robin at reportlab.com (Robin Becker) Date: Tue, 24 Mar 2009 16:55:22 +0000 Subject: [reportlab-users] What arguments does fp_str expect? In-Reply-To: <320fb6e00903240615h63521c9fgb5bf2b322e99aee1@mail.gmail.com> References: <320fb6e00903240615h63521c9fgb5bf2b322e99aee1@mail.gmail.com> Message-ID: <49C9107A.80809@chamonix.reportlab.co.uk> Peter wrote: > Hi all, > > Earlier today, I had a problem in the fp_str function in > reportlab/lib/utils.py where it was being passed three floats held as > strings (perhaps an RGB color tuple, I have not checked yet). The > root problem may have been elsewhere (possibly in my own code), but it > would help to know what arguments this function expects. There is no > docstring, but the comment at the top suggests string arguments might > be expected. fp_str is supposed to convert floats/ints into strings. It's not supposed to be able to convert arbitrary objects (including strings). Probably all this ought to disappear now that we have fixed point. The older versions of acrobat reader used 16.16 fixed point arithmetic so the precision required in the files was strictly limited. The *a argument in the python version indicates that we convert (or expect to convert) more than one value. As a special feature if there is only one argument and that argument is of type list/sequence then we make the arguments the contents of a[0]. > > This sample code shows the issue I am having. This is what I expected > to happen: > >>>> from reportlab.lib.utils import fp_str >>>> fp_str([0.123, 1.23, 12.3]) > '.123 1.23 12.3' >>>> fp_str((0.123, 1.23, 12.3)) > '.123 1.23 12.3' >>>> fp_str(["0.123", "1.23", "12.3"]) > '.123 1.23 12.3' >>>> fp_str(("0.123", "1.23", "12.3")) > '.123 1.23 12.3' > > However, the last two examples fail with a TypeError from the abs line > (see below): > >>>> abs("0.123") > Traceback (most recent call last): > File "", line 1, in > TypeError: bad operand type for abs(): 'str' > > This is my copy of the relevant part of reportlab/lib/utils.py, with > two lines of > code changed to include a float() conversion. Otherwise it looks the same > as that in SVN I think: > http://svn.reportlab.com/cgi-bin/viewvc.cgi/public/reportlab/trunk/src/reportlab/lib/utils.py?view=log > > try: > #raise ImportError > ### NOTE! FP_STR SHOULD PROBABLY ALWAYS DO A PYTHON STR() > CONVERSION ON ARGS > ### IN CASE THEY ARE "LAZY OBJECTS". ACCELLERATOR DOESN'T DO THIS (YET) > try: > from _rl_accel import fp_str # in case of builtin version > except ImportError: > from reportlab.lib._rl_accel import fp_str # specific > except ImportError: > from math import log > _log_10 = lambda x,log=log,_log_e_10=log(10.0): log(x)/_log_e_10 > _fp_fmts = "%.0f", "%.1f", "%.2f", "%.3f", "%.4f", "%.5f", "%.6f" > import re > _tz_re = re.compile('0+$') > del re > def fp_str(*a): > """Returns a space separated string of the given numbers.""" > #PJC: extend this please > if len(a)==1 and isSeqType(a[0]): a = a[0] > s = [] > A = s.append > for i in a: > sa =abs(float(i)) #PJC change to add float > if sa<=1e-7: A('0') > else: > l = sa<=1 and 6 or min(max(0,(6-int(_log_10(sa)))),6) > n = _fp_fmts[l]%float(i) #PJC change to add float > if l: > n = _tz_re.sub('',n) > try: > if n[-1]=='.': n = n[:-1] > except: > print i, n > raise > A((n[0]!='0' or len(n)==1) and n or n[1:]) > return string.join(s) > > > So, should the fp_str function cope with a sequence of numbers as > strings (i.e. a list or tuple of strings)? If so, is my simple minded > fix appropriate for when the _rl_accel module isn't being used? > > If not, then I will have to digg a little deeper into my problem to > work out why I have a list/tuple of strings instead of a list/tuple of > floats. > > Thanks, > > Peter > _______________________________________________ > reportlab-users mailing list > reportlab-users at reportlab.com > http://two.pairlist.net/mailman/listinfo/reportlab-users > -- Robin Becker From peter at maubp.freeserve.co.uk Tue Mar 24 13:32:29 2009 From: peter at maubp.freeserve.co.uk (Peter) Date: Tue, 24 Mar 2009 17:32:29 +0000 Subject: [reportlab-users] What arguments does fp_str expect? In-Reply-To: <49C9107A.80809@chamonix.reportlab.co.uk> References: <320fb6e00903240615h63521c9fgb5bf2b322e99aee1@mail.gmail.com> <49C9107A.80809@chamonix.reportlab.co.uk> Message-ID: <320fb6e00903241032x5a0a7a09i85ac9210bc05949d@mail.gmail.com> On Tue, Mar 24, 2009 at 4:55 PM, Robin Becker wrote: > > Peter wrote: >> >> Hi all, >> >> Earlier today, I had a problem in the fp_str function in >> reportlab/lib/utils.py where it was being passed three floats held as >> strings (perhaps an RGB color tuple, I have not checked yet). ?The >> root problem may have been elsewhere (possibly in my own code), but it >> would help to know what arguments this function expects. ?There is no >> docstring, but the comment at the top suggests string arguments might >> be expected. > > fp_str is supposed to convert floats/ints into strings. It's not supposed to > be able to convert arbitrary objects (including strings). Probably all this > ought to disappear now that we have fixed point. The older versions of > acrobat reader used 16.16 fixed point arithmetic so the precision required > in the files was strictly limited. > > The *a argument in the python version indicates that we convert (or expect > to convert) more than one value. As a special feature if there is only one > argument and that argument is of type list/sequence then we make the > arguments the contents of a[0]. OK - thanks! That means the error I was seeing was triggered elsewhere. I'll have to investigate further... Could you update the fp_str function's docstring with this information? It took me a while to work out what the code was actually doing. My instinct would have been something more like this: def fp_str(*a): if len(a)==1 and isSeqType(a[0]): a = a[0] s = [] A = s.append for value in a: if abs(value) <= 1e-6: A('0') else: #Can use at most 6 dp, don't want leading or trailing zeros A(('%.6f' % value).strip("0")) return " ".join(s) assert fp_str([0.000000123, 0.00000123, 0.0000123, 0.000123 , 0.123, 1.23, 12.3, -12.3]) \ == '0 .000001 .000012 .000123 .123 1.23 12.3 -12.3' Presumably your somewhat more cryptic version is much faster, and avoids international floating point issues (comma versus period)? As an aside, utils.pyt contains several uses of string.join(a_list, a_sep) rather than a_sep.join(a_list), which might be worth fixing. Peter From stephane at harobed.org Thu Mar 26 11:51:02 2009 From: stephane at harobed.org (KLEIN =?iso-8859-1?q?St=E9phane?=) Date: Thu, 26 Mar 2009 15:51:02 +0000 (UTC) Subject: [reportlab-users] [PyPDF] I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm) Message-ID: Hi, To summarize, with PyPDF package, I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm). First, I merge two PDF pages with this code : :: outputStream = file("output.pdf", "w") output = PdfFileWriter() background_pages = PdfFileReader(file("background.pdf", "rb")) foreground_pages = PdfFileReader(file("foreground.pdf", "rb")) bg_page0 = background_pages.getPage(0) fg_page0 = foreground_pages.getPage(0) bg_page0.mergePage( fg_page0 ) output.addPage(page0) output.write(outputStream) outputStream.close() This works greatly. Background and foreground PDF documents size are A4 (paper size). >From this point, I would like : 1. create an empty page with this paper size : A4 width + 10 mm, A4 height + 10 mm 2. merge and center background page in current page (page create at step 1) 3. merge and center foreground page I don't know : * how to change page size ? * how to merge and center page ? I search this informations in PyPDF API and on google... I found nothing. Thanks for your help, Stephane From stephane at harobed.org Thu Mar 26 11:51:02 2009 From: stephane at harobed.org (KLEIN =?iso-8859-1?q?St=E9phane?=) Date: Thu, 26 Mar 2009 15:51:02 +0000 (UTC) Subject: [reportlab-users] [PyPDF] I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm) Message-ID: Hi, To summarize, with PyPDF package, I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm). First, I merge two PDF pages with this code : :: outputStream = file("output.pdf", "w") output = PdfFileWriter() background_pages = PdfFileReader(file("background.pdf", "rb")) foreground_pages = PdfFileReader(file("foreground.pdf", "rb")) bg_page0 = background_pages.getPage(0) fg_page0 = foreground_pages.getPage(0) bg_page0.mergePage( fg_page0 ) output.addPage(page0) output.write(outputStream) outputStream.close() This works greatly. Background and foreground PDF documents size are A4 (paper size). >From this point, I would like : 1. create an empty page with this paper size : A4 width + 10 mm, A4 height + 10 mm 2. merge and center background page in current page (page create at step 1) 3. merge and center foreground page I don't know : * how to change page size ? * how to merge and center page ? I search this informations in PyPDF API and on google... I found nothing. Thanks for your help, Stephane From gherman at darwin.in-berlin.de Fri Mar 27 04:50:30 2009 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Fri, 27 Mar 2009 09:50:30 +0100 Subject: [reportlab-users] [PyPDF] I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm) In-Reply-To: References: Message-ID: <5D85BBE7-3EB5-4A9D-92F5-CC5C393E2F63@darwin.in-berlin.de> KLEIN St?phane: >> From this point, I would like : > > 1. create an empty page with this paper size : A4 width + 10 mm, A4 > height + 10 mm > 2. merge and center background page in current page (page create at > step > 1) > 3. merge and center foreground page > > I don't know : > > * how to change page size ? > * how to merge and center page ? > > I search this informations in PyPDF API and on google... I found > nothing. Hi St?phane, AFAIK, the sample code you're looking for doesn't exit on the PyPDF site, which is supported in a very unpredictable way. But there is hope! ;-) You can have a look at some of my PDF related packages using PyPDF, e.g. pdfnup or pdfgrid, either in the PyPI or here: http://www.dinu-gherman.net/tmp Hope, that helps, Dinu From stephane at harobed.org Fri Mar 27 06:10:34 2009 From: stephane at harobed.org (KLEIN =?iso-8859-1?q?St=E9phane?=) Date: Fri, 27 Mar 2009 10:10:34 +0000 (UTC) Subject: [reportlab-users] [PyPDF] I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm) References: Message-ID: Le Thu, 26 Mar 2009 15:51:02 +0000, KLEIN St?phane a ?crit?: > Hi, > > To summarize, with PyPDF package, I would like merge two A4 PDF > documents in PDF document with A4 size + 10 mm (width + 10mm, height + > 10mm). > > First, I merge two PDF pages with this code : > > :: > > outputStream = file("output.pdf", "w") output = PdfFileWriter() > > background_pages = PdfFileReader(file("background.pdf", "rb")) > foreground_pages = PdfFileReader(file("foreground.pdf", "rb")) > > bg_page0 = background_pages.getPage(0) fg_page0 = > foreground_pages.getPage(0) > > bg_page0.mergePage( fg_page0 ) > > output.addPage(page0) > > output.write(outputStream) > outputStream.close() > > This works greatly. > > Background and foreground PDF documents size are A4 (paper size). > > From this point, I would like : > > 1. create an empty page with this paper size : A4 width + 10 mm, A4 > height + 10 mm > 2. merge and center background page in current page (page create at step > 1) > 3. merge and center foreground page > > I don't know : > > * how to change page size ? > * how to merge and center page ? I found a solution to "translate" a page : :: from reportlab.lib.units import mm import pyPdf def translate_pdf_page(page, delta_x, delta_y): content = pyPdf.pdf.ContentStream(page["/Contents"].getObject(), page.pdf) content.operations.insert(0, [[], '1 0 0 1 %s %s cm' % (delta_x,delta_y)] ) page[pyPdf.generic.NameObject('/Contents')] = content outputStream = file("output.pdf", "w") output = pyPdf.pdf.PdfFileWriter() background_pages = pyPdf.pdf.PdfFileReader(file("background.pdf", "rb")) foreground_pages = pyPdf.pdf.PdfFileReader(file("foreground.pdf", "rb")) bg_page0 = background_pages.getPage(0) fg_page0 = foreground_pages.getPage(0) translate_pdf_page(fg_page0, 5 * mm, 5 * mm) bg_page0.mergePage( fg_page0 ) output.addPage(bg_page0) output.write(outputStream) outputStream.close() Regards, Stephane From stephane at harobed.org Fri Mar 27 06:25:43 2009 From: stephane at harobed.org (KLEIN =?iso-8859-1?q?St=E9phane?=) Date: Fri, 27 Mar 2009 10:25:43 +0000 (UTC) Subject: [reportlab-users] [PyPDF] I would like merge two A4 PDF documents in PDF document with A4 size + 10 mm (width + 10mm, height + 10mm) References: Message-ID: Le Fri, 27 Mar 2009 10:10:34 +0000, KLEIN St?phane a ?crit?: > Le Thu, 26 Mar 2009 15:51:02 +0000, KLEIN St?phane a ?crit?: > >> Hi, >> >> To summarize, with PyPDF package, I would like merge two A4 PDF >> documents in PDF document with A4 size + 10 mm (width + 10mm, height + >> 10mm). >> >> First, I merge two PDF pages with this code : >> >> :: >> >> outputStream = file("output.pdf", "w") output = PdfFileWriter() >> >> background_pages = PdfFileReader(file("background.pdf", "rb")) >> foreground_pages = PdfFileReader(file("foreground.pdf", "rb")) >> >> bg_page0 = background_pages.getPage(0) fg_page0 = >> foreground_pages.getPage(0) >> >> bg_page0.mergePage( fg_page0 ) >> >> output.addPage(page0) >> >> output.write(outputStream) >> outputStream.close() >> >> This works greatly. >> >> Background and foreground PDF documents size are A4 (paper size). >> >> From this point, I would like : >> >> 1. create an empty page with this paper size : A4 width + 10 mm, A4 >> height + 10 mm >> 2. merge and center background page in current page (page create at >> step 1) >> 3. merge and center foreground page >> >> I don't know : >> >> * how to change page size ? >> * how to merge and center page ? > > I found a solution to "translate" a page : > > :: > > from reportlab.lib.units import mm > import pyPdf > > def translate_pdf_page(page, delta_x, delta_y): > content = pyPdf.pdf.ContentStream(page["/Contents"].getObject(), > page.pdf) > content.operations.insert(0, [[], '1 0 0 1 %s %s cm' % > (delta_x,delta_y)] ) > page[pyPdf.generic.NameObject('/Contents')] = content > > outputStream = file("output.pdf", "w") output = > pyPdf.pdf.PdfFileWriter() > > background_pages = pyPdf.pdf.PdfFileReader(file("background.pdf", > "rb")) > foreground_pages = pyPdf.pdf.PdfFileReader(file("foreground.pdf", > "rb")) > > bg_page0 = background_pages.getPage(0) fg_page0 = > foreground_pages.getPage(0) > > translate_pdf_page(fg_page0, 5 * mm, 5 * mm) > > bg_page0.mergePage( fg_page0 ) > > output.addPage(bg_page0) > > output.write(outputStream) > outputStream.close() Now, I've another function to add some marges to page : :: PAGE_BOXES = ("/MediaBox", "/CropBox", "/BleedBox", "/TrimBox", "/ ArtBox") def add_marges(page, top, right, bottom, left): for boxname in PAGE_BOXES: if not page.get(boxname): continue box = pyPdf.pdf.getRectangle(page, boxname, None) box.upperRight = ( float(box.upperRight[0]) + right + left, float(box.upperRight[1]) + top + bottom ) translate_pdf_page(page, left, bottom) I can add some marging (the size) to bg_page0, example : :: bg_page0 = background_pages.getPage(0) fg_page0 = foreground_pages.getPage(0) translate_pdf_page(fg_page0, 5 * mm, 5 * mm) bg_page0.mergePage( fg_page0 ) add_marges(bg_page0, 20 *mm, 20*mm, 10 * mm, 10 * mm) output.addPage(bg_page0) output.write(outputStream) outputStream.close() Regards, Stephane From dirk.holtwick at gmail.com Mon Mar 30 03:47:13 2009 From: dirk.holtwick at gmail.com (Dirk Holtwick) Date: Mon, 30 Mar 2009 09:47:13 +0200 Subject: [reportlab-users] _digester Message-ID: <49D07901.5080007@gmail.com> Hi, I had a nasty bug for some time in Pisa regarding images. Finally I found out that this was originally a bug in Reportlab and therefore I would like to let you know. The problem seems to be that the function "_digester" in reportlab.utils seems not to return reliable hash values. That has lead to reuse of the wrong images in my document. This happened randomly and was hard to find the cause for it. Here is the code: -----------------8<---------------[cut here] if sys.hexversion >= 0x02000000: def _digester(s): return md5(s).hexdigest() else: # hexdigest not available in 1.5 def _digester(s): return join(map(lambda x : "%02x" % ord(x), md5(s).digest()), '') -----------------8<---------------[cut here] When working with StringIO in my image reader implementation the id() of my object is passed to "_digester". But even if different id()s are passed it seems that already used digest are returned. So please consider to switch from "md5" to something else. I don't know if "hash()" might return better results. Cheers Dirk