A SIMPLE REPORT
===============

This is just a simple report, that uses the Geraldo API to format a report with
the begin, summary, page header, page footer and detail bands.

    >>> import os
    >>> cur_dir = os.path.dirname(os.path.abspath(__file__))

    >>> from django.contrib.auth.models import Permission

    >>> from reportlab.lib.pagesizes import A4
    >>> from reportlab.lib.units import cm
    >>> from reportlab.lib.enums import TA_CENTER, TA_RIGHT
    
    >>> from geraldo import Report, ReportBand, Label, ObjectValue, SystemField,\
    ...     FIELD_ACTION_COUNT, BAND_WIDTH

Report class

    >>> class PermissionsReport(Report):
    ...     title = 'Permissions list'
    ... 
    ...     class band_begin(ReportBand):
    ...         height = 1*cm
    ...         elements = [
    ...             Label(text='Look those permissions please', top=0.1*cm,
    ...                 left=8*cm),
    ...         ]
    ... 
    ...     class band_summary(ReportBand):
    ...         height = 0.7*cm
    ...         elements = [
    ...             Label(text="That's all", top=0.1*cm, left=0),
    ...             ObjectValue(attribute_name='name', top=0.1*cm, left=3*cm,
    ...                 action=FIELD_ACTION_COUNT,
    ...                 display_format='%s permissions found'),
    ...         ]
    ...         borders = {'all': True}
    ... 
    ...     class band_page_header(ReportBand):
    ...         height = 1.3*cm
    ...         elements = [
    ...             SystemField(expression='%(report_title)s', top=0.1*cm,
    ...                 left=0, width=BAND_WIDTH, style={'fontName': 'Helvetica-Bold',
    ...                 'fontSize': 14, 'alignment': TA_CENTER}),
    ...             Label(text="ID", top=0.8*cm, left=0),
    ...             Label(text="Name", top=0.8*cm, left=3*cm),
    ...         ]
    ...         borders = {'bottom': True}
    ... 
    ...     class band_page_footer(ReportBand):
    ...         height = 0.5*cm
    ...         elements = [
    ...             Label(text='Created with Geraldo Reports', top=0.1*cm, left=0),
    ...             SystemField(expression='Page # %(page_number)d of %(page_count)d', top=0.1*cm,
    ...                 width=BAND_WIDTH, style={'alignment': TA_RIGHT}),
    ...         ]
    ...         borders = {'top': True}
    ... 
    ...     class band_detail(ReportBand):
    ...         height = 0.5*cm
    ...         elements = [
    ...             ObjectValue(attribute_name='id', top=0, left=0),
    ...             ObjectValue(attribute_name='name', top=0, left=3*cm, width=10*cm),
    ...         ]

    >>> report = PermissionsReport(queryset=Permission.objects.order_by('id'))

PDF generation

    >>> from geraldo.generators import PDFGenerator

    >>> report.generate_by(PDFGenerator, filename=os.path.join(cur_dir, 'output/simple-report.pdf'))

Text generation

    >>> from geraldo.generators import TextGenerator

    >>> report.generate_by(TextGenerator, filename=os.path.join(cur_dir, 'output/simple-report.txt'), to_printer=False, encode_to='latin-1')

Page with half height

    >>> report.page_size = (A4[0], A4[1] / 2)

    >>> report.generate_by(PDFGenerator, filename=os.path.join(cur_dir, 'output/simple-report-half-height.pdf'))

