Exemple #1
0
    def write_pdf(self, canvas):
        canvas.setFont("Helvetica", 70)
        if self.show_title:
            canvas.drawString(70, 70, self.title)

        canvas.setFont("Helvetica", SUDOKU_FONT_SIZE)
        sudoku_offset = SUDOKU_PDF_OFFSET
        xlist = [sudoku_offset[0] + j *
                 (2 * SUDOKU_XPAD + SUDOKU_FONT_SIZE) for j in range(0, 9 + 1)]
        ylist = [sudoku_offset[1] + j *
                 (2 * SUDOKU_YPAD + SUDOKU_FONT_SIZE) for j in range(0, 9 + 1)]
        canvas.grid(xlist, ylist)
        for x in range(0, 9):
            for y in range(0, 9):
                if self.sudoku.mat[y][x] != UNKNOWN:
                    canvas.drawString(
                        sudoku_offset[0] +
                        (SUDOKU_FONT_SIZE + SUDOKU_XPAD) // 2 +
                        x * (2 * SUDOKU_XPAD + SUDOKU_FONT_SIZE) - 4,
                        sudoku_offset[1] + SUDOKU_FONT_SIZE +
                        y * (2 * SUDOKU_YPAD + SUDOKU_FONT_SIZE),
                        str(self.sudoku.mat[y][x])
                    )

        if self.show_page_number:
            canvas.setFont("Helvetica", 10)
            canvas.drawString(280, 800, str(self.page_number))

        # draw a cell
        canvas.setLineWidth(3)
        canvas.grid(xlist[::3], ylist[::3])
Exemple #2
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 #3
0
def firma_actasIntegrales(canvas, doc):
    ##########-------------------- Pie de Pagina del reporte ###########
    canvas.saveState()
    canvas.setStrokeColor(black)
    canvas.setFont("Helvetica-BoldOblique",6.5)
    canvas.drawString(2.7*inch, 2.37*cm, 'Firma y Sello Decanato')
    canvas.drawString(4.35*inch, 2.37*cm, 'Firma y Sello Coordinación')
    #canvas.drawString(9.3*cm, 2.37*cm, 'Profesor:')
    #canvas.drawString(15*cm, 2.37*cm, u'Cédula:')
    #canvas.drawString(11.3*cm, 1.0*cm, 'Firma')
    #canvas.drawString(15*cm, 1.0*cm, 'Fecha')
    canvas.grid([2.3*inch, 4.1*inch, 5.8*inch], [0.23*inch, 1.06*inch])
    canvas.restoreState()
Exemple #4
0
def firma_actasIntegrales(canvas, doc):
    ##########-------------------- Pie de Pagina del reporte ###########
    canvas.saveState()
    canvas.setStrokeColor(black)
    canvas.setFont("Helvetica-BoldOblique", 6.5)
    canvas.drawString(2.7 * inch, 2.37 * cm, 'Firma y Sello Decanato')
    canvas.drawString(4.35 * inch, 2.37 * cm, 'Firma y Sello Coordinación')
    #canvas.drawString(9.3*cm, 2.37*cm, 'Profesor:')
    #canvas.drawString(15*cm, 2.37*cm, u'Cédula:')
    #canvas.drawString(11.3*cm, 1.0*cm, 'Firma')
    #canvas.drawString(15*cm, 1.0*cm, 'Fecha')
    canvas.grid([2.3 * inch, 4.1 * inch, 5.8 * inch],
                [0.23 * inch, 1.06 * inch])
    canvas.restoreState()
def genSinglePageNameTag(canvas, data):
    print 'new page!'
    xcoords = [54, 306]
    ycoords = [76, 236, 396, 556]

    for x in xcoords:
        for y in ycoords:
            if data:
                datum = data.pop(0)
                genSingleNameTag(canvas, datum, x, y)
            else:
                break
    canvas.setStrokeColor(black)
    canvas.grid([54, 306, 558], [76, 236, 396, 556, 716])
Exemple #6
0
def variousshapes(canvas):
    from reportlab.lib.units import inch
    inch = int(inch)
    canvas.setStrokeGray(0.5)
    canvas.grid(range(0,int(11*inch/2),int(inch/2)), range(0,int(7*inch/2),int(inch/2)))

    rectangeHieght = .5
    # % Favorable
    favorableXposition = inch
    favorableYposition = inch
    favorableRectWidth = 1*inch

    # Favorable Rect
    canvas.setStrokeColor(green)
    canvas.setFillColor(green)
    canvas.rect(favorableXposition,favorableYposition,favorableRectWidth,rectangeHieght*favorableYposition, fill=1)

    # % Favorable Text
    canvas.setFillColor(black)
    canvas.drawString(favorableXposition+(favorableXposition/2.5),favorableYposition+(favorableYposition/5), "11")

    # % Neutral
    neutralXposition = 2*inch
    neutralYposition = 1*inch
    neutralRectWidth = 1*inch

    # Neutral Rect
    canvas.setStrokeColor(yellow)
    canvas.setFillColor(yellow)
    canvas.rect(neutralXposition,neutralYposition,neutralRectWidth,rectangeHieght*inch, fill=1)

    # % Neutral Text
    canvas.setFillColor(black)
    canvas.drawString(neutralXposition+(neutralXposition/2.5),neutralYposition+(neutralYposition/5), "22")

    # % Unfavorable
    unfavorableXposition = 3*inch
    unfavorableYposition = 1*inch
    unfavorableRectWidth = 1*inch

    # Unfavorable Rect
    canvas.setStrokeColor(red)
    canvas.setFillColor(red)
    canvas.rect(unfavorableXposition,unfavorableYposition,unfavorableRectWidth,rectangeHieght*inch, fill=1)

    # Unfavorable Text
    canvas.setFillColor(black)
    canvas.drawString(unfavorableXposition+(unfavorableXposition/2.5),unfavorableYposition+(unfavorableYposition/5), "33")
Exemple #7
0
def judging_tasting_body(canvas):
    criteria = ["Flavor", "Crumb", "Texture", "Density", "Appearance", "Theme"]
    maximum_points = [40, 10, 10, 10, 15, 15]

    # Table header
    canvas.drawString(5.85 * inch, 8.375 * inch, "Maximum")
    canvas.drawString(5.85 * inch, 8.125 * inch, "  Points")
    canvas.drawString(6.85 * inch, 8.375 * inch, "  Points")
    canvas.drawString(6.85 * inch, 8.125 * inch, "Awarded")

    # Display column of criteria
    offset = 7.75
    index = 0
    for criterium in criteria:
        canvas.drawString(1.125 * inch, offset * inch, criterium)
        canvas.drawString(6.125 * inch, offset * inch, str(maximum_points[index]))
        offset -= 0.375
        index += 1
    canvas.drawString(6.125 * inch, offset * inch, "Total:")

    # 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, 5.75 * inch, 6.75 * inch, 7.75 * inch], rows)
    canvas.grid([6.75 * inch, 7.75 * inch], [offset * inch, (offset - 0.375) * inch])
    offset -= 0.375

    # 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 #8
0
def judging_showcake_body(canvas):
    criteria = ["Application of Theme", "Precision of Techniques", "Originality & Creativity", "Appropriate Design (size, shape, colors, etc.)", "Difficulty of Techniques", "Number of Techniques Used", "Overall Eye Appeal (Judge's discretion)"]
    maximum_points = [15, 15, 15, 15, 15, 15, 10]

    # Table header
    canvas.drawString(5.85 * inch, 8.375 * inch, "Maximum")
    canvas.drawString(5.85 * inch, 8.125 * inch, "  Points")
    canvas.drawString(6.85 * inch, 8.375 * inch, "  Points")
    canvas.drawString(6.85 * inch, 8.125 * inch, "Awarded")

    # Display column of criteria
    offset = 7.75
    index = 0
    for criterium in criteria:
        canvas.drawString(1.125 * inch, offset * inch, criterium)
        canvas.drawString(6.125 * inch, offset * inch, str(maximum_points[index]))
        offset -= 0.375
        index += 1
    canvas.drawString(6.125 * inch, offset * inch, "Total:")

    # 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, 5.75 * inch, 6.75 * inch, 7.75 * inch], rows)
    canvas.grid([6.75 * inch, 7.75 * inch], [offset * inch, (offset - 0.375) * inch])
    offset -= 0.375

    # 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 #9
0
def generate_registration_and_release_form(canvas, signup, registrant, divisionals, tastings, showcases):
    year = int(signup.get('year'))
    sunday = get_show_end_date(year)
    if (sunday.find("March") < 0):
        sunday = "February " + sunday

    canvas.setFont("Helvetica-Bold", 20)
    canvas.drawString(inch, 10.50 * inch, str(year) + " Competition Registration and Release Form")
    canvas.setFont("Helvetica-Bold", 18)
    canvas.drawString(2.75 * inch, 10.00 * inch, "That Takes the Cake! " + str(year))
    canvas.setFont("Helvetica", 14)
    canvas.drawString(2.65 * inch, 9.75 * inch, "Cake & Sugar Art Show & Competition")
    canvas.drawString(2.90 * inch, 9.50 * inch, "Capital Confectioners, Austin, TX")

    canvas.setFont("Helvetica-Bold", 14)
    canvas.drawString(inch, 9.20 * inch, registrant.get('lastname') + ", " + registrant.get('firstname'))
    canvas.setFont("Helvetica", 14)
    if (registrant.get('address')):
        canvas.drawString(inch, 9.00 * inch, registrant.get('address'))
    if ((registrant.get('city')) and (registrant.get('state')) and (registrant.get('zipcode'))):
        canvas.drawString(inch, 8.80 * inch, registrant.get('city') + ", " + registrant.get('state') + " " + registrant.get('zipcode'))
    if (registrant.get('email')):
        canvas.drawString(inch, 8.60 * inch, registrant.get('email'))
    if (registrant.get('phone')):
        canvas.drawString(inch, 8.40 * inch, registrant.get('phone'))

    # Build up list of entry numbers by entry type
    entries = {}
    for entry in contestant.get('entries'):
        if (entries.get(entry['category']) is None):
            entries[entry['category']] = str(entry['id'])
        else:
            entries[entry['category']] += ", " + str(entry['id'])

    # Print Divisionals table
    canvas.setFont("Helvetica-Bold", 10)
    division = "Divisional Competition: "
    if (signup.get('class')):
        division += signup['class']
        if ((signup['class'] == 'Child') or (signup['class'] == 'Junior')):
            for entry in contestant.get('entries'):
                division += " : " + str(entry['id'])
    canvas.drawString(inch, 8.05 * inch, division)
    canvas.setFont("Helvetica", 10)
    offset = 7.85
    for division in divisionals:
        canvas.drawString(1.1 * inch, offset * inch, division)
        if (entries.get(division)):
            canvas.drawString(3.1 * inch, offset * inch, entries[division])
        offset -= 0.2

    # Build up rows
    rows = []
    offset = 8.0
    for division in divisionals:
        rows.append(offset * inch)
        offset -= 0.2
    rows.append(offset * inch)

    # Draw grid
    canvas.grid([inch, 3 * inch, 7.75 * inch], rows)

    # Print tastings table
    offset -= 0.4
    table_offset = offset
    canvas.setFont("Helvetica-Bold", 10)
    canvas.drawString(inch, offset * inch, "Tasting Competition: ")
    canvas.setFont("Helvetica", 10)
    offset -= 0.2
    for tasting in tastings:
        canvas.drawString(1.1 * inch, offset * inch, tasting)
        if (entries.get(tasting)):
            canvas.drawString(3.1 * inch, offset * inch, entries[tasting])
        offset -= 0.2

    # Build up rows
    rows = []
    offset = table_offset - 0.05
    for tasting in tastings:
        rows.append(offset * inch)
        offset -= 0.2
    rows.append(offset * inch)

    # Draw grid
    canvas.grid([inch, 3 * inch, 7.75 * inch], rows)

    # Print Showcakes table
    offset -= 0.4
    table_offset = offset
    canvas.setFont("Helvetica-Bold", 10)
    canvas.drawString(inch, offset * inch, "Showcake Competition: ")
    canvas.setFont("Helvetica", 10)
    offset -= 0.2
    for showcase in showcases:
        canvas.drawString(1.1 * inch, offset * inch, showcase)
        if (entries.get(showcase)):
            canvas.drawString(3.1 * inch, offset * inch, entries[showcase])
        offset -= 0.2

    # Build up rows
    rows = []
    offset = table_offset - 0.05
    for showcase in showcases:
        rows.append(offset * inch)
        offset -= 0.2
    rows.append(offset * inch)

    # Draw grid
    canvas.grid([inch, 3 * inch, 7.75 * inch], rows)

    canvas.setFont("Helvetica", 10)
    canvas.drawString(0.5 * inch, 3.10 * inch, "Release: By signing below, I understand that my entry(ies) may be photographed and published for the promotion of")
    canvas.drawString(0.5 * inch, 2.95 * inch, "Capital Confectioners, the Cake and Sugar Arts Show and general interest. I hereby agree to abide by the rules and ")
    canvas.drawString(0.5 * inch, 2.80 * inch, "regulations of the show. I understand that the Capital Confectioners Cake Club, Make It Sweet or any sponsors assume")
    canvas.drawString(0.5 * inch, 2.65 * inch, "no responsibility for loss, theft, or damage to displays or personal items at the Show. I agree to indemnify and hold")
    canvas.drawString(0.5 * inch, 2.50 * inch, "harmless the Capital Confectioners Cake Club, Make It Sweet, and all sponsors from and against all claims, demands,")
    canvas.drawString(0.5 * inch, 2.35 * inch, "costs, loss, damage, expense, attorney's fees and liabilities growing out of, or arising from, caused or occasioned by")
    canvas.drawString(0.5 * inch, 2.20 * inch, "my activities in the Capital Confectioners Cake and Sugar Art Show.")

    canvas.setFont("Helvetica-Bold", 10)
    canvas.drawString(0.5 * inch, 1.90 * inch, "I understand that I cannot remove my entry before 5 pm on Sunday, " + sunday + " and that entries left after 7 pm")
    canvas.drawString(0.5 * inch, 1.75 * inch, "become the property of Capital Confectioners.")

    canvas.drawString(0.5 * inch, 1.45 * inch, "I understand that any entries into the tasting competition become the property of Capital Confectioners and that")
    canvas.drawString(0.5 * inch, 1.3 * inch, "platters/plates or the remainder of the entry after judging will not be returned.")

    canvas.drawString(0.5 * inch, inch, "Signature:")
    canvas.line(1.4 * inch, inch, 5.65 * inch, inch)
    canvas.drawString(5.75 * inch, inch, "Date:")
    canvas.line(6.25 * inch, inch, 8 * inch, inch)
Exemple #10
0
def generatePage(words, canvas: canvas.Canvas, page: PageSettings, title):
    """
    :param words: matrix of words (rows * columns)
    :param canvas: PDF canvas
    :param meta: other information (e.g page title)
    :return:
    """

    if page.landscape:
        (marginR, marginT, marginL, marginB) = page.margins
        (height, width) = page.pagesize
        titleX = marginT
        titleY = width - marginR
    else:
        (marginT, marginL, marginB, marginR) = page.margins
        (width, height) = page.pagesize
        titleX = marginL
        titleY = height - marginT

    # if page.title:
    #     canvas.setFont("HatWordFont", page.titleFontSize)
    #     canvas.drawString(titleX + page.titleIndent, titleY - page.titleHeight / 2, title)

    if page.landscape:
        canvas.rotate(90)
        canvas.translate(0, -height)

    gwidth = width - marginL - marginR
    gheight = height - marginT - marginB

    goriginx = marginL
    goriginy = marginB

    # if page.title:
    #     if page.landscape:
    #         gwidth -= page.titleHeight
    #     else:
    #         gheight -= page.titleHeight

    if page.cutGrid:
        canvas.setStrokeColor(black)
        # Large bold rectangle

        canvas.setLineWidth(0.4 * mm)
        canvas.rect(goriginx, goriginy, gwidth, gheight)
        # outer cutting lines:
        canvas.setLineWidth(0.3 * mm)
        canvas.line(0, goriginy, width, goriginy)
        canvas.line(0, goriginy + gheight, width, goriginy + gheight)
        canvas.line(goriginx, 0, goriginx, height)
        canvas.line(goriginx + gwidth, 0, goriginx + gwidth, height)

    # grid
    cellWidth = gwidth / page.columns
    cellHeight = gheight / page.rows

    canvas.setLineWidth(0.2 * mm)

    canvas.grid([goriginx + i * cellWidth for i in range(page.columns + 1)],
                [goriginy + j * cellHeight for j in range(page.rows + 1)])

    # add words
    canvas.setFont("HatWordFont", page.fontSize)

    # As y starts at the end of the page, adjust for it and start from the top
    # (so that empty cells will placed be at bottom).
    yoffset = goriginy + cellHeight / 2 + cellHeight * (page.rows - 1)
    for row in words:
        xoffset = goriginx + cellWidth / 2
        for word in row:
            # scale down font size for long words
            numlines = word.count(";") + 1
            fontSize = page.fontSize
            while fontSize > 0 and max(
                    canvas.stringWidth(w, fontSize=fontSize) for w in
                    word.split(";")) >= cellWidth - 2 * page.wordMargin - 0.5:
                fontSize -= 1
            canvas.setFontSize(fontSize)
            # Somewhat cheap guess on string height : fontsize / 2
            yoff = yoffset + fontSize * numlines * 0.65 - fontSize / 2
            # print("99999999", word)
            flag = False
            for i in word.split(";"):
                print(i)
                if (flag):
                    yoff -= fontSize * 1.1
                if (i[:5] == "Место"):
                    flag = True
                else:
                    flag = False
                if (i == word.split(";")[0]):
                    canvas.setFont("HatWordFontBold", page.titleFontSize)
                    canvas.setFontSize(fontSize)
                    canvas.drawCentredString(xoffset, yoff, i)
                    yoff -= fontSize * 1.1
                else:
                    canvas.drawString(xoffset - cellWidth / 2 + 10, yoff, i)
                if (i == word.split(";")[0]):
                    canvas.setFont("HatWordFont", page.titleFontSize)
                    canvas.setFontSize(fontSize)
                yoff -= fontSize * 1.1
            xoffset += cellWidth
        yoffset -= cellHeight
canvas.setFont('Helvetica', 10)
canvas.drawString(51, 610, "Nº Factura")
canvas.drawString(223.4, 610, "Fecha")
canvas.drawString(395.8, 610, "C.I.F./D.N.I.")

#------------------- Rectangles Total Bill ------------------------
canvas.rect(50, 70, 147.4, 30)
canvas.rect(222.4, 70, 147.4, 30)
canvas.rect(394.8, 70, 147.4, 30)

canvas.drawString(52, 90, "Importe")
canvas.drawString(224.4, 90, "I.V.A.")
canvas.drawString(396.8, 90, "Total")

#------------------- Rectangles Way to pay ------------------------
canvas.rect(50, 30, 492.2, 30)
canvas.drawString(51, 50, "Forma de pago")
#------------------- Table Material Description -------------------
h = A4
x_list = [50, 120, 420, 480, 542.2]
y_list = [115, 565, 580]
canvas.grid(x_list, y_list)
canvas.drawString(64, 569, "Cantidad")
canvas.drawString(250, 569, "Concepto")
canvas.drawString(435, 569, "Precio")
canvas.drawString(493, 569, "Importe")

canvas.rotate(90)
canvas.drawString(119, -45, "Andy Murray 929292929W")
canvas.save()