[reportlab-users] Barcode flowable horizontal offset, why?

Jeff Kowalczyk reportlab-users@reportlab.com
Wed, 14 Aug 2002 19:43:32 -0400


Can anyone tell me why this barcode (a flowable) is offset to the right of
its start coordinate? The grid is just for reference. Thanks.

from reportlab.pdfgen import canvas
from reportlab.extensions.barcode.common import *
from reportlab.extensions.barcode.code128 import *

def demo(canvas, x, y, text):
    c = canvas
    bc = Code128(text)
    bc.drawOn(c, x, y)
    t = c.beginText(x,y-10)
    t.setFont('Helvetica',6)
    t.textOut(text)
    c.drawText(t)
    draw_grid(c, x, y)

def draw_grid(canvas, x, y):
    c = canvas
    xlist = range(x-60, x+120, 20)
    ylist = range(y-60, y+120, 20)
    c.setLineWidth(0.05)
    c.setStrokeGray(0.25)
    c.grid(xlist,ylist)
    for x in xlist:
        t = c.beginText(x,ylist[8])
        t.setFont('Helvetica',6)
        t.textOut(str(x))
        c.drawText(t)
    for y in ylist:
        t = c.beginText(xlist[8],y)
        t.setFont('Helvetica',6)
        t.textOut(str(y))
        c.drawText(t)
    c.setStrokeGray(1.0)

if __name__=='__main__':
    c = canvas.Canvas('Barcoding.pdf')
    x, y = 120, 500
    c.circle(x, y, 1)
    demo(c, x, y,'Barcoding')
    c.save()


begin 666 Barcoding.pdf
M)5!$1BTQ+C,-"B63C(N>(%)E<&]R=$QA8B!'96YE<F%T960@4$1&(&1O8W5M
M96YT(&AT=' Z+R]W=W<N<F5P;W)T;&%B+F-O;0T*)2 G0F%S:6-&;VYT<R<@
M)SQR97!O<G1L86(N<&1F8F%S92YP9&9D;V,N4$1&1&EC=&EO;F%R>2!I;G-T
M86YC92!A)R -"C$@,"!O8FH-"B4@5&AE('-T86YD87)D(&9O;G1S(&1I8W1I
M;VYA<GD-"CP\("]&,2 R(# @4B ^/@T*96YD;V)J#0HE("=&,2<@)SQR97!O
M<G1L86(N<&1F8F%S92YP9&9D;V,N4$1&5'EP93%&;VYT(&EN<W1A;F-E(&%T
M)R -"C(@,"!O8FH-"B4@1F]N="!(96QV971I8V$-"CP\("]"87-E1F]N=" O
M2&5L=F5T:6-A#0H@+T5N8V]D:6YG("]7:6Y!;G-I16YC;V1I;F<-"B O3F%M
M92 O1C$-"B O4W5B='EP92 O5'EP93$-"B O5'EP92 O1F]N=" ^/@T*96YD
M;V)J#0HE("=086=E,2<@)SQR97!O<G1L86(N<&1F8F%S92YP9&9D;V,N4$1&
M4&%G92!I;G-T86YC92!A=" P># P)R -"C,@,"!O8FH-"B4@4&%G92!D:6-T
M:6]N87)Y#0H\/" O0V]N=&5N=',@-R P(%(-"B O365D:6%";W@@6R P#0H@
M(# -"B @-3DU+C(W#0H@(#@T,2XX.2!=#0H@+U!A<F5N=" V(# @4@T*("]2
M97-O=7)C97,@/#P@+T9O;G0@,2 P(%(-"B @+U!R;V-3970@6R O4$1&#0H@
M(" O5&5X= T*(" @+TEM86=E0@T*(" @+TEM86=E0PT*(" @+TEM86=E22!=
M(#X^#0H@+U1R86YS(#P\(" ^/@T*("]4>7!E("]086=E(#X^#0IE;F1O8FH-
M"B4@)U(T)R G/')E<&]R=&QA8BYP9&9B87-E+G!D9F1O8RY01$9#871A;&]G
M(&EN<W1A;F-E(&%T(# G( T*-" P(&]B:@T*)2!$;V-U;65N="!2;V]T#0H\
M/" O3W5T;&EN97,@." P(%(-"B O4&%G94UO9&4@+U5S94YO;F4-"B O4&%G
M97,@-B P(%(-"B O5'EP92 O0V%T86QO9R ^/@T*96YD;V)J#0HE("=2-2<@
M)SQR97!O<G1L86(N<&1F8F%S92YP9&9D;V,N4$1&26YF;R!I;G-T86YC92!A
M=" P># P)R -"C4@,"!O8FH-"CP\("]!=71H;W(@*&%N;VYY;6]U<RD-"B O
M0W)E871I;VY$871E("@R,# R,#@Q-#$Y,S<S,2D-"B O4')O9'5C97(@*%)E
M<&]R=$QA8B!H='1P.B\O=W=W+G)E<&]R=&QA8BYC;VTI#0H@+U-U8FIE8W0@
M*'5N<W!E8VEF:65D*0T*("]4:71L92 H=6YT:71L960I(#X^#0IE;F1O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