Ejemplo n.º 1
0
def convert(filename):
    output_filename = os.path.splitext(filename)[0] + ".pdf"
    c = HTMLToPDFConverter()
    in_fp = open(filename, "r")
    b = c.convert(in_fp)
    with open(output_filename, "wb") as out_fp:
        out_fp.write(b)
Ejemplo n.º 2
0
def main():
    s = StringIO('<p>This document is in landscape.</p>')
    c = HTMLToPDFConverter()
    o = c.convert(s, orientation='landscape')

    output_filename = 'landscape.pdf'
    with open(output_filename, 'wb') as fp:
        fp.write(o)
    print('Wrote %d bytes to %s' % (len(o), output_filename))
Ejemplo n.º 3
0
def main():
    s = StringIO('<p>Hello there!</p><p><strong>How are you today?</strong></p>')

    c = HTMLToPDFConverter()
    o = c.convert(s, header='<p>Header</p>', footer='<p style="font-size: 8pt;">Footer</p>')

    output_filename = 'test_string.pdf'
    with open(output_filename, 'wb') as fp:
        fp.write(o)
    print('Wrote %d bytes to %s' % (len(o), output_filename))