Ejemplo n.º 1
0
 def _add_text(self, text, canvas, coords):
     textobject = canvas.beginText(*coords)
     textobject.setFont("Helvetica", 14)
     text = text.replace('\r', '\n').replace('\n\n', '\n')
     for line in text.split('\n'):
         textobject.textLine(line.strip())
     canvas.drawText(textobject)
Ejemplo n.º 2
0
def main():
    # PDF document layout
    canvas = canvas.Canvas(
        "H:\College Fourth Year\Development Project\Final Year Project 2018\Forensic Reports\SMS Report.pdf",
        pagesize=letter)

    canvas.setLineWidth(.3)
    canvas.setFont('Helvetica', 12)
    canvas.drawString(30, 750, 'LYIT MOBILE FORENSICS DIVISION')
    canvas.drawString(
        500, 750, "Date: " +
        now.strftime("%d-%m-%y"))  # Prints date of the report(on the fly)
    canvas.line(500, 747, 595, 747)
    canvas.drawString(500, 725, 'Case Number:')
    canvas.drawString(580, 725, "10")
    canvas.line(500, 723, 595, 723)

    # Introduction text
    line1 = 'This forensic report on sms data has been compiled by the forensic'
    line2 = 'examiner in conclusion to the investigation into the RTA'
    line3 = 'case which occurred on the 23/01/2018.'
    textObject = canvas.beginText(30, 700)
    lines = [line1, line2, line3]
    for line in lines:
        textObject.textLine(line)
    canvas.drawText(textObject)

    canvas.save()
Ejemplo n.º 3
0
 def afterDrawPage(self, canvas, doc):
     order = self.order
     canvas.saveState()
     left_text = "The Bob Miller Book Room\nAcct#: {}".format(
         order.distributor.account_number)
     center_text = "PO#: {}\n{}".format(order.po, order.date)
     right_text = "{}".format(order.distributor.full_name)
     tx = create_text_object(canvas,
                             2 * cm,
                             PAGE_HEIGHT - 2 * cm,
                             left_text,
                             styleN,
                             align='left')
     canvas.drawText(tx)
     tx = create_text_object(canvas,
                             PAGE_WIDTH / 2.0,
                             PAGE_HEIGHT - 2 * cm,
                             center_text,
                             styleN,
                             align='center')
     canvas.drawText(tx)
     canvas.setFont(styleN.fontName, styleN.fontSize)
     canvas.drawRightString(PAGE_WIDTH - 2 * cm, PAGE_HEIGHT - 2 * cm,
                            right_text)
     canvas.restoreState()
Ejemplo n.º 4
0
def print_line(canvas, y, fontsize, line, force=False):
    """Prints one line of text on the left-hand side of the label.

    :param canvas: ReportLab canvas object
    :param y: vertical coordinate of the lower left corner of the printed text.
        Note that the origin of the coordinate system is the lower left of the
        paper.
    :param fontsize: font size of the text
    :param line: the text to be printed; it must not contain line breaks
    :param force: whether `ExcessException` should be raised if the text has to
        be compressed too much; if ``True``, the text may be compressed as much
        as necessary

    :type canvas: canvas.Canvas
    :type y: float
    :type fontsize: float
    :type line: unicode
    :type force: bool

    :raises ExcessException: if the line is too long and `force` is ``False``
    """
    textobject = canvas.beginText()
    textobject.setFont(institute.reportlab_config.default_fontname, fontsize)
    width = canvas.stringWidth(line, institute.reportlab_config.default_fontname, fontsize)
    excess = width / max_width_text
    if excess > 2 and not force:
        raise ExcessException
    elif excess > 1:
        textobject.setHorizScale(100 / excess)
    textobject.setTextOrigin(horizontal_margin, y + vertical_margin + vertical_relative_offset * fontsize)
    textobject.textOut(line)
    canvas.drawText(textobject)
Ejemplo n.º 5
0
def print_line(canvas, y, fontsize, line, force=False):
    """Prints one line of text on the left-hand side of the label.

    :param canvas: ReportLab canvas object
    :param y: vertical coordinate of the lower left corner of the printed text.
        Note that the origin of the coordinate system is the lower left of the
        paper.
    :param fontsize: font size of the text
    :param line: the text to be printed; it must not contain line breaks
    :param force: whether `ExcessException` should be raised if the text has to
        be compressed too much; if ``True``, the text may be compressed as much
        as necessary

    :type canvas: canvas.Canvas
    :type y: float
    :type fontsize: float
    :type line: unicode
    :type force: bool

    :raises ExcessException: if the line is too long and `force` is ``False``
    """
    textobject = canvas.beginText()
    textobject.setFont(institute.reportlab_config.default_fontname, fontsize)
    width = canvas.stringWidth(line, institute.reportlab_config.default_fontname, fontsize)
    excess = width / max_width_text
    if excess > 2 and not force:
        raise ExcessException
    elif excess > 1:
        textobject.setHorizScale(100 / excess)
    textobject.setTextOrigin(horizontal_margin, y + vertical_margin + vertical_relative_offset * fontsize)
    textobject.textOut(line)
    canvas.drawText(textobject)
Ejemplo n.º 6
0
    def header(self, canvas, doc):
        # Header

        data = self.page_header_data

        header_list_left = ["essenza lubricants", "b>" + data['title'].upper(),
                            "b>" + data['depot'].upper()]

        header_list_right = ["LUBRICANTS", "b>" + "MADE IN " + data['made_in'].upper(),
                             "VALIDITY " + data['valid_from'].upper()]

        canvas.saveState()

        x = 12 * mm
        y = 200 * mm

        for t in header_list_left:

            if 'b>' in t:
                font = "Helvetica-Bold"
                t = t.split('>')[1]
            else:
                font = "Helvetica"

            textobject = canvas.beginText()
            textobject.setFont(font, 10)
            textobject.setTextOrigin(
                x,
                y
            )
            textobject.textLine(t)
            canvas.drawText(textobject)

            y -= 15

        y = 200 * mm

        canvas.drawImage("logo.jpg", x=(A4[1] / 2) - 15 * mm, y=A4[0] - 23 * mm, width=15 * mm, height=15 * mm)

        for t in header_list_right:

            if 'b>' in t:
                font = "Helvetica-Bold"
                t = t.split('>')[1]
            else:
                font = "Helvetica"

            textobject = canvas.beginText()
            textobject.setFont(font, 10)
            textobject.setTextOrigin(
                A4[1] - 12 * mm - stringWidth(t, font, 10),
                y
            )
            textobject.textLine(t)
            canvas.drawText(textobject)

            y -= 15

        canvas.restoreState()
Ejemplo n.º 7
0
Archivo: invoice.py Proyecto: ses4j/ts
def draw_address(canvas):
    """ Draws the business address """

    canvas.setFont('Helvetica', 9)
    textobject = canvas.beginText(13 * cm, -2.5 * cm)
    for line in business_details:
        textobject.textLine(line)
    canvas.drawText(textobject)
Ejemplo n.º 8
0
    def draw_due_date(self, canvas, due_date):
        """Draw due date. This will probably be ignored by quite a few but..."""

        textobject = canvas.beginText()
        textobject.setTextOrigin(170*mm, 95*mm)
        textobject.setFont(self.FONT, 10)
        textobject.textLine(due_date)
        canvas.drawText(textobject)
Ejemplo n.º 9
0
    def draw_account_no(self, canvas, account):
        """Draw the account no"""

        textobject = canvas.beginText()
        textobject.setTextOrigin(133*mm, 2.13*cm)
        textobject.setFont(self.BOLDFONT, 10)
        textobject.textLine(account)
        canvas.drawText(textobject)
Ejemplo n.º 10
0
    def draw_payment_info(self, canvas, info):
        """Add payment information. This will probably be copied and pasted by the member"""

        textobject = canvas.beginText()
        textobject.setTextOrigin(1.5*cm, 9.0*cm)
        textobject.setFont(self.BOLDFONT, 10)
        textobject.textLine(info)
        canvas.drawText(textobject)
Ejemplo n.º 11
0
    def draw_address_heading(self, canvas, address):
        """Draw member's address at the top of the page."""

        textobject = canvas.beginText()
        textobject.setTextOrigin(2.0*cm, 24.5*cm)
        textobject.setFont(self.FONT, 12)
        for line in address.split('\n'):
            textobject.textLine(line)
        canvas.drawText(textobject)
Ejemplo n.º 12
0
def drawPageNumbers(canvas, style, pages, availWidth, availHeight, dot=' . '):
    '''
    Draws pagestr on the canvas using the given style.
    If dot is None, pagestr is drawn at the current position in the canvas.
    If dot is a string, pagestr is drawn right-aligned. If the string is not empty,
    the gap is filled with it.
    '''
    pages.sort()
    pagestr = ', '.join([str(p) for p, _ in pages])
    x, y = canvas._curr_tx_info['cur_x'], canvas._curr_tx_info['cur_y']

    fontSize = style.fontSize
    pagestrw = stringWidth(pagestr, style.fontName, fontSize)

    #if it's too long to fit, we need to shrink to fit in 10% increments.
    #it would be very hard to output multiline entries.
    #however, we impose a minimum size of 1 point as we don't want an
    #infinite loop.   Ultimately we should allow a TOC entry to spill
    #over onto a second line if needed.
    freeWidth = availWidth - x
    while pagestrw > freeWidth and fontSize >= 1.0:
        fontSize = 0.9 * fontSize
        pagestrw = stringWidth(pagestr, style.fontName, fontSize)

    if isinstance(dot, strTypes):
        if dot:
            dotw = stringWidth(dot, style.fontName, fontSize)
            dotsn = int((availWidth - x - pagestrw) / dotw)
        else:
            dotsn = dotw = 0
        text = '%s%s' % (dotsn * dot, pagestr)
        newx = availWidth - dotsn * dotw - pagestrw
        pagex = availWidth - pagestrw
    elif dot is None:
        text = ',  ' + pagestr
        newx = x
        pagex = newx
    else:
        raise TypeError(
            'Argument dot should either be None or an instance of basestring.')

    tx = canvas.beginText(newx, y)
    tx.setFont(style.fontName, fontSize)
    tx.setFillColor(style.textColor)
    tx.textLine(text)
    canvas.drawText(tx)

    commaw = stringWidth(', ', style.fontName, fontSize)
    for p, key in pages:
        if not key:
            continue
        w = stringWidth(str(p), style.fontName, fontSize)
        canvas.linkRect('',
                        key, (pagex, y, pagex + w, y + style.leading),
                        relative=1)
        pagex += w + commaw
Ejemplo n.º 13
0
    def draw_payers_address(self, canvas, address):
        """Draw member's address at the bottom"""

        textobject = canvas.beginText()
        textobject.setTextOrigin(1.5*cm, 5.8*cm)
        textobject.setFont(self.FONT, 10)
        address = address.replace('\r','')
        for line in address.split('\n'):
            textobject.textLine(line)
        canvas.drawText(textobject)
Ejemplo n.º 14
0
    def draw_amount(self, canvas, amount):
        """Draw the amount to be paid"""

        textobject = canvas.beginText()
        textobject.setTextOrigin(92*mm, 2.13*cm)
        textobject.setFont(self.BOLDFONT, 10)
        textobject.textLine(amount)
        textobject.setTextOrigin(107*mm, 2.13*cm)
        textobject.textLine('00')
        canvas.drawText(textobject)
Ejemplo n.º 15
0
def lfleft(canvas):
	textobject = canvas.beginText()
	textobject.setTextOrigin(51.2,749)
	textobject.setFont('Gridnik',27)
	textobject.textLines('''
	LEFT 
	FIELD 
	LABS
	''')
	canvas.drawText(textobject)
Ejemplo n.º 16
0
    def draw_recipient_address(self, canvas, address):
        """Draw the club's address"""

        textobject = canvas.beginText()
        textobject.setTextOrigin(11.5*cm, 5.8*cm)
        textobject.setFont(self.FONT, 10)
        address=address.replace('\r', '')
        for line in address.split('\n'):
            textobject.textLine(line)
        canvas.drawText(textobject)
Ejemplo n.º 17
0
 def fillMonthNames(self, canvas):
     for x in range(0, 12):
         textobject = canvas.beginText()
         textobject.setTextOrigin(
             self.monthPositions[x][0],
             7 * self.individualDateTextBoxSize[0] + A4[1] -
             self.monthPositions[x][1])
         textobject.setFont("Helvetica", 14)
         textobject.textOut(calendar.month_name[x + 1])
         canvas.drawText(textobject)
Ejemplo n.º 18
0
def contactleftLaterPages(canvas):
	textobject = canvas.beginText()
	textobject.setTextOrigin(51.2,57)
	textobject.setFont('Akkurat-Light',9)
	textobject.textLines('''
	510 Victoria Ave
	Venice CA 90291
	www.leftfieldlabs.com
	''')
	canvas.drawText(textobject)
Ejemplo n.º 19
0
def horizontalscale(canvas):
    textobject = canvas.beginText()
    textobject.setTextOrigin(3, 2.5 * inch)
    textobject.setFont("Helvetica-Oblique", 12)
    horizontalscale = 80  # 100 is default
    for line in lyrics:
        textobject.setHorizScale(horizontalscale)
        textobject.textLine("%s: %s" % (horizontalscale, line))
        horizontalscale = horizontalscale + 10
        textobject.setFillColorCMYK(0.0, 0.4, 0.4, 0.2)
    canvas.drawText(textobject)
Ejemplo n.º 20
0
def drawPageNumbers(canvas, style, pages, availWidth, availHeight, dot=' . '):
    '''
    Draws pagestr on the canvas using the given style.
    If dot is None, pagestr is drawn at the current position in the canvas.
    If dot is a string, pagestr is drawn right-aligned. If the string is not empty,
    the gap is filled with it.
    '''
    pages.sort()
    pagestr = ', '.join([str(p) for p, _ in pages])
    x, y = canvas._curr_tx_info['cur_x'], canvas._curr_tx_info['cur_y']
    
    fontSize = style.fontSize
    pagestrw = stringWidth(pagestr, style.fontName, fontSize)
    
    #if it's too long to fit, we need to shrink to fit in 10% increments.
    #it would be very hard to output multiline entries.
    #however, we impose a minimum size of 1 point as we don't want an
    #infinite loop.   Ultimately we should allow a TOC entry to spill
    #over onto a second line if needed.
    freeWidth = availWidth-x
    while pagestrw > freeWidth and fontSize >= 1.0:
        fontSize = 0.9 * fontSize
        pagestrw = stringWidth(pagestr, style.fontName, fontSize)
        
    
    if isinstance(dot, strTypes):
        if dot:
            dotw = stringWidth(dot, style.fontName, fontSize)
            dotsn = int((availWidth-x-pagestrw)/dotw)
        else:
            dotsn = dotw = 0
        text = '%s%s' % (dotsn * dot, pagestr)
        newx = availWidth - dotsn*dotw - pagestrw
        pagex = availWidth - pagestrw
    elif dot is None:
        text = ',  ' + pagestr
        newx = x
        pagex = newx
    else:
        raise TypeError('Argument dot should either be None or an instance of basestring.')

    tx = canvas.beginText(newx, y)
    tx.setFont(style.fontName, fontSize)
    tx.setFillColor(style.textColor)
    tx.textLine(text)
    canvas.drawText(tx)

    commaw = stringWidth(', ', style.fontName, fontSize)
    for p, key in pages:
        if not key:
            continue
        w = stringWidth(str(p), style.fontName, fontSize)
        canvas.linkRect('', key, (pagex, y, pagex+w, y+style.leading), relative=1)
        pagex += w + commaw
Ejemplo n.º 21
0
def drawlines(canvas):
	canvas.setStrokeColorRGB(0.2,0.5,0.3)
	canvas.line(0,0,70,70)
	textobject = canvas.beginText()
	textobject.setTextOrigin(51.2,749)
	textobject.textLines('''
	LEFT 
	FIELD 
	LABS
	''')
	canvas.drawText(textobject)
Ejemplo n.º 22
0
 def render(self, canvas):
     if len(self.words) == 1:
         canvas.setFillColor(self.words[0]['color'])
         canvas.drawString(self.coords[0], self.coords[1], self.words[0]['txt'])
     elif len(self.words)>1:
         txt = canvas.beginText()
         txt.setTextOrigin(self.coords[0], self.coords[1])
         for elt in self.words:
             txt.setFillColor(elt['color'])
             txt.textOut(elt['txt'])
         canvas.drawText(txt)
Ejemplo n.º 23
0
 def drawOn(self, canvas, label=None):
     canvas.line(self.p1[0], self.p1[1], self.p2[0], self.p2[1])
     canvas.circle(*self.p1, r=1*mm, fill=True)
     canvas.circle(*self.p2, r=1*mm, fill=False)
     if label is not None:
         textobject = canvas.beginText()
         center = ((self.p1 + self.p2)/2.)
         textobject.setTextOrigin(*center)
         textobject.setFont("Helvetica", 8)
         textobject.textOut(label)
         canvas.drawText(textobject)
Ejemplo n.º 24
0
 def drawOn(self, canvas, label=None):
     canvas.line(self.p1[0], self.p1[1], self.p2[0], self.p2[1])
     canvas.circle(*self.p1, r=1 * mm, fill=True)
     canvas.circle(*self.p2, r=1 * mm, fill=False)
     if label is not None:
         textobject = canvas.beginText()
         center = ((self.p1 + self.p2) / 2.)
         textobject.setTextOrigin(*center)
         textobject.setFont("Helvetica", 8)
         textobject.textOut(label)
         canvas.drawText(textobject)
Ejemplo n.º 25
0
Archivo: invoice.py Proyecto: ses4j/ts
def draw_address(canvas, text=None):
    """ Draws the business address """

    canvas.setFont('Helvetica', 9)
    textobject = canvas.beginText(13 * cm, -2.5 * cm)

    if text is None:
        text = business_details

    for line in text:
        textobject.textLine(line)
    canvas.drawText(textobject)
Ejemplo n.º 26
0
 def render(self, canvas):
     if len(self.words) == 1:
         canvas.setFillColor(self.words[0]['color'])
         canvas.drawString(self.coords[0], self.coords[1],
                           self.words[0]['txt'])
     elif len(self.words) > 1:
         txt = canvas.beginText()
         txt.setTextOrigin(self.coords[0], self.coords[1])
         for elt in self.words:
             txt.setFillColor(elt['color'])
             txt.textOut(elt['txt'])
         canvas.drawText(txt)
Ejemplo n.º 27
0
    def myFirstPage(canvas, doc):
        PAGE_HEIGHT,PAGE_WIDTH = letter
        canvas.saveState()
        canvas.drawImage(fondo, 0,0, PAGE_HEIGHT, PAGE_WIDTH )
        canvas.setStrokeColorRGB(1,0,1,alpha=0.1)
        #canvas.setPageSize(landscape(letter))
        canvas.setFont('Arial', 10)
        canvas.drawString(150, 579, cuenta_cobro.nombre_dependencia)
        canvas.drawString(215, 558, cuenta_cobro.fecha_transaccion)
        canvas.drawString(284, 538, cuenta_cobro.nombre_adquiriente)
        canvas.drawString(90, 513,  cuenta_cobro.nit_adquiriente)
        canvas.drawString(230, 513, cuenta_cobro.direccion_adquiriente)
        canvas.drawString(492, 513, cuenta_cobro.telefono_adquiriente)
        canvas.drawString(120, 488, cuenta_cobro.ciudad_adquiriente)
        #
        canvas.drawString(285, 474, cuenta_cobro.nombre_beneficiario)
        canvas.drawString(140, 448, cuenta_cobro.documento_beneficiario)
        canvas.drawString(365, 448, cuenta_cobro.direccion_beneficiario)
        canvas.drawString(120, 425, cuenta_cobro.telefono_beneficiario)
        canvas.drawString(360, 425, cuenta_cobro.email_beneficiario)
        canvas.drawString(115, 410, cuenta_cobro.ciudad_beneficiario)

        cuenta_cobro.objeto_contrato = textwrap.fill(cuenta_cobro.objeto_contrato, 80)

        textobject = canvas.beginText()
        textobject.setTextOrigin(63, 365)
        textobject.textLines(cuenta_cobro.objeto_contrato)
        canvas.drawText(textobject)

        canvas.drawString(117, 297, cuenta_cobro.no_rpc)
        canvas.drawString(242, 297, cuenta_cobro.no_cdp)
        canvas.drawString(392, 297, cuenta_cobro.valor_contrato)

        canvas.drawString(127, 282, cuenta_cobro.concepto)
        canvas.drawString(127, 268, cuenta_cobro.valor_concepto)
        canvas.drawString(95, 255, cuenta_cobro.valor_concepto_letras)

        SHOW_GRID = False
        if SHOW_GRID:
             n = 5
             s = 200
             #canvas.setStrokeGray(0.90)
             #canvas.setFillGray(0.90)
             canvas.setStrokeColorRGB(0,1,1,alpha=0.1)

             canvas.setFillColorRGB(1,0,1)
             canvas.setFont('Arial',1)
             for x in range(s):
                for y in range(s):
                   canvas.rect(x*n,y*n, width=n, height=n, stroke=1)
                   canvas.drawString(x*n,y*n,"%s,%s" % ((x*n),(y*n)) )
        canvas.restoreState()
Ejemplo n.º 28
0
 def render(self, canvas):
     canvas.saveState()
     empty_index = random.sample(range(9), 2)
     FONT_SIZE = 10
     GAP = 5
     for index, num in enumerate(self._code):
         x = index % 3 * (FONT_SIZE + GAP)
         y = index / 3 * (FONT_SIZE + GAP)
         if index not in empty_index:
             t = canvas.beginText(x, y)
             t.textLine(str(num))
             canvas.drawText(t)
     canvas.restoreState()
def createTextBox(canvas, data, horiz, vert, color, font, size):
    """ Function to draw text """

    textobject = canvas.beginText()
    textobject.setTextOrigin(horiz, vert)
    textobject.setFont(font, size)
    textobject.setFillColor(HexColor(color))
    for line in data.split("\n"):
        vert -= size
        textobject.textLine(line)

    canvas.drawText(textobject)
    return vert
Ejemplo n.º 30
0
    def myFirstPage(canvas, doc):
        PAGE_HEIGHT,PAGE_WIDTH = letter
        canvas.saveState()
        canvas.drawImage(fondo, 0,0, PAGE_HEIGHT, PAGE_WIDTH )
        canvas.setStrokeColorRGB(1,0,1,alpha=0.1)
        #canvas.setPageSize(landscape(letter))
        canvas.setFont('Arial', 8)
        canvas.drawString(132,670, cuenta_cobro.periodo)
        canvas.drawString(475, 670, cuenta_cobro.num_cuota)
        canvas.drawString(132, 653, cuenta_cobro.fecha_transaccion)
        canvas.drawString(132, 633,  cuenta_cobro.no_contrato)

        seguridad_social = "Adjunto planilla de pago de Seguridad social No %s " % (cuenta_cobro.num_planilla_ss,)
        seguridad_social = seguridad_social + " correspondiente a los aportes del mes de %s, en los terminos legales." % (cuenta_cobro.mes_planilla_ss)
        #canvas.drawString(132, 300,textwrap.fill(seguridad_social, 90)  )
        cuenta_cobro.informe_actividades_periodo = textwrap.fill(cuenta_cobro.informe_actividades_periodo, 105)

        textobject = canvas.beginText()
        textobject.setTextOrigin(132, 609)
        textobject.textLines(cuenta_cobro.informe_actividades_periodo)
        canvas.drawText(textobject)

        textobject = canvas.beginText()
        textobject.setTextOrigin(132, 240)
        textobject.textLines(textwrap.fill(seguridad_social, 105))
        canvas.drawText(textobject)

        #canvas.drawString(132, 292,  "correspondiente a los aportes del mes de %s, en los terminos legales." % (cuenta_cobro.mes_planilla_ss))

        canvas.drawCentredString(170, 90, cuenta_cobro.nombre_interventor)
        canvas.drawCentredString(170, 81, "INTERVENTOR/SUPERVISOR %s" % (cuenta_cobro.cargo_interventor,))

        canvas.drawCentredString(415, 90, cuenta_cobro.nombre_beneficiario)
        canvas.drawCentredString(415, 81, "C.C. No. %s de %s" % (cuenta_cobro.documento_beneficiario, cuenta_cobro.lugar_exp_doc_beneficiario))


        SHOW_GRID = False
        if SHOW_GRID:
             n = 5
             s = 200
             #canvas.setStrokeGray(0.90)
             #canvas.setFillGray(0.90)
             canvas.setStrokeColorRGB(0,1,1,alpha=0.1)

             canvas.setFillColorRGB(1,0,1)
             canvas.setFont('Arial',1)
             for x in range(s):
                for y in range(s):
                   canvas.rect(x*n,y*n, width=n, height=n, stroke=1)
                   canvas.drawString(x*n,y*n,"%s,%s" % ((x*n),(y*n)) )
        canvas.restoreState()
Ejemplo n.º 31
0
Archivo: invoice.py Proyecto: ses4j/ts
def draw_footer(canvas, text=None):
    """ Draws the invoice footer """
    note = (
        'Bank Details: Street address, Town, County, POSTCODE',
        'Sort Code: 00-00-00 Account No: 00000000 (Quote invoice number).',
        'Please pay via bank transfer or cheque. All payments should be made in CURRENCY.',
        'Make cheques payable to Company Name Ltd.',
    )
    if text is None:
        text = note
    textobject = canvas.beginText(1 * cm, -27 * cm)
    for line in text:
        textobject.textLine(line)
    canvas.drawText(textobject)
Ejemplo n.º 32
0
Archivo: invoice.py Proyecto: ses4j/ts
def draw_footer(canvas, text=None):
    """ Draws the invoice footer """
    note = (
        u'Bank Details: Street address, Town, County, POSTCODE',
        u'Sort Code: 00-00-00 Account No: 00000000 (Quote invoice number).',
        u'Please pay via bank transfer or cheque. All payments should be made in CURRENCY.',
        u'Make cheques payable to Company Name Ltd.',
    )
    if text is None:
        text = note
    textobject = canvas.beginText(1 * cm, -27 * cm)
    for line in text:
        textobject.textLine(line)
    canvas.drawText(textobject)
Ejemplo n.º 33
0
 def afterDrawPage(self, canvas, doc):
     order = self.order
     canvas.saveState()
     left_text = "The Bob Miller Book Room\nAcct#: {}".format(order.distributor.account_number)
     center_text = "PO#: {}\n{}".format(order.po, order.date)
     right_text = "{}".format(order.distributor.full_name)
     tx = create_text_object(canvas, 2 * cm, PAGE_HEIGHT - 2 * cm,
         left_text, styleN, align='left')
     canvas.drawText(tx)
     tx = create_text_object(canvas, PAGE_WIDTH / 2.0, PAGE_HEIGHT - 2 * cm,
         center_text, styleN, align='center')
     canvas.drawText(tx)
     canvas.setFont(styleN.fontName, styleN.fontSize)
     canvas.drawRightString(PAGE_WIDTH - 2 * cm, PAGE_HEIGHT - 2 * cm, right_text)
     canvas.restoreState()
Ejemplo n.º 34
0
 def draw_footer(canvas,pdf):
     """ Draws the invoice footer """
     oBank=get_object_or_404(SYSTEM_BANK, pk=1)
     oCompany=get_object_or_404(SYSTEM_MAIN, pk=1)
     oCompany=get_object_or_404(SYSTEM_MAIN, pk=1)
     note = (
         u'Bank Details: '+oBank.BankName+'',
         u'Sort Code: '+oBank.BankSortCode+' Account No: '+oBank.BankAccountNo+' (Quote invoice number).',
         u"Please pay via bank transfer or cheque. All payments should be made in "+oBank.Curency.Name+"'s.",
         u'Make cheques payable to '+oCompany.CompanyName+'.',
     )
     textobject = canvas.beginText(1 * cm, -27 * cm)
     for line in note:
         textobject.textLine(line)
     canvas.drawText(textobject)
Ejemplo n.º 35
0
def draw_page(page, uid, survey_name, canvas: reportlab.pdfgen.canvas.Canvas):
    draw_qr_data(canvas, 'survey:' + survey_name + ':' + page.name + ':' + uid,
                 64, (48, height - 64 - 48))
    canvas.setFillColorRGB(0.2, 0.2, 0.2)
    canvas.setStrokeColorRGB(0.2, 0.2, 0.2)
    canvas.circle(32, 32, 4, stroke=1, fill=1)
    canvas.circle(32 + 12, 32, 4, stroke=1, fill=1)
    canvas.circle(32, 32 + 12, 4, stroke=1, fill=1)
    canvas.circle(width - 32, height - 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32 - 12, height - 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32, height - 32 - 12, 4, stroke=1, fill=1)
    canvas.circle(width - 32, 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32 - 12, 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32, 32 + 12, 4, stroke=1, fill=1)
    canvas.circle(32, height - 32, 4, stroke=1, fill=1)
    canvas.circle(32 + 12, height - 32, 4, stroke=1, fill=1)
    canvas.circle(32, height - 32 - 12, 4, stroke=1, fill=1)

    canvas.setFillColorRGB(0.3, 0.3, 0.3)
    canvas.drawString(128, height - 67,
                      survey_name + ':' + page.name + ':' + uid)

    canvas.setFillColorRGB(0.4, 0.4, 0.4)
    canvas.setStrokeColorRGB(0.2, 0.2, 0.2)
    canvas.setFont('Courier', 8)
    for field in page.get_binary_fields():
        canvas.circle(field.position[0],
                      height - field.position[1],
                      5,
                      stroke=1,
                      fill=0)
        canvas.drawCentredString(field.position[0],
                                 height - field.position[1] - 2, field.hint)

    canvas.setFillColorRGB(0.1, 0.1, 0.1)
    for text in page.get_text_areas():
        if text.rotation != 0:
            canvas.saveState()
            canvas.rotate(text.rotation)
        tobj = canvas.beginText(text.position[0], height - text.position[1])
        tobj.setFont(text.fontname, text.fontsize)
        for line in text.text.split():
            tobj.textLine(line)
        canvas.drawText(tobj)

        if text.rotation != 0:
            canvas.restoreState()
    canvas.showPage()
Ejemplo n.º 36
0
def contactleftFirstPage(canvas):
	textobject = canvas.beginText()
	addrwidth = canvas.stringWidth('510 Victoria Ave, Venice CA 90291','Akkurat',10)
	urlwidth = canvas.stringWidth('www.leftfieldlabs.com','Akkurat',10)
	urlx = addrwidth - urlwidth + 18
	phonewidth = canvas.stringWidth('424-500-2045','Akkurat',10)	
	phonex = addrwidth - phonewidth + 18	
	textobject.setTextOrigin(18,75)	
	textobject.setFont('Akkurat',10)
	textobject.textLine('510 Victoria Ave, Venice CA 90291')
	yy = textobject.getY()
	textobject.setTextOrigin(urlx,yy)
	textobject.textLine('www.leftfieldlabs.com')
	yyy = textobject.getY()
	textobject.setTextOrigin(phonex,yyy)
	textobject.textLine('424-500-2045')
	canvas.drawText(textobject)
Ejemplo n.º 37
0
def drawPageNumbers(canvas, style, pages, availWidth, availHeight, dot=' . '):
    '''
    Draws pagestr on the canvas using the given style.
    If dot is None, pagestr is drawn at the current position in the canvas.
    If dot is a string, pagestr is drawn right-aligned. If the string is not empty,
    the gap is filled with it.
    '''
    pages.sort()
    pagestr = ', '.join([str(p) for p, _ in pages])
    x, y = canvas._curr_tx_info['cur_x'], canvas._curr_tx_info['cur_y']
    pagestrw = stringWidth(pagestr, style.fontName, style.fontSize)
    if isinstance(dot, basestring):
        if dot:
            dotw = stringWidth(dot, style.fontName, style.fontSize)
            dotsn = int((availWidth - x - pagestrw) / dotw)
        else:
            dotsn = dotw = 0
        text = '%s%s' % (dotsn * dot, pagestr)
        newx = availWidth - dotsn * dotw - pagestrw
        pagex = availWidth - pagestrw
    elif dot is None:
        text = ',  ' + pagestr
        newx = x
        pagex = newx
    else:
        raise TypeError(
            'Argument dot should either be None or an instance of basestring.')

    tx = canvas.beginText(newx, y)
    tx.setFont(style.fontName, style.fontSize)
    tx.setFillColor(style.textColor)
    tx.textLine(text)
    canvas.drawText(tx)

    commaw = stringWidth(', ', style.fontName, style.fontSize)
    for p, key in pages:
        if not key:
            continue
        w = stringWidth(str(p), style.fontName, style.fontSize)
        canvas.linkRect('',
                        key, (pagex, y, pagex + w, y + style.leading),
                        relative=1)
        pagex += w + commaw
Ejemplo n.º 38
0
    def draw_page_text(self, canvas, heading, body):
        """Draw main text on page"""

        textobject = canvas.beginText()
        textobject.setTextOrigin(2.0*cm, 21.0*cm)

        textobject.setFont(self.BOLDFONT, 14)
        heading = heading.replace('\r', '')
        for line in heading.split('\n'):
            textobject.textLine(line)

        textobject.textLine('')

        textobject.setFont(self.FONT, 12)
        body = body.replace('\r','')
        for line in body.split('\n'):
            textobject.textLine(line)

        canvas.drawText(textobject)
Ejemplo n.º 39
0
def _footer(canvas, doc):
    splunkLayoutSettings = PAPERSIZES[doc.splunkPaperSize]
    canvas.saveState()
    canvas.setStrokeColorRGB(0.8, 0.8, 0.8)
    canvas.setLineWidth(1)  # hairline
    canvas.line(inch, inch, doc.width + inch, inch)
    canvas.setStrokeColorRGB(0.5, 0.5, 0.5)
    canvas.setFillColorRGB(0.586, 0.586, 0.586)
    canvas.drawRightString(doc.width + inch, 0.75 * inch - _TEXT_OFFSET,
                           "Page %d" % (doc.page))

    # draw title centered and ellipsized
    ellipsizedTitle = _ellipsize(doc.getTitle(),
                                 splunkLayoutSettings['ellipsizedTitleCount'])
    ellipsizedTitleWidth = doc.getFontManager().textWidth(
        ellipsizedTitle, _TITLE_SIZE)
    textObject = canvas.beginText(
        inch + doc.width / 2 - ellipsizedTitleWidth / 2,
        0.75 * inch - _TEXT_OFFSET)
    doc.getFontManager().addTextAndFontToTextObject(textObject,
                                                    ellipsizedTitle,
                                                    _TITLE_SIZE)
    canvas.drawText(textObject)

    timestamp = doc.getTimestamp()
    timestampWidth = doc.getFontManager().textWidth(timestamp, _DATE_SIZE)
    textObject = canvas.beginText(inch + doc.width - timestampWidth,
                                  inch - _TEXT_OFFSET)
    doc.getFontManager().addTextAndFontToTextObject(textObject, timestamp,
                                                    _DATE_SIZE)
    canvas.drawText(textObject)

    canvas.restoreState()
    canvas.saveState()
    if doc.getLogoDrawing() != None:
        logoDrawing = doc.getLogoDrawing()
        renderPDF.draw(logoDrawing,
                       canvas,
                       inch,
                       inch - logoDrawing.height - _LOGO_OFFSET,
                       showBoundary=False)
    canvas.restoreState()
Ejemplo n.º 40
0
def horizontalscale(canvas):
    from reportlab.lib.units import inch
    textobject = canvas.beginText()
    textobject.setTextOrigin(3, 2.5 * inch)
    textobject.setFont("Helvetica-Oblique", 12)
    horizontalscale = 80  # 100 is default
    lyrics = [
        "azzeertytui", "jkjlkjlkjlllllllllll",
        "abbbbbbddddkkffffffffffffffffflllllllllllgggggggggggggggggggllll"
    ]
    for line in lyrics:
        textobject.setHorizScale(horizontalscale)
        textobject.textLine("%s: %s" % (horizontalscale, line))
        horizontalscale += 10
        textobject.setFillColorCMYK(0.0, 0.4, 0.4, 0.2)
        textobject.textLines('''
        With many apologies to the Beach Boys
        and anyone else who finds this objectionable
        ''')
    canvas.drawText(textobject)
Ejemplo n.º 41
0
def draw_page(page, uid, survey_name, canvas : reportlab.pdfgen.canvas.Canvas):
    draw_qr_data(canvas, 'survey:'+survey_name+':'+page.name+':'+uid, 64, (48, height-64-48))
    canvas.setFillColorRGB(0.2, 0.2, 0.2)
    canvas.setStrokeColorRGB(0.2, 0.2, 0.2)
    canvas.circle(32, 32, 4, stroke=1, fill=1)
    canvas.circle(32+12, 32, 4, stroke=1, fill=1)
    canvas.circle(32, 32+12, 4, stroke=1, fill=1)
    canvas.circle(width - 32, height - 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32-12, height - 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32, height - 32-12, 4, stroke=1, fill=1)
    canvas.circle(width - 32, 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32-12, 32, 4, stroke=1, fill=1)
    canvas.circle(width - 32, 32+12, 4, stroke=1, fill=1)
    canvas.circle(32, height - 32, 4, stroke=1, fill=1)
    canvas.circle(32+12, height - 32, 4, stroke=1, fill=1)
    canvas.circle(32, height - 32-12, 4, stroke=1, fill=1)

    canvas.setFillColorRGB(0.3, 0.3, 0.3)
    canvas.drawString(128, height - 67, survey_name+':'+page.name+':'+uid)

    canvas.setFillColorRGB(0.4, 0.4, 0.4)
    canvas.setStrokeColorRGB(0.2, 0.2, 0.2)
    canvas.setFont('Courier', 8)
    for field in page.get_binary_fields():
        canvas.circle(field.position[0], height - field.position[1], 5, stroke=1, fill=0)
        canvas.drawCentredString(field.position[0], height - field.position[1]-2, field.hint)

    canvas.setFillColorRGB(0.1, 0.1, 0.1)
    for text in page.get_text_areas():
        if text.rotation != 0:
            canvas.saveState()
            canvas.rotate(text.rotation)
        tobj = canvas.beginText(text.position[0], height - text.position[1])
        tobj.setFont(text.fontname, text.fontsize)
        for line in text.text.split():
            tobj.textLine(line)
        canvas.drawText(tobj)

        if text.rotation != 0:
            canvas.restoreState()
    canvas.showPage()
Ejemplo n.º 42
0
def address_func(canvas, partner):
    """ Draws the business address """
    business_details = (
        partner.ragione_sociale,
        partner.ragione_sociale_fattura,
        partner.indirizzo,
        partner.email,
        U'',
        U'',
        u'',
        u'',
        u'',
        u'',
        u'',
        u''
    )
    canvas.setFont('Helvetica', 9)
    textobject = canvas.beginText(13 * cm, -4 * cm)
    for line in business_details:
        textobject.textLine(line)
    canvas.drawText(textobject)
Ejemplo n.º 43
0
def drawPageNumbers(canvas, style, pages, availWidth, availHeight, dot=' . '):
    '''
    Draws pagestr on the canvas using the given style.
    If dot is None, pagestr is drawn at the current position in the canvas.
    If dot is a string, pagestr is drawn right-aligned. If the string is not empty,
    the gap is filled with it.
    '''
    pages.sort()
    pagestr = ', '.join([str(p) for p, _ in pages])
    x, y = canvas._curr_tx_info['cur_x'], canvas._curr_tx_info['cur_y']
    pagestrw = stringWidth(pagestr, style.fontName, style.fontSize)
    if isinstance(dot, basestring):
        if dot:
            dotw = stringWidth(dot, style.fontName, style.fontSize)
            dotsn = int((availWidth-x-pagestrw)/dotw)
        else:
            dotsn = dotw = 0
        text = '%s%s' % (dotsn * dot, pagestr)
        newx = availWidth - dotsn*dotw - pagestrw
        pagex = availWidth - pagestrw
    elif dot is None:
        text = ',  ' + pagestr
        newx = x
        pagex = newx
    else:
        raise TypeError('Argument dot should either be None or an instance of basestring.')

    tx = canvas.beginText(newx, y)
    tx.setFont(style.fontName, style.fontSize)
    tx.setFillColor(style.textColor)
    tx.textLine(text)
    canvas.drawText(tx)

    commaw = stringWidth(', ', style.fontName, style.fontSize)
    for p, key in pages:
        if not key:
            continue
        w = stringWidth(str(p), style.fontName, style.fontSize)
        canvas.linkRect('', key, (pagex, y, pagex+w, y+style.leading), relative=1)
        pagex += w + commaw
Ejemplo n.º 44
0
def titulo_pdf_proovedor(canvas, doc):
    datos = DATOS_DE_LA_EMPRESA.objects.get(pk=1)
    membrete= '%s \n RIF %s \n DIRECCION: %s \n TELEFONOS: %s / %s \n ZONA POSTAL: %s'%(datos.NOMBRE.upper(),
                                     datos.RIF.upper(), datos.DIRECCION.upper(),
                                     datos.TELEFONO, datos.CELULAR,
                                     datos.CODIGO_POSTAL)
    nombre= datos.NOMBRE.upper()
    rif = 'RIF: %s'% (datos.RIF.upper())
    direccion= 'DIRECCION: %s'% (datos.DIRECCION.upper())
    telefonos = '%s / %s'% (datos.TELEFONO, datos.CELULAR)
    codigo_postal='CODIGO POSTAL: %s'% (datos.CODIGO_POSTAL)


    canvas.saveState()
    canvas.setFillColorRGB(0,0,0)
    #canvas.drawCentredString(50, PAGE_HEIGHT-150, membrete)

    #canvas.drawString(100, 800, str(libro.titulo))#Obtenemos el titulo de un libro y lap.drawImage(str(libro.portada.url), 100, 100, width=400, height=600) 
    # mostramos y guardamos el objeto PDF. 

    canvas.setFont('Times-Bold',12)
    canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-110, nombre)
    canvas.roundRect(0, 750, 694, 120, 20, stroke=0, fill=1) 

    canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-130, rif)
    textobject = canvas.beginText()
    textobject.setTextOrigin(inch, 400)
    textobject.setFont("Helvetica-Oblique", 14)
    for line in direccion:
        textobject.textLine(line)
    textobject.setFillGray(0.4)
    textobject.textLines(direccion)
    canvas.drawText(textobject)
    #canvas.drawString(100, 100, direccion)
    canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-170, telefonos)
    canvas.drawCentredString(PAGE_WIDTH/2.0, PAGE_HEIGHT-190, codigo_postal)

    canvas.drawString(12, 10 * 50, "First Page / %s" % membrete)

    canvas.restoreState()
Ejemplo n.º 45
0
def cursormoves1(canvas):
    textobject = canvas.beginText()
    #textobject.setLeading(12)
    textobject.setTextOrigin(inch, 2.5*inch)
    textobject.setFont("Helvetica-Oblique", 14)
    lyrics = """well she hit Net Solutions
and she registered her own .com site now
and filled it up with yahoo profile pics
she snarfed in one night now
and she made 50 million when Hugh Hefner
bought up the rights now
and she'll have fun fun fun
til her Daddy takes the keyboard away
""".split('\n')
    for line in lyrics:
         textobject.textLine(line)
    textobject.setFillGray(0.4)
    textobject.textLines('''
    With many apologies to the Beach Boys
    and anyone else who finds this objectionable
    ''')
    canvas.drawText(textobject)
Ejemplo n.º 46
0
def write_title_and_credits(canvas, text, nib_width, partitions, angles, pagesize, horizontal = False):
    canvas.setFillColorRGB(0, 0, 0, 1)
    if not horizontal:
        canvas.rotate(90)
    t = canvas.beginText()
    if text:
        canvas.setTitle(text)
        t.setTextOrigin(10*mm, 3*mm)
        t.setFont("Times-Italic", 20)
        t.textOut(text)
        t.setFont("Times-Italic", 10)
        t.textOut("  (%smm nib, Partitions:%s, angles:%s)"%(nib_width, partitions, angles))

    # canvas.setFillColorRGB(0, 0, 0, 0.2)
    # w,l = (float(x)/100 for x in A4)
    # print w,",",l
    if not horizontal:
        t.setTextOrigin(10*mm, -pagesize[0]-5*mm)
    t.setFont("Times-Roman", 10)
    t.textOut(" Generated using ")
    t.setFont("Times-Italic", 10)
    t.textOut("http://calligraffiti.in/rulings")
    canvas.drawText(t)
Ejemplo n.º 47
0
def contactleftLaterPages(canvas):
	textobject = canvas.beginText()
	lflwidth = canvas.stringWidth('LEFT FIELD LABS','Gridnik',12)
	addrwidth = canvas.stringWidth('510 Victoria Ave, Venice CA 90291','Akkurat',10)
	urlwidth = canvas.stringWidth('www.leftfieldlabs.com','Akkurat',10)
	phonewidth = canvas.stringWidth('424-500-2045','Akkurat',10)	
	phonex = addrwidth - phonewidth + 18
	lflx = addrwidth - lflwidth + 18
	urlx = addrwidth - urlwidth + 18
	textobject.setTextOrigin(lflx,75)
	textobject.setFont('Gridnik',12)
	textobject.textLine('LEFT FIELD LABS')
	y = textobject.getY()
	textobject.setTextOrigin(18,y)
	textobject.setFont('Akkurat',10)
	textobject.textLine('510 Victoria Ave, Venice CA 90291')
	yy = textobject.getY()
	textobject.setTextOrigin(urlx,yy)
	textobject.textLine('www.leftfieldlabs.com')
	yyy = textobject.getY()
	textobject.setTextOrigin(phonex,yyy)
	textobject.textLine('424-500-2045')
	canvas.drawText(textobject)
Ejemplo n.º 48
0
    def beforeDrawPage(self, canvas, doc):
        self.senderFrame._reset()
        self.senderFrame.addFromList(self.sendertext[:], canvas)
        self.senderFooterFrame._reset()
        self.senderFooterFrame.addFromList(self.sendertext[:], canvas)
        self.detailsFooterFrame._reset()
        self.detailsFooterFrame.addFromList(self.detailstext, canvas)
        self.bankFooterFrame._reset()
        self.bankFooterFrame.addFromList(self.banktext, canvas)
        with save_state(canvas):
            p = canvas.beginPath()
            p.moveTo(15 * mm, 35 * mm)
            p.lineTo(self.width - 15 * mm, 35 * mm)
            canvas.drawPath(p)

            to = canvas.beginText()
            to.setTextOrigin(118 * mm, self.height - 15 * mm)
            to.setFont('Helvetica-Bold', 24)
            to.textOut(self.kind_text)
            to.moveCursor(50 * mm, 0)
            to.setFont('Helvetica', 10)
            to.textOut(_(u'page %d') % doc.page)
            to.setTextOrigin(118 * mm, self.height - 21 * mm)
            to.textOut(self.date_text)
            to.moveCursor(50 * mm, 0)
            to.textLine(formatters.date(self.date))
            to.moveCursor(-50 * mm, 0)
            to.textOut(self.ocr_text)
            to.moveCursor(50 * mm, 0)
            to.textLine(self.ocr)
            to.moveCursor(-50 * mm, 0)
            if self.expiryDate:
                to.textOut(_(u'Due date'))
                to.moveCursor(50 * mm, 0)
                to.textLine(formatters.date(self.expiryDate))
                to.moveCursor(-50 * mm, 0)
            canvas.drawText(to)
Ejemplo n.º 49
0
def DrawString(string, canvas, x, y, lead):
    textobject = canvas.beginText()
    textobject.setTextOrigin(x, y)
    textobject.setLeading(lead)
    for i in string.split('\n'):
        if len(i) > 90:
            i = i.split(" ")
            s = len(i) / 4
            wrd = ""
            for w in range(3 * s):
                wrd = wrd + i[w] + " "
            textobject.textLine(wrd)
            wrd = ""
            for w in range(3 * s, len(i)):
                wrd = wrd + i[w] + " "
            textobject.textLine(wrd)
        else:
            textobject.textLine(i)
    return canvas.drawText(textobject)
Ejemplo n.º 50
0
def add_consensus(canvas,title,data,page_limit=PAGE_LIMIT,line_limit=LINE_LIMIT):
	data_lenght = len(data)
	i = 0
	j = 0
	y = CONSENSUS_Y
	x = CONSENSUS_X
	string = ""
	canvas.drawText(new_textobject(title,canvas,TITLE_X,TITLE_Y))
	for i in range(data_lenght):
		string = string + data[i]
		if i % line_limit == 0 and i != 0:
			canvas.drawText(new_textobject(string,canvas,x,y))			
			y = y - 15
			string = ""
			j = j + 1
		if j % page_limit == 0 and j != 0:
			canvas.showPage()
			canvas.drawText(new_textobject(title,canvas,TITLE_X,TITLE_Y))
			y = CONSENSUS_Y
			j = 0
Ejemplo n.º 51
0
def add_split_data(canvas,title,data,page_limit):
	data_list = data.split('\n')
	data_list_lenght = len(data_list)
	i = 0	
	x = TEXT_ORIGIN_X
	y = TEXT_ORIGIN_Y
	for i in range(data_list_lenght):
		canvas.drawText(new_textobject(title,canvas,TITLE_X,TITLE_Y))
		string = data_list[i] + '\n'
		if string.find('*') != -1:
			x = POS_TABS
			canvas.drawText(new_textobject(string,canvas,x,y))
			x = TEXT_ORIGIN_X
		else:
			canvas.drawText(new_textobject(string,canvas,x,y))
		y = y - 15
		if i % page_limit == 0 and i != 0:
			canvas.showPage()
			y = TEXT_ORIGIN_Y
	canvas.showPage()
Ejemplo n.º 52
0
def add_image(canvas,title,image,scale=SCALE):
	canvas.drawText(new_textobject(title,canvas,TITLE_X,TITLE_Y))
	w, h = ImageReader(image).getSize()
	canvas.drawInlineImage(image,IMAGE_ORIGIN_X,IMAGE_ORIGIN_Y,w * scale,h * scale)
	canvas.showPage()