MCPcopy Create free account
hub / github.com/Distrotech/reportlab / drawOn

Method drawOn

tools/pythonpoint/pythonpoint.py:883–919  ·  view source on GitHub ↗
(self, canv)

Source from the content-addressed store, hash-verified

881 self.text = newtext
882
883 def drawOn(self, canv):
884 # for a string in a section, this will be drawn several times;
885 # so any substitution into the text should be in a temporary
886 # variable
887 if self.hasInfo:
888 # provide a dictionary of stuff which might go into
889 # the string, so they can number pages, do headers
890 # etc.
891 info = {}
892 info['title'] = canv._doc.info.title
893 info['author'] = canv._doc.info.author
894 info['subject'] = canv._doc.info.subject
895 info['page'] = canv.getPageNumber()
896 drawText = self.text % info
897 else:
898 drawText = self.text
899
900 if self.color is None:
901 return
902 lines = string.split(string.strip(drawText), '\\n')
903 canv.saveState()
904
905 canv.setFont(self.font, self.size)
906
907 r,g,b = checkColor(self.color)
908 canv.setFillColorRGB(r,g,b)
909 cur_y = self.y
910 for line in lines:
911 if self.align == TA_LEFT:
912 canv.drawString(self.x, cur_y, line)
913 elif self.align == TA_CENTER:
914 canv.drawCentredString(self.x, cur_y, line)
915 elif self.align == TA_RIGHT:
916 canv.drawRightString(self.x, cur_y, line)
917 cur_y = cur_y - 1.2*self.size
918
919 canv.restoreState()
920
921class PPDrawing:
922 def __init__(self):

Callers

nothing calls this directly

Calls 10

checkColorFunction · 0.85
getPageNumberMethod · 0.80
setFillColorRGBMethod · 0.80
splitMethod · 0.45
saveStateMethod · 0.45
setFontMethod · 0.45
drawStringMethod · 0.45
drawCentredStringMethod · 0.45
drawRightStringMethod · 0.45
restoreStateMethod · 0.45

Tested by

no test coverage detected