produce a pdf content based of a given rst content

    If filename is given, it will store the result using the given filename
    if no filename is given, it will generate a pdf in /tmp/ with a random
    name

def produce_pdf(rst_content=None, doctree_content=None, filename=None):
    """produce a pdf content based of a given rst content

    If filename is given, it will store the result using the given filename
    if no filename is given, it will generate a pdf in /tmp/ with a random
    name
    """
    if filename is None:
        filename = os.path.join(
            "/tmp", ''.join([random.choice(string.ascii_letters +
            string.digits) for n in range(15)]) + '.pdf')
    r2p = RstToPdf(stylesheets=['pdf.style'],
                   style_path=[os.path.join(os.path.dirname(__file__),
                                            'styles')],
                   breaklevel=0,
                   splittables=True,
                   footer="""###Title### - ###Page###/###Total###""")
    r2p.createPdf(text=rst_content,
                  doctree=doctree_content,
                  output=filename)
    return filename