html2pdf cannot generate large files

40 Views Asked by At

I am using html2pdf with python and it works fine for me. The problem occurs when I need to create a PDF of more than 800 pages. MemoryError error appears and the file is never created. Do you know any way to solve this problem? Some alternative.

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta charset="UTF-8">
    <style type="text/css">
        @page {
            size: a4 portrait;
            @frame header_frame {           /* Static Frame */
                -pdf-frame-content: header_content;
                left: 50pt; width: 512pt; top: 30pt; height: 40pt;
            }
            @frame content_frame {          /* Content Frame */
                left: 50pt; width: 512pt; top: 90pt; height: 700pt;
            }
            @frame footer_frame {           /* Another static Frame */
                -pdf-frame-content: footer_content;
                left: 50pt; width: 512pt; top: 800pt; height: 20pt;
            }
        }
    </style>
</head>        
    <body>
        <div id="header_content">
            <table border="0">
                <tr>
                    <td style="border: 0px solid #000; width: 200px;"><img src="img\logo.jpg" width="100%"></td>
                    <td style="text-align: center; border: 0px solid #000; font-size: 15px;"><B>VALIDACION DE PROCESOS JUDICIALES - PROTOCOLO 2</B></td>
                </tr>
            </table>
            
        </div>

        <div id="footer_content">Pagina <pdf:pagenumber/> de <pdf:pagecount/>
        </div>

        <table border=0 cellspacing=0 style="border: 0px solid #000; width: 700px">

            {{ registros }} <-- HTMLCODE HERE


        </table>
    </body>
</html>
0

There are 0 best solutions below