'Produce a PDF representation of the grouped table
@param r: the S3Request
@return: the PDF document'

def pdf(self, r, filename=None):

    styles = {'tr.gi-column-totals': {'background-color': 'black', 'color': 'white'}, 'tr.gi-group-footer.gi-level-1': {'background-color': 'lightgrey'}, 'tr.gi-group-header.gi-level-1': {'background-color': 'lightgrey'}}
    title = self.title
    pdf_header = self.pdf_header
    if callable(pdf_header):
        pdf_header = (lambda r, title=title: self.pdf_header(r, title=title))
    pdf_footer = self.pdf_footer
    from s3.s3export import S3Exporter
    exporter = S3Exporter().pdf
    return exporter(self.resource, request=r, pdf_title=title, pdf_header=pdf_header, pdf_header_padding=12, pdf_footer=pdf_footer, pdf_callback=(lambda r: self.html()), pdf_table_autogrow='B', pdf_paper_alignment='Landscape', pdf_html_styles=styles, pdf_filename=filename)
