def render_claims_to_pdf(request, slug, claim_group, deferred_awards):
    """Currently hard-coded to print to Avery 22805 labels"""

    metrics = dict(
        page_width=(8.5 * inch),
        page_height=(11.0 * inch),

        top_margin=(0.5 * inch),
        left_margin=((25.0 / 32.0) * inch),

        qr_overlap=((1.0 / 32.0) * inch),
        padding=((1.0 / 16.0) * inch),

        horizontal_spacing=((5.0 / 16.0) * inch),
        vertical_spacing=((13.0 / 64.0) * inch),

        width=(1.5 * inch),
        height=(1.5 * inch),
    )

    debug = (request.GET.get('debug', False) is not False)

    pagesize = (metrics['page_width'], metrics['page_height'])
    cols = int((metrics['left_margin'] - metrics['page_width']) /
               (metrics['width'] + metrics['horizontal_spacing']))
    rows = int((metrics['page_height'] - metrics['top_margin']) /
               (metrics['height'] + metrics['vertical_spacing']))
    per_page = (cols * rows)
    label_ct = len(deferred_awards)
    page_ct = math.ceil(label_ct / per_page)

    pages = [deferred_awards[x:x + (per_page)]
             for x in range(0, label_ct, per_page)]

    response = HttpResponse(content_type='application/pdf; charset=utf-8')
    if not debug:
        # If debugging, don't force download.
        response['Content-Disposition'] = ('attachment; filename="%s-%s.pdf"' %
                (slug.encode('utf-8', 'replace'), claim_group))

    badge_img = None

    fout = StringIO()
    c = canvas.Canvas(fout, pagesize=pagesize)

    for page in pages:
        c.translate(metrics['left_margin'],
                    metrics['page_height'] - metrics['top_margin'])

        for row in range(0, rows, 1):
            c.translate(0.0, 0 - metrics['height'])
            c.saveState()

            for col in range(0, cols, 1):

                try:
                    da = page.pop(0)
                except IndexError:
                    continue

                if not badge_img:
                    image_fin = da.badge.image.file
                    image_fin.open()
                    badge_img = ImageReader(StringIO(image_fin.read()))

                c.saveState()
                render_label(request, c, metrics, da, badge_img, debug)
                c.restoreState()

                dx = (metrics['width'] + metrics['horizontal_spacing'])
                c.translate(dx, 0.0)

            c.restoreState()
            c.translate(0.0, 0 - metrics['vertical_spacing'])

        c.showPage()

    c.save()
    response.write(fout.getvalue())
    return response
dataset/ETHPy150Open mozilla/django-badger/badger/printing.py/render_claims_to_pdf/swapped operands of `-`