ipaqman23
September 12th, 2008, 07:30 PM
Hi,
i got a problem with a long string in Python -
Script Snippet:
# get movie information from db
movie = self.db.Movie.get_by(number=number)
if movie is not None:
if print_number == True:
c.setFont(fontName, 10)
c.drawCentredString(pageWidth/2, 530, number)
c.setFont(fontName, 16)
c.rotate(90)
c.drawString(60, (-pageWidth/2)-8, movie.o_title.encode('utf-8'))
c.rotate(-90)
if movie.image is not None and movie.image != '':
tmp_dest = self.locations['posters']
image = str(os.path.join(tmp_dest, str(movie.image)+".jpg"))
c.drawImage(image, x=(pageWidth-30)/2, y=470, width=30, height=50)
# print movie info
c.setFont(fontName, 8)
textObject = c.beginText()
textObject.setTextOrigin(pageWidth-cover_x, 500)
textObject.setFont(fontName, 8)
textObject.textLine(_("Original Title").encode('utf-8')+': '+str(movie.o_title).encode('utf-8'))
textObject.textLine(_("Title").encode('utf-8')+': '+str(movie.title).encode('utf-8'))
textObject.textLine("")
textObject.textLine(_("Director").encode('utf-8')+': '+str(movie.director).encode('utf-8'))
textObject.textLine("")
textObject.textLine(_("Running Time").encode('utf-8')+': '+str(movie.runtime).encode('utf-8')+ _(" min").encode('utf-8'))
textObject.textLine(_("Country").encode('utf-8')+': '+str(movie.country).encode('utf-8'))
textObject.textLine(_("Genre").encode('utf-8')+': '+str(movie.genre).encode('utf-8'))
textObject.textLine("")
textObject.textLine(_("Handlung").encode('utf-8')+': '+str(movie.plot).encode('utf-8'))
c.drawText(textObject)
# draw bigger poster image
if poster == True and movie.image is not None:
c.drawImage(image, x=(pageWidth-(pageWidth-cover_x)-235), y=(pageHeight/2)-125, width=180, height=250)
c.showPage()
c.save()
self.widgets['print_cover']['window_simple'].hide()
cover_file = os.path.join(self.griffith_dir, "cover.pdf")
Problem:
Variable movie.plot is very long and the script prints just one very long line - not very appealing!
So how can I force word wrap for this string??
i got a problem with a long string in Python -
Script Snippet:
# get movie information from db
movie = self.db.Movie.get_by(number=number)
if movie is not None:
if print_number == True:
c.setFont(fontName, 10)
c.drawCentredString(pageWidth/2, 530, number)
c.setFont(fontName, 16)
c.rotate(90)
c.drawString(60, (-pageWidth/2)-8, movie.o_title.encode('utf-8'))
c.rotate(-90)
if movie.image is not None and movie.image != '':
tmp_dest = self.locations['posters']
image = str(os.path.join(tmp_dest, str(movie.image)+".jpg"))
c.drawImage(image, x=(pageWidth-30)/2, y=470, width=30, height=50)
# print movie info
c.setFont(fontName, 8)
textObject = c.beginText()
textObject.setTextOrigin(pageWidth-cover_x, 500)
textObject.setFont(fontName, 8)
textObject.textLine(_("Original Title").encode('utf-8')+': '+str(movie.o_title).encode('utf-8'))
textObject.textLine(_("Title").encode('utf-8')+': '+str(movie.title).encode('utf-8'))
textObject.textLine("")
textObject.textLine(_("Director").encode('utf-8')+': '+str(movie.director).encode('utf-8'))
textObject.textLine("")
textObject.textLine(_("Running Time").encode('utf-8')+': '+str(movie.runtime).encode('utf-8')+ _(" min").encode('utf-8'))
textObject.textLine(_("Country").encode('utf-8')+': '+str(movie.country).encode('utf-8'))
textObject.textLine(_("Genre").encode('utf-8')+': '+str(movie.genre).encode('utf-8'))
textObject.textLine("")
textObject.textLine(_("Handlung").encode('utf-8')+': '+str(movie.plot).encode('utf-8'))
c.drawText(textObject)
# draw bigger poster image
if poster == True and movie.image is not None:
c.drawImage(image, x=(pageWidth-(pageWidth-cover_x)-235), y=(pageHeight/2)-125, width=180, height=250)
c.showPage()
c.save()
self.widgets['print_cover']['window_simple'].hide()
cover_file = os.path.join(self.griffith_dir, "cover.pdf")
Problem:
Variable movie.plot is very long and the script prints just one very long line - not very appealing!
So how can I force word wrap for this string??