def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) ext = os.path.splitext(filename)[-1] self._kind = kind # Prefer svg2rlg for SVG, as it works better if LazyImports.svg2rlg: self._mode = 'svg2rlg' self.doc = LazyImports.svg2rlg.svg2rlg(filename) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.doc.getBounds() # Actually, svg2rlg's getBounds seems broken. self._w, self._h = x2, y2 if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h else: self._mode = None log.error("SVG support not enabled," " please install svg2rlg.") self.__ratio = float(self.imageWidth)/self.imageHeight if kind in ['direct','absolute']: self.drawWidth = width or self.imageWidth self.drawHeight = height or self.imageHeight elif kind in ['bound','proportional']: factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight) self.drawWidth = self.imageWidth*factor self.drawHeight = self.imageHeight*factor
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None, captionTextColor=toColor('black'), captionBackColor=None, border=1, spaceBefore=12, spaceAfter=12, captionGap=None, ): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.captionFont = captionFont self.captionSize = captionSize self.captionTextColor = captionTextColor self.captionBackColor = captionBackColor self.captionGap = captionGap self._captionData = None self.captionHeight = 0 # work out later self.background = background self.border = border self.spaceBefore = spaceBefore self.spaceAfter = spaceAfter self._getCaptionPara() #Larry Meyn's fix - otherwise they all get the number of the last chapter.
def __init__(self, svg, width=None, height=None, kind='direct'): # svg is either a text buffer with svg or a xml node object. Flowable.__init__(self) self._kind = kind s = svglib.SvgRenderer() if isinstance(svg, (str, unicode)): doc = xml.dom.minidom.parseString(svg) svg = doc.documentElement s.render(svg) self.doc = s.finish() #self.doc = svglib.svg2rlg(filename) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.doc.getBounds() self._w, self._h = x2, y2 if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h self.__ratio = float(self.imageWidth)/self.imageHeight if kind in ['direct','absolute']: self.drawWidth = width or self.imageWidth self.drawHeight = height or self.imageHeight elif kind in ['bound','proportional']: factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight) self.drawWidth = self.imageWidth*factor self.drawHeight = self.imageHeight*factor
def __init__(self, width, height, caption="", captionFont=_baseFontNameI, captionSize=12, background=None, captionTextColor=toColor('black'), captionBackColor=None, border=None, spaceBefore=12, spaceAfter=12, captionGap=None, captionAlign='centre', captionPosition='bottom', hAlign='CENTER', ): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.captionFont = captionFont self.captionSize = captionSize self.captionTextColor = captionTextColor self.captionBackColor = captionBackColor self.captionGap = captionGap or 0.5*captionSize self.captionAlign = captionAlign self.captionPosition = captionPosition self._captionData = None self.captionHeight = 0 # work out later self.background = background self.border = border self.spaceBefore = spaceBefore self.spaceAfter = spaceAfter self.hAlign=hAlign self._getCaptionPara() #Larry Meyn's fix - otherwise they all get the number of the last chapter.
def __init__(self, measure_unit, document): Flowable.__init__(self) self.unit = measure_unit self.cursor = Cursor() self._elements = [] self.canv = document.canv self._frame = document.pageTemplate.frames[0]
def __init__(self, width, height, images, preserve_aspect_ratio=True): """ Initialize the 'TriPlanar' class. If a None image is passed, an empty box will be displayed. Parameters ---------- width: float (mandatory) the element width. heights: float (mandatory) the element height. images: 4-uplet or 1-uplet (mandatory) the path to the images to be displayed. If a 4-uplet is specified the display order is (image_upper_left, image_upper_right, image_bottom_left, image_bottom_right) preserve_aspect_ratio: bool (optional, default True) if True preserve the image aspect ratios. """ Flowable.__init__(self) self.width = width self.height = height self.display_mode = "multi" if len(images) == 1: self.display_mode = "single" self.images = images self.preserve_aspect_ratio = preserve_aspect_ratio self.missing_file = os.path.join(os.path.dirname(__file__), "resources", "missing.png")
def __init__(self, height, text_width, text_padding, texts, linecount=42, linespace=14, verbose=0): """ Initialize the 'Intro' class. Parameters ---------- height: float (mandatory) the text box height. text_width: float (mandatory) each text box width. text_padding: float (mandatory) the padding between each text box. texts: list of str (mandatory) the texts to be displayed. linecount: int (optional, default 42) the number of characters in each line. linespace: int (optional, default 14) the space between lines. verbose: int (optional, default 0) the verbosity level. """ Flowable.__init__(self) self.height = height self.text_width = text_width self.text_padding = text_padding self.texts = [] for txt in texts: self.texts.append([txt[i: i + linecount] for i in range(0, len(txt), linecount)]) self.linespace = linespace self.verbose = verbose
def __init__(self, resource, item, labels=None, common=None, backside=False, multiple=False, ): """ Constructor @param resource: the resource @param item: the data item @param labels: the field labels @param common: common data for all cards @param backside: this instance should render a card backside @param multiple: there are multiple cards per page """ Flowable.__init__(self) self.width, self.height = self.cardsize self.resource = resource self.item = item self.labels = labels if labels is not None else {} self.common = common if common is not None else {} self.backside = backside self.multiple = multiple
def __init__(self, width, height, caption="", captionFont="Times-Italic", captionSize=12, background=None, captionTextColor=toColor('black'), captionBackColor=None, border=1, spaceBefore=12, spaceAfter=12, captionGap=None, ): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.captionFont = captionFont self.captionSize = captionSize self.captionTextColor = captionTextColor self.captionBackColor = captionBackColor self.captionGap = captionGap self._captionData = None self.captionHeight = 0 # work out later self.background = background self.border = border self.spaceBefore = spaceBefore self.spaceAfter = spaceAfter
def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) self._kind = kind self._mode = 'svg2rlg' self.doc = svg2rlg(filename) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.doc.getBounds() # Actually, svg2rlg's getBounds seems broken. self._w, self._h = x2, y2 if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h self.__ratio = float(self.imageWidth) / self.imageHeight if kind in ['direct', 'absolute']: self.drawWidth = width or self.imageWidth self.drawHeight = height or self.imageHeight elif kind in ['bound', 'proportional']: factor = min( float(width) / self.imageWidth, float(height) / self.imageHeight ) self.drawWidth = self.imageWidth * factor self.drawHeight = self.imageHeight * factor
def __init__(self, x=0, y=-15, width=100, height=15, text=""): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.text = text self.styles = getSampleStyleSheet()
def __init__(self, fname, width, height): Flowable.__init__(self) self.fname = fname self.width = width self.height = height self.x = 0 self.y = 0 self.page = 0
def __init__(self, texto="", x=0, y=0, width=200, height=10): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.texto = texto self.styles = getSampleStyleSheet()
def __init__(self, fator=None, style=None, imagem=None, x=0, y=0, width=defaultPageSize[0] - (2 * cm), height=55): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.fator = fator self.style = style self.imagem = imagem
def __init__(self, doctor): Flowable.__init__(self) self.user = doctor.refer_userprofile.user self.adr = doctor.address self.x = 0 self.y = 25 self.width = 250 self.height = 15 self.styles = getSampleStyleSheet()
def __init__(self, x=0, y=-15, width=40, height=15, text_label="", text_box=""): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.text_box = text_box self.text_label = text_label self.styles = getSampleStyleSheet() self.styles.add(ParagraphStyle(name='HeadText', fontName='OpenSans-Regular', fontSize=10))
def __init__(self, s, label=None, fontsize=12, color='black'): self.s = s self.label = label self.fontsize = fontsize self.color = color if HAS_MATPLOTLIB: self.parser = mathtext.MathTextParser("Pdf") else: log.error('Math support not available, some parts of this ' + 'document will be rendered incorrectly. Install ' + 'matplotlib.') Flowable.__init__(self) self.hAlign = 'CENTER'
def __init__(self, data, width=500, height=200): Flowable.__init__(self) self.Stats = {} self.data = data self.width = width self.height = height self.styles = getSampleStyleSheet() self.aw = 0 self.ah = 0 self.InitStats() self.Colors = [(0.7, 0.0, 0.0, 0.9), (0.9, 0.20, 0.25, 0.9), (0.45, 0.7, 0.35, 0.9), (0.9, 0.8, 0.15, 0.9), (0.9, 0.55, 0.15, 0.9)]
def __init__(self, coords, paragraphs): Flowable.__init__(self) self.coords = coords # Scale pdf images s = self.coords.get('s', 1.0) for para in paragraphs: if isinstance(para, _PDFImage): para.scale(s) self.paragraphs = paragraphs self._maxWidth = 0
def __init__(self, width, height, leftIndent=0, spaceBefore=0, showBoundary=False): Flowable.__init__(self) self.width = width self.height = height self.leftIndent = leftIndent self.spaceBefore = spaceBefore self.showBoundary = showBoundary self.coords = list()
def __init__(self, canvFig, data, width=500, height=200): Flowable.__init__(self) self.Stats = {} self.data = data self.CanvFig = canvFig self.width = width self.height = height self.styles = getSampleStyleSheet() self.aw = 0 self.ah = 0 self.Fill = 0 self.Stroke = 1 self.InitStats()
def __init__(self, title="", author="", subject="", keywords="", creator="", producer=""): Flowable.__init__(self) self.title = title self.author = author self.subject = subject self.keywords = keywords self.creator = creator self.producer = producer
def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) self._kind = kind self.xobj = xobj = self.load_xobj(srcinfo) self.imageWidth, self.imageHeight = imageWidth, imageHeight = xobj.w, xobj.h width = width or imageWidth height = height or imageHeight if kind in ['bound','proportional']: factor = min(float(width)/imageWidth,float(height)/imageHeight) width = factor * imageWidth height = factor * imageHeight self.drawWidth = width self.drawHeight = height
def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) ext = os.path.splitext(filename)[-1] self._kind = kind # Prefer svglib for SVG, as it works better if ext in ('.svg', '.svgz') and LazyImports.svglib: self._mode = 'svglib' self.doc = LazyImports.svglib.svg2rlg(filename) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.doc.getBounds() # Actually, svglib's getBounds seems broken. self._w, self._h = x2, y2 if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h # Use uniconvertor for the rest elif LazyImports.uniconvertor: load, plugins, self.uniconvertor_save = LazyImports.uniconvertor self._mode = 'uniconvertor' self.doc = load.load_drawing(filename.encode('utf-8')) self.saver = plugins.find_export_plugin( plugins.guess_export_plugin('.pdf')) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.doc.BoundingRect() # The abs is to compensate for what appears to be # a bug in uniconvertor. At least doing it this way # I get the same values as in inkscape. # This fixes Issue 236 self._w, self._h = abs(x2)-abs(x1), abs(y2)-abs(y1) if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h else: self._mode = None log.error("Vector image support not enabled," " please install svglib and/or uniconvertor.") self.__ratio = float(self.imageWidth)/self.imageHeight if kind in ['direct','absolute']: self.drawWidth = width or self.imageWidth self.drawHeight = height or self.imageHeight elif kind in ['bound','proportional']: factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight) self.drawWidth = self.imageWidth*factor self.drawHeight = self.imageHeight*factor
def __init__(self, canvFig, data, width=500, height=200): Flowable.__init__(self) self.Stats = {} self.data = data self.NormalRange = data['y'] self.CanvFig = canvFig self.width = width self.height = height self.styles = getSampleStyleSheet() self.aw = 0 self.ah = 0 self.Fill = 0 self.FillColor = (0.16, 0.5, 0.72, 0.4) self.Stroke = 1 self.InitStats()
def __init__(self, x=0 * inch, y=0 * inch, width=3.68 * inch, height=2.45 * inch, text1="", text2=""): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.text1 = text1 self.text2 = text2 self.styles = getSampleStyleSheet()
def __init__(self, x=0, y=0, width=0, height=0, text="", style="", tbl=None): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.text = text self.style = style self.tbl = tbl
def __init__(self, width, height, author, client, poweredby, project, timepoint, subject, date, linespace=14): """ Initialize the 'Intro' class. Parameters ---------- width: float (mandatory) the element width. height: float (mandatory) the element height. author: str (mandatory) the author name. client: str (mandatory) the client name. poweredby: str (mandatory) the tool used to produce the results. project: str (mandatory) the project name. timepoint: str (mandatory) the project timepoint. subject: str (mandatory) the subject identifier. date: str (mandatory) the study date. linespace: int (mandatory) the space between lines. """ Flowable.__init__(self) self.width = width self.linespace = linespace self.left = [ "Performed by: {0}".format(author), "Client: {0}".format(client), "Powered by: {0}".format(poweredby) ] self.right = [ "Project: {0}".format(project), "Subject: {0}".format(subject), "Time step: {0}".format(timepoint), "QC date: {0}".format(date) ]
def __init__(self, width, height, checkboxSize=11, checkedYes=False, checkedNo=False, x_offset=0, y_offset=0, fontName='Times-Roman'): Flowable.__init__(self) self.width = width self.height = height self.checkboxSize = checkboxSize self.checkedYes = checkedYes self.checkedNo = checkedNo self.x_offset = x_offset self.y_offset = y_offset self.fontName = fontName
def __init__(self, x=0, y=0, width=40, height=15, text="", color="#ffffff", custom_style=None): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.text = text self.colour = color if custom_style is not None: self.custom_style = custom_style else: self.custom_style = getSampleStyleSheet()["Normal"]
def __init__(self, x=0, y=-15, width=40, height=15, text_label="", text_box=""): Flowable.__init__(self) self.x = x self.y = y self.width = width self.height = height self.text_box = text_box self.text_label = text_label self.styles = getSampleStyleSheet() self.styles.add( ParagraphStyle(name='HeadText', fontName='OpenSans-Regular', fontSize=10))
def __init__(self, data, width=500, height=200): Flowable.__init__(self) self.Stats = {} self.dataX = data['data']['time'] self.dataY = data['data']['value'] self.Q1 = data['data']['Q1'] self.Q2 = data['data']['Q2'] self.NormalRange = data['normal_range'] self.width = width self.height = height self.text = data['title'] self.styles = getSampleStyleSheet() self.aw = 0 self.ah = 0 self.InitStats() self.mDataX = self.convert_xAxis_pixels(self.dataX) self.mDataY = self.convert_yAxis_pixels(self.dataY) self.mDataQ1 = self.convert_QData_pixels(self.Q1) self.mDataQ2 = self.convert_QData_pixels(self.Q2)
def __init__(self, data=None, size=25 * mm, fill_color='black', back_color='white', border=4, **kwargs): Flowable.__init__(self) self.x = 0 self.y = 0 self.width = size self.height = size self.size = size self.border = border self.fill_color = fill_color self.back_color = back_color kwargs['box_size'] = 1 kwargs['border'] = 0 self._qr = qrcode.QRCode(**kwargs) if data is not None: self._qr.add_data(data)
def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) self._kind = kind self.xobj = self.load_xobj(srcinfo) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.xobj.BBox self._w, self._h = x2 - x1, y2 - y1 if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h self.__ratio = float(self.imageWidth)/self.imageHeight if kind in ['direct','absolute']: self.drawWidth = width or self.imageWidth self.drawHeight = height or self.imageHeight elif kind in ['bound','proportional']: factor = min(float(width)/self.imageWidth,float(height)/self.imageHeight) self.drawWidth = self.imageWidth*factor self.drawHeight = self.imageHeight*factor
def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) self._kind = kind self.xobj = xobj = self.load_xobj(srcinfo) self.imageWidth, self.imageHeight = imageWidth, imageHeight = xobj.w, xobj.h width = width or imageWidth height = height or imageHeight if kind in ['bound', 'proportional']: factor = min( float(width) / imageWidth, float(height) / imageHeight) width = factor * imageWidth height = factor * imageHeight self.drawWidth = width self.drawHeight = height
def __init__( self, width, height, caption="", captionFont=_baseFontNameI, captionSize=12, background=None, captionTextColor=toColor('black'), captionBackColor=None, border=None, spaceBefore=12, spaceAfter=12, captionGap=None, captionAlign='centre', captionPosition='bottom', hAlign='CENTER', ): Flowable.__init__(self) self.width = width self.figureHeight = height self.caption = caption self.captionFont = captionFont self.captionSize = captionSize self.captionTextColor = captionTextColor self.captionBackColor = captionBackColor self.captionGap = captionGap or 0.5 * captionSize self.captionAlign = captionAlign self.captionPosition = captionPosition self._captionData = None self.captionHeight = 0 # work out later self.background = background self.border = border self.spaceBefore = spaceBefore self.spaceAfter = spaceAfter self.hAlign = hAlign self._getCaptionPara( ) #Larry Meyn's fix - otherwise they all get the number of the last chapter.
def __init__(self, height, text_width, text_padding, texts, linecount=42, linespace=14, verbose=0): """ Initialize the 'Intro' class. Parameters ---------- height: float (mandatory) the text box height. text_width: float (mandatory) each text box width. text_padding: float (mandatory) the padding between each text box. texts: list of str (mandatory) the texts to be displayed. linecount: int (optional, default 42) the number of characters in each line. linespace: int (optional, default 14) the space between lines. verbose: int (optional, default 0) the verbosity level. """ Flowable.__init__(self) self.height = height self.text_width = text_width self.text_padding = text_padding self.texts = [] for txt in texts: self.texts.append( [txt[i:i + linecount] for i in range(0, len(txt), linecount)]) self.linespace = linespace self.verbose = verbose
def __init__(self, filename, width=None, height=None, kind='direct', mask=None, lazy=True, srcinfo=None): Flowable.__init__(self) ext = os.path.splitext(filename)[-1] self._kind = kind # Prefer svg2rlg for SVG, as it works better if LazyImports.svg2rlg: self._mode = 'svg2rlg' self.doc = LazyImports.svg2rlg.svg2rlg(filename) self.imageWidth = width self.imageHeight = height x1, y1, x2, y2 = self.doc.getBounds() # Actually, svg2rlg's getBounds seems broken. self._w, self._h = x2, y2 if not self.imageWidth: self.imageWidth = self._w if not self.imageHeight: self.imageHeight = self._h else: self._mode = None log.error("SVG support not enabled," " please install svg2rlg.") self.__ratio = float(self.imageWidth) / self.imageHeight if kind in ['direct', 'absolute']: self.drawWidth = width or self.imageWidth self.drawHeight = height or self.imageHeight elif kind in ['bound', 'proportional']: factor = min( float(width) / self.imageWidth, float(height) / self.imageHeight) self.drawWidth = self.imageWidth * factor self.drawHeight = self.imageHeight * factor
def __init__(self, tournament): Flowable.__init__(self) self.tournament = tournament
def __init__(self,width): Flowable.__init__(self) self.width = width
def __init__(self, current_x, current_y, invoice): Flowable.__init__(self) self.current_x = current_x self.current_y = current_y self.invoice = invoice
def __init__(self, width, height=0): Flowable.__init__(self) self.width = width self.height = height
def __init__(self, request, contract): Flowable.__init__(self) self.req = request self.contract = contract
def __init__(self, width): Flowable.__init__(self) self.width = width
def __init__(self, current_x, current_y, proposal, invoice): Flowable.__init__(self) self.current_x = current_x self.current_y = current_y self.proposal = proposal self.invoice = invoice
def __init__(self, start, width, height=0): Flowable.__init__(self) self.width = width self.height = height self.start = start
def __init__(self,current_x,current_y,invoice): Flowable.__init__(self) self.current_x = current_x self.current_y = current_y self.invoice = invoice
def __init__(self, title): self.title = title Flowable.__init__(self)
def __init__(self, qr_value): # init and store rendering value Flowable.__init__(self) self.qr_value = qr_value
def __init__(self, text): Flowable.__init__(self) self.text = text
def __init__(self, width, margin): Flowable.__init__(self) self.width = width self.margin = margin self.hAlign = "CENTER" self.height = 0.5*inch
def __init__(self, doc: SimpleDocTemplate, text: str) -> None: Flowable.__init__(self) self.doc = doc self.text = text
def __init__(self, barcode, x, y): Flowable.__init__(self) self.barcode = barcode self.x = x self.y = y
def __init__(self, qr_value: str, border: int = 4): # init and store rendering value Flowable.__init__(self) self.qr_value = qr_value self.border = border
def __init__ (self, title, key) : self._title = title self._key = key Flowable.__init__(self)