Hi, A try to write my first PDF report (the user fill a form, manager it, .... at the end another user print this order). All the test I read in this forum or in the documentation alwyas end with "Le fichier ne commence pas par '%PDF-' Local\EWH-3508-0 "
First test : from gluon.contrib.fpdf import FPDF def test(): pdf = FPDF() pdf.add_page() pdf.set_font('Arial', 'B', 16) pdf.cell(40,10,'Hello World') pdf.output('tuto1.pdf','F') return response.stream(open('tuto1.pdf')) ==> I get the message Second one : from gluon.contrib.fpdf import FPDF def test(): pdf = FPDF() pdf.add_page() pdf.set_font('Arial', 'B', 16) pdf.cell(40,10,'Hello World') response.headers['Content-Type'] = 'application/pdf' return XML(pdf.output('', 'S')) ==> I get the message I remark in the source code, that the "%PDF- + version" is written in the _enddoc function, called by the close. So I try to add "pdf.close()" ... ==> I also get the message. Other try : pdf = FPDF('P','mm','A4') # A4 Portrait en mm pdf.add_page() pdf.set_font('Arial', 'I', 14) pdf.cell(40, 10, "Hello, ExampleServer World") pdf.close() stuff = open("stuff.pdf", 'w') stuff.write(pdf.output('', 'S')) stuff.close() ==> I file is created, named stuff.pdf. When I try to open this file (with Windows Acrobat reader) => "Cette page contient une erreur" (This page contains an error). -- 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.