[Tutor] more trouble with PDF program

Jonathan Soons jsoons at juilliard.edu
Tue Nov 18 13:44:53 EST 2003


Many thanks for the advice that got me this far.
Now my remaining problem is that any text carrying 
over to page 2 is printed twice (variable txt below.)
newpage() is only called if text gets  close to the
bottom of page 1.
Can anyone see how the duplication is happening?

def mklines(field) :
    if len(field) < 1 :
        return
    words = field.split(" ")
    while len(words) > 0 :
        line = ""
        while (len(line) < 60) and len(words) > 0 :
            line = line + " " + words[0]
            del(words[0])
        PDF_continue_text(pdf, line)
        line = ""
        if (PDF_get_value(pdf, "texty", 0) < INCH) and (len(words) > 0):
            txt = string.joinfields(words, " ")
            newpage(str(txt))
  
def newpage(words) :
    global pagenum  
    pagenum = pagenum + 1
    PDF_end_page(pdf)
    PDF_begin_page(pdf, WIDTH, HEIGHT)
    PDF_setfont(pdf, font0, 14)
    PDF_set_text_pos(pdf, INCH, 704)
    PDF_show(pdf, last + ", " + first)
    PDF_set_text_pos(pdf, WIDTH - 144, 704)
    if pagenum > 1 :
        PDF_show(pdf, "page %d" % pagenum)
    PDF_setfont(pdf, font1, 12)
    PDF_set_text_pos(pdf, INCH, 690)
    mklines(words)
            

Thanks

jon soons



More information about the Tutor mailing list