Exemple #1
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()
Exemple #2
0
def header(canvas, doc):
    # Save the state of our canvas so we can draw on it
    canvas.saveState()
    canvas.setFont("Times-Roman", 12)
    left = 0.98 * inch
    right = 600 - 0.59 * inch
    y = 731
    canvas.setTitle("documento_oficial_webCGAE")
    fn = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      'static/Atividades/icon_ifc2.jpg')
    canvas.drawImage(fn, 10.2 * cm, 770, width=40, height=40)
    canvas.drawCentredString(11.0 * cm, 760, "Ministério da Educação")
    canvas.drawCentredString(
        11.0 * cm, 747, "Secretaria de Educação Profissional e Tecnológica")
    canvas.drawCentredString(11.0 * cm, 735, "Instituto Federal Catarinense")
    canvas.line(left, y, right, y)

    canvas.setFont("Times-Roman", 10)
    canvas.line(left, y - 24.4 * cm, right, y - 24.4 * cm)
    fn = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      'static/Atividades/icon_ifc.png')
    canvas.drawImage(fn, left + 10, y - 25.7 * cm, width=140, height=35)
    canvas.drawRightString(550, y - 24.8 * cm,
                           "Rua das Missões, 100 - Ponta Aguda")
    canvas.drawRightString(550, y - 25.2 * cm, "Blumenau/SC - CEP: 89.051-000")
    canvas.drawRightString(550, y - 25.6 * cm,
                           "(47) 3331-7800 / [email protected]")

    # Release the canvas
    canvas.restoreState()
Exemple #3
0
def framePage(canvas):
    # Деление страницы на 4 зоны линиями
    canvas.setFont('Times-Roman', 20)
    canvas.setStrokeColorRGB(0, 0, 0)
    canvas.setLineWidth(1)
    canvas.line(w / 2, 0, w / 2, h)
    canvas.line(0, h / 2, w, h / 2)
Exemple #4
0
 def drawBounds(self, canvas):
     """Guidelines to help me draw - not needed in production"""
     canvas.setStrokeColor(colors.red)
     canvas.rect(-100, -70, 200, 140)
     canvas.line(-100, 0, 100, 0)
     canvas.line(0, 70, 0, -70)
     canvas.setStrokeColor(colors.black)
Exemple #5
0
def first_page_boxes(canvas):
    #Box1
    canvas.setStrokeColorRGB(0, 0, 0)
    canvas.rect(20, 504, 270, 117)
    canvas.line(20, 599, 290, 599)
    canvas.setFont('palab', 9)
    canvas.drawString(40, 605, 'Bill To:')

    canvas.setFont('pala', 9)
    #Dynamic
    canvas.drawString(40, 585, 'Test Orders Invoices')
    canvas.drawString(40, 573, '123 Center Str')
    canvas.drawString(40, 561, 'Boko Town, Boko 999999')

    #Box2
    canvas.rect(310, 504, 270, 117)
    canvas.line(310, 599, 580, 599)

    canvas.setFont('palab', 9)
    canvas.drawString(320, 605, 'Order Information:')
    canvas.drawString(320, 585, 'Order Date: ')
    canvas.drawString(320, 573, 'Order Name: ')
    canvas.drawString(320, 561, 'Client Matter Number: ')
    canvas.drawString(320, 549, 'Total Amount Due: ')
    canvas.drawString(320, 537, 'Processed By: ')
    canvas.drawString(320, 525, 'Authorized By: ')

    canvas.setFont('pala', 9)
    canvas.drawString(390, 585, 'April 14, 2021')
    canvas.drawString(390, 573, 'Test orders Aaron')
    #canvas.drawString(390, 561,'Client Matter Number: ')
    canvas.drawString(405, 549, '$144945')
    canvas.drawString(390, 537, 'Aaron Sauber')
    canvas.drawString(390, 525, 'Judith Testing')
Exemple #6
0
def cutmark(canvas, x, y, xpol, ypol):
    v('------')
    cutlen = 10
    canvas.line(x, y, x + cutlen * xpol, y)
    v('cutmark() x,y,xe,ye %f %f %f %f' % (x, y, x + cutlen * xpol, y))
    canvas.line(x, y, x, y + cutlen * ypol)
    v('cutmark() x,y,xe,ye %f %f %f %f' % (x, y, x, y + cutlen * ypol))
def test_report():
    from reportlab.lib.pagesizes import letter
    from reportlab.pdfgen import canvas
    import time

    start_date = time.strftime('%d-%m-%Y %H:%M:%S')

    canvas = canvas.Canvas("form1.pdf", pagesize=letter)
    canvas.setLineWidth(1)
    canvas.setFont('Helvetica', 12)

    canvas.drawString(30, 750, 'DATE GENERATE')
    canvas.drawString(450, 750, start_date)
    canvas.line(440, 745, 570, 745)
    # canvas.line(420, 730, 600, 730)

    canvas.drawString(30, 730, 'REPORT TOPIC')
    canvas.drawString(450, 730, 'PROBES')
    canvas.line(440, 725, 570, 725)
    # canvas.line(480, 747, 580, 747)
    #
    # canvas.drawString(275, 725, 'AMOUNT OWED:')
    # canvas.drawString(500, 725, "$1,000.00")
    # canvas.line(378, 723, 580, 723)
    #
    # canvas.drawString(30, 703, 'RECEIVED BY:')
    # canvas.line(120, 700, 580, 700)
    # canvas.drawString(120, 703, "JOHN DOE")

    canvas.save()
Exemple #8
0
    def myPage(canvas, doc):
        canvas.saveState()  # save the current state
        canvas.setFont('InconsolataBold', 16)  # set the font for the name
        canvas.drawString(
            .4 * inch,
            HEIGHT - (.4 * inch),
            contact['name'])  # draw the name on top left page 1
        canvas.setFont('Inconsolata', 8)  # sets the font for contact
        canvas.drawRightString(
            WIDTH - (.4 * inch),
            HEIGHT - (.4 * inch),
            contact['website'])  
        canvas.line(.4 * inch, HEIGHT - (.47 * inch), 
            WIDTH - (.4 * inch), HEIGHT - (.47 * inch))
        canvas.drawString(
            .4 * inch,
            HEIGHT - (.6 * inch),
            contact['phone'])
        canvas.drawCentredString(
			WIDTH / 2.0,
			HEIGHT - (.6 * inch),
			contact['address'])
        canvas.drawRightString(
			WIDTH - (.4 * inch),
			HEIGHT - (.6 * inch),
			contact['email'])
        # restore the state to what it was when saved
        canvas.restoreState()
Exemple #9
0
 def addPageNumber(self, canvas, doc):
     self.pageNum = canvas.getPageNumber()
     text = "Page %s" % str(self.pageNum + 2)
     topTitle = self.topTitle.split(", ")
     topTitle = topTitle[len(topTitle) - 1]
     PresidenNameOccurs = False
     canvas.setLineWidth(3)
     text2 = ""
     topTitle2 = ""
     for item in self.articleNum:
         if item["pNum"] == self.pageNum:
             if item["name"] == "For the European Parliament":
                 topTitle = ""
                 PresidenNameOccurs = True
             else:
                 topTitle2 += ", " + item["name"] if topTitle2 else item[
                     "name"]
     canvas.setFont("Helvetica-Bold", 9)
     if self.pageNum % 2 == 0:
         canvas.drawString(0.5 * inch, 8.6 * inch, topTitle2 or topTitle)
     else:
         canvas.drawRightString(5.5 * inch, 8.6 * inch, topTitle2
                                or topTitle)
     canvas.setFont("Helvetica-Bold", 10)
     canvas.drawRightString(1 * inch, 8.4 * inch, "English")
     canvas.drawRightString(5.5 * inch, 8.4 * inch, self.lang)
     canvas.line(0.5 * inch, 8.3 * inch, 5.5 * inch, 8.3 * inch)
     canvas.setFont("Helvetica", 10)
     canvas.drawRightString(5.5 * inch, 0.3 * inch, text)
     canvas.line(0.5 * inch, 0.5 * inch, 5.5 * inch, 0.5 * inch)
     self.topTitle = "" if PresidenNameOccurs == True else (topTitle2
                                                            or topTitle)
Exemple #10
0
 def render(self, canvas):
     if self.dashed:
         canvas.setDash(1, 2)
     else:
         canvas.setDash([], 0)
     canvas.line(self.coords[0], self.coords[1], self.coords[2],
                 self.coords[3])
Exemple #11
0
def judging_divisional_body(canvas):
    criteria = ["Precision", "Originality", "Creativity", "Skill", "Color", "Design", "Difficulty", "Number of Techniques", "Overall Eye Appeal"]

    # Table header
    canvas.drawString(3.30 * inch, 8.375 * inch, "    Needs")
    canvas.drawString(3.30 * inch, 8.125 * inch, "Improvement")
    canvas.drawString(4.85 * inch, 8.25 * inch, "Fair")
    canvas.drawString(5.750 * inch, 8.25 * inch, "Good")
    canvas.drawString(6.750 * inch, 8.25 * inch, "Excellent")

    # Display column of criteria
    offset = 7.75
    for criterium in criteria:
        canvas.drawString(1.125 * inch, offset * inch, criterium)
        offset -= 0.375

    # Build up rows
    rows = []
    offset = 8.00
    for criterium in criteria:
        rows.append(offset * inch)
        offset -= 0.375
    rows.append(offset * inch)

    # Draw grid
    canvas.grid([inch, 3.25 * inch, 4.50 * inch, 5.50 * inch, 6.50 * inch, 7.75 * inch], rows)

    # Display comments section
    offset -= 0.5
    canvas.drawString(inch, offset * inch, "Comments: ")
    canvas.line(2.25 * inch, offset * inch, 7.5 * inch, offset * inch)

    while (offset > 1.5):
        offset -= 0.5
        canvas.line(1 * inch, offset * inch, 7.5 * inch, offset * inch)
Exemple #12
0
    def get(self, request):
        tables = Table.objects.filter(user=request.user)
        context = {
            'tables': tables,
        }
        from reportlab.lib.pagesizes import letter
        from reportlab.pdfgen import canvas
        from datetime import date
        import random

        today = date.today().strftime("%d/%m/%Y")

        canvas = canvas.Canvas("/tmp/form.pdf", pagesize=letter)
        canvas.setLineWidth(.3)
        canvas.setFont('Helvetica', 12)

        canvas.drawString(30, 750, 'REGALOS S.A de CV')
        canvas.drawString(30, 735, 'FACTURA #%s' % random.randint(1, 1000))
        canvas.drawString(500, 750, today)
        canvas.line(480, 747, 580, 747)

        canvas.drawString(30, 703, 'RFC de REGALOS S.A de CV:')
        canvas.drawString(230, 703, "SAVR090503795")

        canvas.drawString(30, 683, 'Direccion de REGALOS S.A de CV:')
        canvas.drawString(
            230, 683,
            "AV JUAREZ NO. 907, PERIODISTAS, 42000, Pachuca, HIDALGO")

        canvas.drawString(30, 643, 'Nombre:')
        canvas.drawString(230, 643, "Mauricio Mejia")

        canvas.drawString(30, 623, 'RFC:')
        canvas.drawString(230, 623, "MERM971214HDFJMKR07")

        canvas.drawString(30, 603, 'Direcciom:')
        canvas.drawString(230, 603, "Calle 28 133 Progreso Nacional")

        canvas.drawString(30, 583, 'Importe:')
        canvas.drawString(230, 583, "20")

        canvas.drawString(30, 563, 'IVA:')
        canvas.drawString(230, 563, "20")

        canvas.drawString(30, 543, 'TOTAL:')
        canvas.drawString(230, 543, "20")

        canvas.save()

        email = EmailMessage()
        email.subject = "New shirt submitted"
        email.body = "Tu factura esta lista"
        email.from_email = "*****@*****.**"
        email.to = [
            "*****@*****.**",
        ]
        email.attach_file("/tmp/form.pdf")  # Attach a file directly
        email.send()

        return TemplateResponse(request, 'users/profile.html', context)
Exemple #13
0
def pdf():
    try:
        path = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                            'form.pdf')
        os.remove(path)
    except FileNotFoundError:
        pass
    now = datetime.datetime.now()
    from reportlab.pdfgen import canvas
    canvas = canvas.Canvas("form.pdf", pagesize=letter)
    canvas.setLineWidth(.3)
    canvas.setFont('Helvetica', 12)
    canvas.drawString(450, 50, 'CREATED BY SOLARIS')
    canvas.drawString(
        500, 750, "{day}/{month}/{year}".format(day=now.day,
                                                month=now.month,
                                                year=now.year))
    canvas.line(480, 747, 580, 747)
    canvas.setFont('Helvetica', 18)
    canvas.drawString(225, 725, 'Performance metric')
    canvas.setFont('Helvetica', 12)
    canvas.drawString(50, 670, 'Information:')
    canvas.setFont('Helvetica', 11)
    canvas.drawString(70, 630, '- This data is based on Solaris algorithm')
    canvas.drawString(70, 600, '- Frequency - 1 FPS')
    canvas.drawInlineImage('dio.png', 80, 250, height=270, width=480)
    canvas.save()
    return None
Exemple #14
0
def cutmark(canvas,x,y,xpol,ypol):
    v('------')
    cutlen = 10
    canvas.line(x, y, x+cutlen*xpol, y)
    v('cutmark() x,y,xe,ye %f %f %f %f' % (x, y, x+cutlen*xpol, y))
    canvas.line(x, y, x        , y+cutlen*ypol)
    v('cutmark() x,y,xe,ye %f %f %f %f' % (x, y, x        , y+cutlen*ypol))
Exemple #15
0
 def drawBounds(self, canvas):
     """Guidelines to help me draw - not needed in production"""
     canvas.setStrokeColor(colors.red)
     canvas.rect(-100,-70,200,140)
     canvas.line(-100,0,100,0)
     canvas.line(0,70,0,-70)
     canvas.setStrokeColor(colors.black)
def pdf(name, adult, children, total, date_time, counter):
    from reportlab.pdfgen import canvas
    canvas = canvas.Canvas("static/website/pdf/print.pdf", pagesize=(300, 360))
    canvas.setLineWidth(.3)
    canvas.setFont('Helvetica', 19)
    canvas.drawInlineImage("static/website/images/butterfly.jpeg",
                           82,
                           303,
                           width=46,
                           height=46)
    canvas.drawString(138, 340, 'The')
    canvas.drawString(138, 322, 'Butterfly')
    canvas.drawString(138, 300, 'Corner')
    canvas.setFont('Helvetica', 14)
    canvas.drawString(220, 300, 'Sr. No : ' + str(counter))
    canvas.line(10, 291, 290, 291)
    canvas.drawInlineImage("qrcodes/qrcode.png",
                           72,
                           131,
                           width=155,
                           height=155)
    canvas.line(10, 124, 290, 124)
    canvas.setFont('Helvetica', 16)
    canvas.drawString(20, 100, 'Total : ' + total + ' THB')

    canvas.setFont('Helvetica', 14)
    canvas.drawString(20, 80, 'Date & Time : ' + date_time)
    canvas.drawString(20, 60, 'Name : ' + name)
    canvas.drawString(20, 40, 'Adult : ' + adult)
    canvas.drawString(170, 40, 'Children : ' + children)
    canvas.save()
    def header(self, canvas, doc, growing_year, cur_date):
        """Create the header of the document

        Parameters
        ----------
        canvas
        doc
        growing_year: int
        cur_date: str, with the current date

        """
        canvas.saveState()
        canvas.drawString(30, 750, self.tr('Simple report from GeoDataFarm'))
        canvas.drawString(
            30, 733,
            self.tr('For the growing season of ') + str(growing_year))
        canvas.drawImage(self.plugin_dir + '\\img\\icon.png',
                         500,
                         765,
                         width=50,
                         height=50)
        canvas.drawString(500, 750, 'Generated:')
        canvas.drawString(500, 733, cur_date)
        canvas.line(30, 723, 580, 723)
        #w, h = content.wrap(doc.width, doc.topMargin)
        #content.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - h)
        canvas.restoreState()
def drawOneCircle(canvas, circle_data):
	theta = float(0)
	(x_last, y_last) = circle_data.points
	radius = circle_data.radius
	index = circle_data.index
	last_cycle = circle_data.end
	rad_calculation = radius

	while theta < math.pi*2:
		if not last_cycle:
			rad_calculation = radius
		if index != -1.0:
			index += index_increments
		x_val = 6*scale_num+rad_calculation*math.cos(theta)
		y_val = 6*scale_num-rad_calculation*math.sin(theta)

		if ((x_last - x_val)**2 +(y_last-y_val)**2)>min_distance**2:
			if (x_last != 0.0 and y_last != 0.0) and (x_val != 0.0 and y_val != 0.0):
				canvas.line(x_last, y_last, x_val, y_val)
			x_last = x_val
			y_last = y_val

		if not last_cycle:
			radius -= rad_increments
		theta += theta_increments

	if index == -1.0:
		index = 0.0
	circle_data.points = (x_last, y_last)
	circle_data.radius = radius
	circle_data.index = index

	return circle_data
Exemple #19
0
def encabezado(canvas, doc):
    canvas.saveState()
    canvas.setFont('Times-Roman', 9)
    canvas.drawImage(this_path + '/static/images/aok/logo.png',
                     inch,
                     A4[1] - 90,
                     55,
                     60,
                     mask='auto')  # imagen logo
    canvas.setStrokeColorRGB(121 / 256, 128 / 256,
                             129 / 256)  # choose your line color
    canvas.line(133, A4[1] - 90, 133, A4[1] - 45)  # linea
    canvas.setFont('Helvetica', 12)
    canvas.setFillGray(0.3)
    canvas.drawString(140, A4[1] - 64, 'Universidad')
    canvas.setFont('Helvetica-Bold', 14)
    canvas.drawString(140, A4[1] - 79, 'Técnica Estatal de Quevedo')
    canvas.setFont('Helvetica-Bold', 8)
    canvas.drawString(140, A4[1] - 90,
                      'La primera Universidad Agropecuaria del País')
    canvas.setFillColorRGB(250 / 256, 210 / 256, 1 / 256)
    canvas.setStrokeColorRGB(250 / 256, 210 / 256, 1 / 256)
    canvas.rect(50, 742, 500, 3, fill=1)
    canvas.setFillColorRGB(76 / 256, 145 / 256, 65 / 256)
    canvas.setStrokeColorRGB(76 / 256, 145 / 256, 65 / 256)
    canvas.rect(50, 742, 500, 1, fill=1)
    canvas.restoreState()
Exemple #20
0
        def prepare_first_page(canvas, document):
            p1 = Paragraph(presentation.title, styles['Heading'])
            p2 = Paragraph(
                presentation.owner.get_full_name(), styles['SubHeading'])
            avail_width = width - inch
            avail_height = height - inch
            w1, h1 = p1.wrap(avail_width, avail_height)
            w2, h2 = p2.wrap(avail_width, avail_height)
            f = Frame(
                inch / 2,
                inch / 2,
                width - inch,
                height - inch,
                leftPadding=0,
                bottomPadding=0,
                rightPadding=0,
                topPadding=0
            )
            f.addFromList([p1, p2], canvas)

            document.pageTemplate.frames[0].height -= h1 + h2 + inch / 2
            document.pageTemplate.frames[1].height -= h1 + h2 + inch / 2

            canvas.saveState()
            canvas.setStrokeColorRGB(0, 0, 0)
            canvas.line(
                width / 2, inch / 2, width / 2, height - inch - h1 - h2)
            canvas.restoreState()
Exemple #21
0
    def header_footer(canvas, doc, content):
        styles = getSampleStyleSheet()
        styleN = styles['Normal']
        styleH = styles['Heading1']

        canvas.saveState()
        reporttitle = Paragraph(content[1], styleH)
        w, h = content[0].wrap(0.5 * inch, 0.5 * inch)  #doc.width
        w1, h1 = reporttitle.wrap(5 * inch, doc.topMargin)  #doc.width
        content[0].drawOn(canvas, doc.leftMargin,
                          doc.height + doc.topMargin - h)
        reporttitle.drawOn(canvas, doc.leftMargin + 1.5 * inch,
                           doc.height + doc.topMargin - h1)
        canvas.setLineWidth(0.5)
        canvas.line(doc.leftMargin, doc.height - 0.25 * inch,
                    doc.width + doc.leftMargin, doc.height - 0.25 * inch)

        canvas.line(doc.leftMargin, 0.75 * inch, doc.width + doc.leftMargin,
                    0.75 * inch)
        reporttitleBottom = Paragraph(content[1], styleN)
        w2, h2 = reporttitleBottom.wrap(3 * inch, 0.5 * inch)
        reporttitleBottom.drawOn(canvas, doc.leftMargin, 0.5 * inch)

        datestamp = Paragraph("Printed on " + time.strftime("%x"), styleN)
        w3, h3 = datestamp.wrap(2 * inch, 0.5 * inch)
        datestamp.drawOn(canvas, doc.width - 1 * inch, 0.5 * inch)

        canvas.restoreState()
 def draw_right_image(self,
                      canvas,
                      url,
                      x,
                      y,
                      w,
                      h,
                      x_padding=0,
                      y_padding=0,
                      title=''):
     try:
         canvas.drawImage(url,
                          x + x_padding,
                          y - h - y_padding,
                          w,
                          h,
                          preserveAspectRatio=True)
     except:
         canvas.roundRect(x + x_padding,
                          y - y_padding - h,
                          w,
                          h,
                          0,
                          stroke=1,
                          fill=0)
         canvas.line(x + x_padding, y - y_padding + h - h,
                     x + x_padding + w, y - y_padding - h)
         canvas.line(x + x_padding, y - y_padding - h, x + x_padding + w,
                     y - y_padding + h - h)
Exemple #23
0
        def prepare_first_page(canvas, document):
            p1 = Paragraph(presentation.title, styles['Heading'])
            p2 = Paragraph(presentation.owner.get_full_name(),
                           styles['SubHeading'])
            avail_width = width - inch
            avail_height = height - inch
            w1, h1 = p1.wrap(avail_width, avail_height)
            w2, h2 = p2.wrap(avail_width, avail_height)
            f = Frame(inch / 2,
                      inch / 2,
                      width - inch,
                      height - inch,
                      leftPadding=0,
                      bottomPadding=0,
                      rightPadding=0,
                      topPadding=0)
            f.addFromList([p1, p2], canvas)

            document.pageTemplate.frames[0].height -= h1 + h2 + inch / 2
            document.pageTemplate.frames[1].height -= h1 + h2 + inch / 2

            canvas.saveState()
            canvas.setStrokeColorRGB(0, 0, 0)
            canvas.line(width / 2, inch / 2, width / 2,
                        height - inch - h1 - h2)
            canvas.restoreState()
Exemple #24
0
def header(canvas):
    """ draws the header part of the document for every page"""
    canvas.setFont('pala', 9)

    # 1point = 1/72 inch , 40 points = 0.55 inch
    canvas.drawString(40, 720, 'PLATINUM FILINGS LLC')
    canvas.drawString(40, 708, '99 WEST HAWTHORNE AVENUE')
    canvas.drawString(40, 696, 'SUITE 408')
    canvas.drawString(40, 684, 'VALLLEY STREAM, NY 11580')

    canvas.setFont('Helvetica-Bold', 16)
    canvas.drawString(468, 741.6, 'Invoice')
    canvas.setFont('Helvetica', 10)
    #Dynamic line
    canvas.drawString(468, 725, 'Page 1 of 4')
    """Invoice date and number box"""
    canvas.setLineWidth(.3)
    canvas.rect(378, 648, 223, 36)
    #horizontal
    canvas.line(378, 671, 601, 671)
    #vertical
    canvas.line(464, 648, 464, 684)

    canvas.setFont('Helvetica', 9)
    canvas.drawString(385, 674, 'Invoice Date')
    canvas.drawString(470, 674, 'Invoice Number')

    #Dynamic Content
    canvas.setFont('pala', 9)
    canvas.drawString(385, 660, 'April 14, 2021')
    canvas.drawString(470, 660, '2020-5742')
Exemple #25
0
    def _header(canvas, doc):
        # Save the state of our canvas so we can draw on it
        canvas.saveState()
        styles = getSampleStyleSheet()

        # Header
        header1 = Paragraph('iVigilate', styles['Heading4'])
        header2 = Paragraph('www.ivigilate.com', styles['Heading4'])
        w, h = header1.wrap(doc.width, doc.topMargin)
        header1.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - h)
        w, h = header2.wrap(doc.width, doc.topMargin)
        header2.drawOn(canvas, doc.width - (2 * doc.leftMargin),
                       doc.height + doc.topMargin - h)

        canvas.line(doc.leftMargin, doc.height + doc.topMargin - h,
                    doc.leftMargin + w, doc.height + doc.topMargin - h)
        canvas.line(doc.leftMargin, doc.topMargin - h, doc.leftMargin + w,
                    doc.topMargin - h)

        # Footer
        # footer = Paragraph('www.ivigilate.com', styles['Heading5'])
        # w, h = footer.wrap(doc.width, doc.bottomMargin)
        # footer.drawOn(canvas, doc.leftMargin, doc.bottomMargin - h)

        # Release the canvas
        canvas.restoreState()
Exemple #26
0
    def draw(self):
        canvas = self.canv
        unitWidth = self.style.unitWidth * self.style.unit

        v_origin = self.height - self.beatsHeight
        h_offset = self.chartMargin

        h_loc = 0
        v_loc = 0

        maxWidth = self.widthInBeats

        for u in range(maxWidth + 1):
            y = v_origin
            x = u * unitWidth + h_offset
            if u % self.timeSignature == 0:
                l = self.beatsHeight
            else:
                l = self.beatsHeight / 2
            canvas.line(x, y, x, y + l)
            if u == maxWidth:  # Avoid writing beat number after the final line
                break
            writeText(canvas,
                      self.style,
                      str((u % self.timeSignature) + 1),
                      self.style.beatsFontSize,
                      v_origin + self.beatsHeight,
                      self.width,
                      hpos=x + unitWidth / 2)

        parsedBlockList = self.wrapBlocks(self.blockList, maxWidth)

        for b in parsedBlockList:
            if h_loc == maxWidth:
                v_loc += 1
                h_loc = 0
            canvas.rect(h_offset + h_loc * unitWidth,
                        v_origin - ((v_loc + 1) * self.unitHeight),
                        b.length * unitWidth, self.unitHeight)
            if b.notes is not None:
                writeText(canvas,
                          self.style,
                          b.notes,
                          self.style.notesFontSize,
                          v_origin - ((v_loc + 1) * self.unitHeight) +
                          (1.3 * self.style.notesFontSize),
                          self.width,
                          hpos=h_offset + ((h_loc + b.length / 2) * unitWidth))
            v_offset = ((v_loc * self.unitHeight) +
                        self.unitHeight / 2) - self.style.chordNameFontSize / 2
            if b.chord is not None:
                writeText(canvas,
                          self.style,
                          b.chord.name,
                          self.style.chordNameFontSize,
                          v_origin - v_offset,
                          self.width,
                          hpos=h_offset + ((h_loc + b.length / 2) * unitWidth))
            h_loc += b.length
Exemple #27
0
    def _header_footer(self, canvas, doc):
        # Save the state of our canvas so we can draw on it.
        canvas.saveState()
        styles = getSampleStyleSheet()
        styles.add(ParagraphStyle(name='centered', alignment=TA_CENTER))
        styles.add(ParagraphStyle(name='right', alignment=TA_RIGHT))

        try:
            specialize_prescription = NoPatientPrescription.objects.get(
                prescription_ptr=self.prescription)
        except:
            specialize_prescription = None

        if specialize_prescription is None:
            specialize_prescription = PatientPrescription.objects.get(
                prescription_ptr=self.prescription)
            patient_name = Paragraph(
                "Paciente: " + specialize_prescription.patient.name,
                styles['right'])
        else:
            patient_name = Paragraph(
                "Paciente: " + specialize_prescription.patient,
                styles['right'])

        w, h = patient_name.wrap(doc.width, doc.topMargin)

        medic_name = Paragraph(self.prescription.health_professional.name,
                               styles['centered'])
        w, h = medic_name.wrap(doc.width, doc.bottomMargin)

        specialty = self.prescription.health_professional.specialty_second

        if (specialty != 'Nao Possui'):
            specialty = self.prescription.health_professional.specialty_first + ' / ' + specialty
        else:
            specialty = self.prescription.health_professional.specialty_first

        medic_specialty = Paragraph(specialty, styles['centered'])
        w, h = medic_specialty.wrap(doc.width, doc.bottomMargin)

        medic_crm = Paragraph(
            self.prescription.health_professional.crm + ' / ' +
            self.prescription.health_professional.crm_state,
            styles['centered'])
        w, h = medic_crm.wrap(doc.width, doc.bottomMargin)

        # Footer.
        medic_name.drawOn(canvas, doc.leftMargin + 10, 60)
        medic_specialty.drawOn(canvas, doc.leftMargin + 10, 48)
        medic_crm.drawOn(canvas, doc.leftMargin + 10, 36)

        # Draw Lines.
        canvas.setLineWidth(0.5)
        canvas.line(66, 78, letter[0] - 66, 78)
        canvas.setLineWidth(.3)
        canvas.line(30, 750, 580, 750)

        # Release the canvas.
        canvas.restoreState()
    def beforeDrawPage(self, canvas, doc):
        if self.background != None:
            self.background.draw_on(canvas)

        (width, height) = canvas._pagesize
        canvas.setLineWidth(0.2 * cm)
        canvas.line(cm, height - (2*cm), width - cm, height - (2*cm))
        canvas.line(cm, (2*cm), width - cm, (2*cm))
def drawCrossHairs(canvas, x, y):
    """just a marker for checking text metrics - blue for fun"""

    canvas.saveState()
    canvas.setStrokeColorRGB(0, 1, 0)
    canvas.line(x - 6, y, x + 6, y)
    canvas.line(x, y - 6, x, y + 6)
    canvas.restoreState()
Exemple #30
0
 def later_header(self, canvas, doc):
     # Footer
     canvas.saveState()
     canvas.line(doc.leftMargin, 1 * cm, doc.width + doc.leftMargin, 1 * cm)
     footer = Paragraph(settings.PDF_FOOTER_TEXT, style_footer)
     w, h = footer.wrap(doc.width, doc.bottomMargin)
     footer.drawOn(canvas, doc.leftMargin, h)
     canvas.restoreState()
Exemple #31
0
def f(canvas, x, y, m):
    x_1 = x * x_scale + x_start
    x_2 = x_1 + x_scale
    
    y_1 = y * y_scale + y_start
    y_2 = y_1 + y_scale

    canvas.line(x_1, y_1, x_2, y_2)
def drawCrossHairs(canvas, x, y):
    """just a marker for checking text metrics - blue for fun"""

    canvas.saveState()
    canvas.setStrokeColorRGB(0, 1, 0)
    canvas.line(x - 6, y, x + 6, y)
    canvas.line(x, y - 6, x, y + 6)
    canvas.restoreState()
Exemple #33
0
    def _drawLifeline(self, canvas):

        for i in range(len(self.objectList)):
            topX = getLifelineX(len(self.objectList), i)
            topY = 50
            bottomX = topX
            bottomY = 750
            canvas.line(topX, topY, bottomX, bottomY) 
Exemple #34
0
def _draw_section_title(canvas, yc, title):
    title = title.upper()
    title_x = H_TEXT_MARGIN
    title_y = yc - SECTION_V_SPACE - SECTION_FONT_SIZE
    line_y = title_y - V_SEPARATOR
    canvas.setFont(SECTION_FONT, SECTION_FONT_SIZE)
    canvas.drawString(title_x, title_y, title)
    canvas.line(H_TEXT_MARGIN - H_LINE_MARGIN_OFFSET, line_y, RESUME_PAGE_SIZE[0] - (H_TEXT_MARGIN - H_LINE_MARGIN_OFFSET), line_y)
    return line_y# - V_SEPARATOR
Exemple #35
0
 def showscale(self, canvas):
     canvas.setFont(self.st_font, 5)
     canvas.setLineWidth(.1)
     for x in self.drange(0, 600, 10):
         canvas.line(x, 0, x, 10)
         canvas.drawString(x, 12, str(x))
     for y in self.drange(0, 840, 10):
         canvas.line(0, y, 10, y)
         canvas.drawString(12, y, str(y))
Exemple #36
0
def print_shoppinglist_header(canvas):
    line = HEIGHT - P_YMARGIN
    canvas.setLineWidth(H_LINEWIDTH)
    canvas.setFont(FONTTYPE, H_FONTSIZE)
    canvas.drawString(P_XOFFSET, line, "Thanks for choosing Cookyourself!")
    canvas.setLineWidth(P_LINEWIDTH)
    canvas.setFont(FONTTYPE, P_FONTSIZE)
    line -= PADDING
    canvas.line(L_XOFFSET, line, WIDTH - L_XOFFSET, line)
def draw_line_set(canvas, position, nib_width, partitions, pagesize):
    """Draws rulings for a single line of calligraphic text. Returns
    position of last line drawn"""
    offset = position
    canvas.line(1*mm, offset, pagesize[0], offset)
    for i in (float(x) for x in partitions.split(",")):
        offset += i * nib_width * mm
        canvas.line(1*mm, offset, pagesize[0], offset)
    return offset
Exemple #38
0
 def cabecera(self, canvas):
     origen = Frame(self.MARGEN, A4[1] - 1.5 * cm,
         A4[0] - (2 * self.MARGEN), 1 * cm,
         id='cabecera', showBoundary=self.mostrar)
     story = []
     story.append(Paragraph(self.header, self.estilos['cabecera']))
     origen.addFromList(story, canvas)
     canvas.line(x1=self.MARGEN, y1=A4[1] - 1.2 * cm,
         x2=A4[0] - (self.MARGEN), y2=A4[1] - 1.2 * cm)
Exemple #39
0
def rectInterna(canvas, x0, x1, y0, rows, altura_row, linewidth=0.5):
    canvas.setLineWidth(linewidth)
    # escalar x1 razon desconocida
    x1 *= 1.355
    # empezar en x0, y0 + altura row
    for row in range(1, rows):
        canvas.setLineWidth(linewidth * 2.3) if (row == 1) else canvas.setLineWidth(linewidth)
        # x0,y0,x1,y1
        canvas.line(x0, y0 + altura_row * row, x1, y0 + altura_row * row)
Exemple #40
0
def piePagina(canvas, doc):
	canvas.saveState()
	canvas.setFillColor('#666666')
	canvas.setFont('Helvetica', 8)
	canvas.setStrokeColor('#ABAAAB')
	canvas.line(A4[0] - 800, A4[1] - 818, A4[0] - 0, A4[1] - 818)
	canvas.drawString(275, A4[1] - 835, "Pag. %d" % doc.page)
	# canvas.drawString( 20,  A4[1]-835, 'Codigo: '+form['data']['header']['code'])
	canvas.restoreState()
Exemple #41
0
 def myLaterPages(canvas, doc):
     from reportlab.lib.colors import red
     PAGE_HEIGHT = canvas._pagesize[1]
     canvas.saveState()
     canvas.setStrokeColor(red)
     canvas.setLineWidth(5)
     canvas.line(66,72,66,PAGE_HEIGHT-72)
     canvas.setFont(_baseFontName,12)
     canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page)
     canvas.restoreState()
Exemple #42
0
 def myLaterPages(canvas, doc):
     from reportlab.lib.colors import red
     PAGE_HEIGHT = canvas._pagesize[1]
     canvas.saveState()
     canvas.setStrokeColor(red)
     canvas.setLineWidth(5)
     canvas.line(66,72,66,PAGE_HEIGHT-72)
     canvas.setFont('Times-Roman',12)
     canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % doc.page)
     canvas.restoreState()
def header(canvas, DOC, MAPHEADERTEXT):
    """Draws the page header"""
    arcpy.AddMessage("Drawing Header...")
    canvas.saveState()
    header_top_padding = 1 * cm
    logo_image_height = 50
    logo_header_gap = 0.75 * cm
    indent_right = 40
    docy = PAGE_HEIGHT - 60

    style_header = getSampleStyleSheet()
    style_header.add(
        ParagraphStyle(name='BodyT',
                       alignment=TA_LEFT,
                       borderPadding=(5, 10, 10),
                       fontName='Vera',
                       fontSize=14,
                       spaceAfter=6,
                       backColor=Color(0, 0.2627450980392157,
                                       0.42745098039215684, 1),
                       textColor=Color(1, 1, 1, 1)))
    para = Paragraph(MAPHEADERTEXT, style_header["BodyT"])

    logo_image_width, imageheight = ImageReader(IMAGE).getSize()

    aspect_ratio = imageheight / (float(logo_image_width))
    reduceby = 0.1

    while logo_image_height <= imageheight:
        logo_image_width = logo_image_width - reduceby
        imageheight = logo_image_width * aspect_ratio
        reduceby += 0.1

    para_width_total, para_height = para.wrap(
        DOC.width + 0.70 * inch - logo_image_width - logo_header_gap,
        DOC.topMargin + 0.5 * inch)

    logo_y = ((para_height + imageheight) / 2) + header_top_padding
    canvas.drawImage(ImageReader(IMAGE),
                     indent_right,
                     PAGE_HEIGHT - logo_y,
                     logo_image_width,
                     imageheight,
                     mask='auto')

    para_y = para_height + header_top_padding

    para.drawOn(canvas,
                (indent_right + 0.1 * cm + logo_image_width + logo_header_gap),
                (PAGE_HEIGHT - para_y))

    canvas.setLineWidth(1.0)
    canvas.setStrokeColor(Color(0, 0.2627450980392157, 0.42745098039215684, 1))
    canvas.line(indent_right, docy, (PAGE_WIDTH - indent_right), docy)
    canvas.restoreState()
Exemple #44
0
def draw_header(canvas):
    """ Draws the invoice header """
    canvas.setStrokeColorRGB(176/255., 196/255., 222/255.)
    # canvas.setStrokeColorRGB(0.9, 0.5, 0.2)
    canvas.setFillColorRGB(0.2, 0.2, 0.2)
    canvas.setFont('Helvetica', 16)
    canvas.drawString(18 * cm, -1 * cm, 'Invoice')
    if consultant_logo_filename:
        canvas.drawInlineImage(consultant_logo_filename, 1 * cm, -1 * cm, 250, 16)
    canvas.setLineWidth(4)
    canvas.line(0, -1.25 * cm, 21.7 * cm, -1.25 * cm)
Exemple #45
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)
Exemple #46
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)
Exemple #47
0
 def myFirstPage(canvas, doc):
     from reportlab.lib.colors import red
     PAGE_HEIGHT = canvas._pagesize[1]
     canvas.saveState()
     canvas.setStrokeColor(red)
     canvas.setLineWidth(5)
     canvas.line(66,72,66,PAGE_HEIGHT-72)
     canvas.setFont('Times-Bold',24)
     canvas.drawString(108, PAGE_HEIGHT-108, "TABLE OF CONTENTS DEMO")
     canvas.setFont('Times-Roman',12)
     canvas.drawString(4 * inch, 0.75 * inch, "First Page")
     canvas.restoreState()
    def draw(self):
        canvas = self.canv
        couleurDate = None
        positionSeparation = 20
        
        # Couleur de la case Date de la journée
        if AFFICHER_VACANCES == True and self.dateDD in LISTE_VACANCES : couleurDate = COULEUR_VACANCES
        if AFFICHER_WE == True and (self.dateDD.weekday() == 5 or self.dateDD.weekday() == 6) : couleurDate = COULEUR_WE
        if AFFICHER_FERIES == True and self.dateDD in LISTE_FERIES : couleurDate = COULEUR_FERIES
        
        if couleurDate != None :
            r, g, b = ConvertCouleur(couleurDate)
            canvas.setFillColorRGB(r, g, b)
            canvas.rect(0, 0, positionSeparation, self.hauteurCase, fill=1, stroke=False)
        
        # Texte date
        canvas.setFillColorRGB(0, 0, 0)
        canvas.setFont("Helvetica", 7)
        canvas.drawRightString(positionSeparation-2, 2, self.labelDate)
        
        # Trait séparation Date et Heures
        canvas.setLineWidth(0.25)
        canvas.line(positionSeparation, 0, positionSeparation, self.hauteurCase)
        
        # Si aucune présence ce jour -là
        if len(self.dictBarres) == 0 : return

        # Récup du nbre total d'heure de la journée
        totalJour = self.dictBarres["totalJour"]
        
        # Transformation du nombre d'heures par catégorie en pourcentage
        listeCategories = []
        for IDcategorie, nbreHeures in self.dictBarres.items():
            if IDcategorie != "totalJour" :
                largeurBarre = nbreHeures * 1.0 * (self.largeurCase-positionSeparation-0.25) / totalJour
                listeCategories.append( (largeurBarre, IDcategorie) )
        listeCategories.sort()
        
        # Création des graphes
        if AFFICHER_COULEUR_CATEGORIES == True :
            positionTemp = positionSeparation+0.25
            for largeurBarre, IDcategorie in listeCategories :
                r, g, b = ConvertCouleur(FormateCouleur(DICT_CATEGORIES[IDcategorie][2]))
                canvas.setFillColorRGB(r, g, b)
                canvas.rect(positionTemp, 0, largeurBarre, self.hauteurCase, fill=1, stroke=False)
                positionTemp += largeurBarre
        
        # Label Total Heure de la journée
        if AFFICHER_HEURES == True :
            canvas.setFillColorRGB(0, 0, 0)
            canvas.setFont("Helvetica", 7)
            canvas.drawRightString(self.largeurCase-2, 2, "%s" % minutesEnHeures(totalJour))
def framePage(canvas, doc):
    # canvas.drawImage("snkanim.gif", 36, 36)
    canvas.saveState()
    canvas.setStrokeColorRGB(1, 0, 0)
    canvas.setLineWidth(5)
    canvas.line(66, 72, 66, PAGE_HEIGHT - 72)

    canvas.setFont("Times-Italic", 12)
    canvas.drawRightString(523, PAGE_HEIGHT - 56, "Platypus User Guide and Test Script")

    canvas.setFont("Times-Roman", 12)
    canvas.drawString(4 * inch, 0.75 * inch, "Page %d" % canvas.getPageNumber())
    canvas.restoreState()
Exemple #50
0
def print_receipt(tot_price, trans_id, cashier_id, amount_paid, amount_rem):
	#global last_trans, canvas, base, values, currentprinter, canvas
	print str(tot_price)+' '+str(trans_id)+' '+str(cashier_id)+str(last_trans)
	#raw_input("Press Enter to continue...")
	canvas = canvas.Canvas("receipt.pdf", pagesize=letter)
	canvas.setLineWidth(.3)
	canvas.setFont('Helvetica', 12)

	canvas.drawString(30,750,'CASHIER ID: '+str(cashier_id))
	canvas.drawString(30,735,'TRANSACTION ID: '+str(trans_id))

	canvas.drawString(500,750,time.strftime("%d/%m/%Y"))
	canvas.line(480,747,580,747)
	 
	canvas.drawString(275,725,'TOTAL PRICE:')
	canvas.drawString(500,725,"$"+str(tot_price))
	canvas.line(378,723,580,723)
	 
	canvas.drawString(30,703,'PRODUCTS:')
	canvas.drawString(120,703,'<Barcode>')
	canvas.drawString(190,703,'<Quantity>')
	canvas.drawString(260,703,'<Price>')

	#items = ['10005058 2 24.00', '10005058 2 24.00']
	base = 683
	print last_trans
	for check in last_trans:
		values = check.split()
		print values
		#raw_input('print check')
		left= 120
		for value in values:
			canvas.drawString(left,base,str(value))
			left+=70
		base=base-30

	canvas.line(120,base,580,base)
	base-=30
	canvas.drawString(120,base,'AMOUNT PAID: $ %.2f'%amount_paid)
	canvas.line(120,base-10,580,base-10)
	base-=30
	canvas.drawString(120,base,'CHANGE: $ %.2f'%amount_rem)
	base-=30
	canvas.line(120,base-10,580,base-10)
	canvas.save()
	currentprinter = win32print.GetDefaultPrinter()
	if len(currentprinter):
		win32print.SetDefaultPrinter(currentprinter)
		win32api.ShellExecute(0, "print", 'receipt.pdf', None,  ".",  0)	
	threading.Timer(15, lambda: os.remove('receipt.pdf') ).start()
def mylaterpages(canvas, doc):
    canvas.saveState()
    canvas.line(0 * inch, 0.01 * inch, 11.69 * inch, 0.01 * inch)
    canvas.line(0 * inch, 0 * inch, 0 * inch, 8.24 * inch)
    canvas.line(11.69 * inch, 0 * inch, 11.69 * inch, 8.24 * inch)
    canvas.line(0 * inch, 8.24 * inch, 11.69 * inch, 8.24 * inch)
    canvas.restoreState()
def framePage(canvas, title):
    canvas.setFont("Times-BoldItalic", 20)
    canvas.drawString(inch, 10.5 * inch, title)

    canvas.setFont("Times-Roman", 10)
    canvas.drawCentredString(4.135 * inch, 0.75 * inch, "Page %d" % canvas.getPageNumber())

    # draw a border
    canvas.setStrokeColorRGB(1, 0, 0)
    canvas.setLineWidth(5)
    canvas.line(0.8 * inch, inch, 0.8 * inch, 10.75 * inch)
    # reset carefully afterwards
    canvas.setLineWidth(1)
    canvas.setStrokeColorRGB(0, 0, 0)
	def myFirstPage(self,canvas, doc):
		canvas.saveState()
		canvas.drawImage(STATICFILES_DIRS[0]+'escudo_transito.jpg',35, PAGE_HEIGHT-115)
		canvas.setLineWidth(1)
		canvas.line(10, 723, 600,723)
		canvas.setFont('Times-Roman',8)
		canvas.drawString(10,PAGE_HEIGHT-130, "MUNICIPIO DE LEON GUANAJUATO")
		canvas.drawString(10,PAGE_HEIGHT-142, "SECRETARIA DE SEGURIDAD PUBLICA")
		canvas.drawString(420,PAGE_HEIGHT-142, "INFORME DE CAPTURA DE INFRACCIONES")
		canvas.setFillColorRGB(1,0,0)
		canvas.setFontSize(18)
		canvas.setFontSize(10)
		canvas.setFillColorRGB(0,0,0)
		canvas.drawString(10,PAGE_HEIGHT-154, "DIRECCION GENERAL DE TRANSITO MUNICIPAL")
		
def myfirstpage(canvas, doc):
    canvas.saveState()
    canvas.line(0 * inch, 0.01 * inch, 11.69 * inch, 0.01 * inch)
    canvas.line(0 * inch, 0 * inch, 0 * inch, 8.24 * inch)
    canvas.line(11.69 * inch, 0 * inch, 11.69 * inch, 8.24 * inch)
    canvas.line(0 * inch, 8.23 * inch, 11.69 * inch, 8.23 * inch)
    canvas.setFont('Times-Bold', 16)
    canvas.restoreState()
def header(canvas, DOC, MAPHEADERTEXT):
    """Draws the page header"""
    arcpy.AddMessage("Drawing Header...")
    canvas.saveState()
    header_top_padding = 1*cm
    logo_image_height = 50
    logo_header_gap = 0.75*cm
    indent_right = 40
    docy = PAGE_HEIGHT-60

    style_header = getSampleStyleSheet()
    style_header.add(ParagraphStyle(name='BodyT', alignment=TA_LEFT,
                                    borderPadding=(5, 10, 10), fontName='Vera',
                                    fontSize=14, spaceAfter=6,
                                    backColor=Color(0, 0.2627450980392157,
                                                    0.42745098039215684, 1),
                                    textColor=Color(1, 1, 1, 1)))
    para = Paragraph(MAPHEADERTEXT, style_header["BodyT"])

    logo_image_width, imageheight = ImageReader(IMAGE).getSize()

    aspect_ratio = imageheight/(float(logo_image_width))
    reduceby = 0.1

    while logo_image_height <= imageheight:
        logo_image_width = logo_image_width - reduceby
        imageheight = logo_image_width*aspect_ratio
        reduceby += 0.1

    para_width_total, para_height = para.wrap(DOC.width + 0.70*inch
                                              - logo_image_width
                                              - logo_header_gap,
                                              DOC.topMargin + 0.5 *inch)

    logo_y = ((para_height + imageheight) / 2) + header_top_padding
    canvas.drawImage(ImageReader(IMAGE), indent_right, PAGE_HEIGHT-logo_y,
                     logo_image_width, imageheight, mask='auto')

    para_y = para_height + header_top_padding

    para.drawOn(canvas,
                (indent_right+ 0.1*cm + logo_image_width + logo_header_gap),
                (PAGE_HEIGHT - para_y))

    canvas.setLineWidth(1.0)
    canvas.setStrokeColor(Color(0, 0.2627450980392157, 0.42745098039215684, 1))
    canvas.line(indent_right, docy, (PAGE_WIDTH - indent_right), docy)
    canvas.restoreState()
Exemple #56
0
def write_header(canvas, x, y, ancho, alto):
    from django.conf import settings
    from reportlab.platypus import Paragraph
    from reportlab.lib.units import cm
    # header
    fecha = datetime.now().strftime("%d/%m/%y %H:%M")
    if settings.STATIC_ROOT:
        img_path = "%s/images/logo_conduct_header.png" % settings.STATIC_ROOT
    else:
        img_path = "%s%simages/logo_conduct_header.png" % (settings.BASE_DIR,settings.STATIC_URL)
    canvas.drawImage(img_path, x, y, 1.5*cm, 1.5*cm)
    canvas.line(x,y-0.1*cm,ancho,y-0.1*cm)
    parag = Paragraph( _("header_code"),parag_style())
    parag.wrapOn(canvas,ancho-x,500)
    parag.drawOn(canvas, x + 1.6*cm, y)
    canvas.drawString(ancho-3*cm, y, fecha)
def header(canvas, y):

    try:
        college = College.objects.latest('id')
    except:
        college = ''
    canvas.setFont("Helvetica", 35)  
    if college:
        canvas.setFont('Times-Roman',20)  
        canvas.drawCentredString(500, y+45, college.name) 
        canvas.setFont('Times-Roman',14)  
        canvas.drawCentredString(500, y+25, college.address) 
        canvas.drawCentredString(500, y+5, college.district+","+college.state+",PIN-"+college.PIN)           
        canvas.drawCentredString(500, y-15, "PH: "+college.contact)   
    canvas.line(50, y - 30, 950, y - 30)
    return canvas
Exemple #58
0
def pdf_draw_footer(canvas, country):
    width = canvas._pagesize[0]
    canvas.line(LEFT_COLUMN, 3.5*cm, width - LEFT_COLUMN, 3.5*cm)
    if country == 'DE':
        drawStrings(canvas, LEFT_COLUMN, 3*cm, 8,
                    u"Inhaber: Johann C. Rocholl",
                    u"PayPal: [email protected]")
        drawStrings(canvas, RIGHT_COLUMN, 3*cm, 8,
                    u"Konto: 3415213",
                    u"BLZ: 38070724")
    else:
        drawStrings(canvas, LEFT_COLUMN, 3*cm, 8,
                    u"Sole proprietor: Johann C. Rocholl",
                    u"PayPal: [email protected]")
        drawStrings(canvas, RIGHT_COLUMN, 3*cm, 8,
                    u"IBAN: DE63380707240341521300",
                    u"BIC / SWIFT: DEUTDEDBXXX")
Exemple #59
0
    def _header_footer(canvas, doc):
        # Save the state of our canvas so we can draw on it
        canvas.saveState()
        styles = getSampleStyleSheet()

        # Header
        ##header = Paragraph('This is a multi-line header.  It goes on every page.   ' * 5, styles['Normal'])
        ##w, h = header.wrap(doc.width, doc.topMargin)
        ##header.drawOn(canvas, doc.leftMargin, doc.height + doc.topMargin - h)

        # Footer
        canvas.line(doc.leftMargin,doc.bottomMargin,doc.leftMargin+doc.width,doc.bottomMargin)
        footer = Paragraph('QC Status Rapportage', styles['Italic'])
        w, h = footer.wrap(doc.width, doc.bottomMargin-5*mm)
        footer.drawOn(canvas, doc.leftMargin, doc.bottomMargin-5*mm)

        # Release the canvas
        canvas.restoreState()