[reportlab-users] how to center flowable object?
Andrew Kornilov
frutik at gmail.com
Wed Jun 20 04:41:24 EDT 2007
Hi All!
I improved my barcode generator but still have a problems %)
Why barcode is not centered on canva?
This is my code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from reportlab.lib.units import inch
from reportlab.graphics.barcode.code39 import Standard39
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph, Frame
def run():
styles = getSampleStyleSheet()
styleN = styles['Normal']
barcodeFrame = []
string = 'TE.15K035'
barcode = Standard39(string)
barcode.barHeight = 0.7*inch
barcode.lquiet = 0 # left padding
barcode.hAlign = 'CENTER'
barcodeFrame.append(barcode)
out = 'out.pdf'
c = Canvas(out, pagesize=(162,108))
c.setFont('Times-Roman',10)
c.drawCentredString(80, 0.4*inch, string)
f = Frame(0, 0.7*inch, 2.25*inch, 0.7*inch, leftPadding=0,
rightPadding=0, bottomPadding=0, topPadding=0, showBoundary=1)
f.addFromList(barcodeFrame, c)
c.showPage()
c.save()
if __name__=='__main__':
run()
and result pdf in attachment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20070620/437ba059/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: out.pdf
Type: application/pdf
Size: 2435 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20070620/437ba059/attachment.pdf>
More information about the reportlab-users
mailing list