Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pdfkit
- options = {
- 'page-size': 'Letter',
- 'margin-top': '1cm',
- 'margin-right': '1cm',
- 'margin-bottom': '1cm',
- 'margin-left': '1cm',
- '--footer-right': '[page]',
- }
- body = u"""
- <html>
- <head>
- <meta name="pdfkit-page-size" content="Letter"/>
- <meta name="pdfkit-orientation" content="Portrait"/>
- <meta charset="utf-8">
- <style>
- .td_left{
- text-align: left;
- }
- .td_rigth{
- text-align: right;
- }
- img{
- width: 150px;
- height: auto;
- position: absolute;
- top: 0;
- left: 0;
- }
- </style>
- </head>
- <body>
- <img src='/home/produccion/Downloads/logo.png'>
- <center>
- <h2><b>NOMBRE DE LA EMPRESA - NOMBRE DE LA SUCURSAL</b></h2>
- <h3><b>NIT: 000.000.000-0</b></h3>
- <h2><b>CONTABILIZACIÓN</b></h2>
- <center>
- <table>
- <thead>
- <th>CUENTA PUC</th>
- <th>BOD</th>
- <th class='td_left'>TERCERO</th>
- <th class='td_rigth'>DOC N°</th>
- <th class='td_rigth'>VENCE</th>
- <th class='td_rigth'>CANTIDAD</th>
- <th class='td_rigth'>DÉBITO</th>
- <th class='td_rigth'>CRÉDITO</th>
- </thead>
- <tbody>
- """
- for i in range(15):
- body += """<tr>
- <td>0000-00-000</td>
- <td>{0}</td>
- <td class='td_left'>NOMBRE DEL TERCERO</td>
- <td class='td_rigth'>AAA0000000001</td>
- <td class='td_rigth'>01/01/2000</td>
- <td class='td_rigth'>0.0</td>
- <td class='td_rigth'>00000000</td>
- <td class='td_rigth'>00000000</td>
- </tr>""".format(i+1)
- body += """</tbody>
- </table>
- </body>
- </html>"""
- pdfkit.from_string(body, 'ejemplo.pdf', options=options)
Add Comment
Please, Sign In to add comment