It should work unless there is something in the HTML markup messing with 
the output.  I tried this similar code with file output instead of stream 
and it did what you expected (as I understood it):

from gluon.contrib.pyfpdf import FPDF, HTMLMixin
from datetime import datetime

class MyFPDF(FPDF, HTMLMixin):
    def header(self):
        self.set_title("Analise de Valores")
        self.set_font('Arial', '', 15)
        self.cell(0, 10, "title", 0, 0, 'L')
        self.cell(0, 10, '%s VEICULOS' % "50", 0, 0, 'R')
        self.line(287, 18, 10, 18)

    def footer(self):
        self.set_y(-15)
        self.set_font('Arial', 'I', 8)
        txt = 'Folha %s de %s' % (self.page_no(), self.alias_nb_pages())
        self.cell(0, 10, txt, 0, 0, 'C')
        self.set_y(-15)
        self.set_font('Arial', 'I', 10)
        Useratual="auth.user"
        #Useratual = Useratual.first_name + ' ' + Useratual.last_name
        #Useratual = Useratual.decode("utf-8")
        data = datetime.now().strftime('%d/%m/%Y - %H:%M')
        self.cell(0, 20, 'Impresso por: %s (%s)' % (Useratual,"data"), 0, 0, 
'C')

pdf = MyFPDF('L')
pdf.add_page('L')
#pdf.write_html( str(XML(table, sanitize=True)).decode("utf-8"))

# First page
pdf.write_html('<h1>1st Page</h1>')
pdf.write_html('<font size="9"><table><tr><th width="50%">1</th><th 
width="50%">2</th></tr><tbody><tr><td width="50%">TEST 1</td><td 
width="50%">TEST 2</td></tr><tr><td width="50%">TEST 3</td><td>TEST 
4</td></tr></tbody><tfooter><tr><td width="50%">footer 1</td><td 
width="50%">footer 1</td></tr></tfooter></table></font>')

# Second page
pdf.add_page('L')
pdf.write_html('<h1>2nd Page</h1>')
pdf.write_html('<font size="15"><table><tr><th width="50%">10</th><th 
width="50%">20</th></tr><tbody><tr><td width="50%">TEST 5</td><td 
width="50%">TEST 6</td></tr><tr><td width="50%">TEST 7</td><td>TEST 
 8</td></tr></tbody><tfooter><tr><td width="50%">footer 2</td><td 
width="50%">footer 2</td></tr></tfooter></table></font>')

# Third page
pdf.add_page('L')
pdf.write_html('<font size="15"><h1>3rd Page</h1></font>')
pdf.write_html('<font size="15"><table><tr><th width="50%">100</th><th 
width="50%">200</th></tr><tbody><tr><td width="50%">TEST 9</td><td 
width="50%">TEST 10</td></tr><tr><td width="50%">TEST 11</td><td>TEST 
 12</td></tr></tbody><tfooter><tr><td width="50%">footer 3</td><td 
width="50%">footer 3</td></tr></tfooter></table></font>')
#response.headers['Content-Type'] = 'application/pdf'
pdf.output("multihtml.pdf", dest='F')

I attached the PDF output (multihtml.pdf). Compare with your table's HTML.


On Monday, January 2, 2017 at 9:53:24 PM UTC-4, Áureo Dias Neto wrote:
>
> Hello, it's basically this:
>
> i want another page with another content, in the same function or document 
> pdf
>
> from gluon.contrib.pyfpdf import FPDF, HTMLMixin
>
> class MyFPDF(FPDF, HTMLMixin):
> def header(self):
> self.set_title("Analise de Valores")
> self.set_font('Arial', '', 15)
> self.cell(0, 10, response.title, 0, 0, 'L')
> self.cell(0, 10, '%s VEICULOS' % registros, 0, 0, 'R')
> self.line(287, 18, 10, 18)
>
> def footer(self):
> self.set_y(-15)
> self.set_font('Arial', 'I', 8)
> txt = 'Folha %s de %s' % (self.page_no(), self.alias_nb_pages())
> self.cell(0, 10, txt, 0, 0, 'C')
> self.set_y(-15)
> self.set_font('Arial', 'I', 10)
> Useratual=auth.user
> Useratual = Useratual.first_name + ' ' + Useratual.last_name
> Useratual = Useratual.decode("utf-8")
> data = datetime.now().strftime('%d/%m/%Y - %H:%M')
> self.cell(0, 20, 'Impresso por: %s (%s)' % (Useratual,data), 0, 0, 'C')
>
> pdf = MyFPDF('L')
> pdf.add_page('L')
> #pdf.write_html( str(XML(table, sanitize=True)).decode("utf-8"))
> pdf.write_html('<font size="9">' + table.xml().decode('utf-8') + '</font>')
> pdf.add_page('L')
> pdf.write_html('<font size="15">' + tabela_totais.xml().decode('utf-8') + 
> '</font>')
> response.headers['Content-Type'] = 'application/pdf'
> return pdf.output(dest='S')
>
> 2017-01-02 21:20 GMT-02:00 Edwood <edwood...@gmail.com <javascript:>>:
>
>> Happy new year to you too!
>>
>> Can you post the code? It will be easier to understand the problem.
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: multihtml.pdf
Description: Adobe PDF document

Reply via email to