Creating PDF-File with Button in Grid

Hello,

I want to create a PDF document, using the PHP Code of a Grid button.

I tried the following PHP-Code within a Button PHP Code in the grid:

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont(‘Arial’,‘B’,16);
$pdf->Cell(40,10,‘Hello World!’);
$pdf->Output();

Fatal error: Class ‘FPDF’ not found in C:Program Files (x86)NetMakev5wwwrootscriptcaseappSVSBgrid_blzgrid_blz.php on line 1521


sc_include_lib(“FPDF”);

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont(‘Arial’,‘B’,16);
$pdf->Cell(40,10,‘Hello World!’);
$pdf->Output();

Error
Cannot modify header information - headers already sent by (output started at C:Program Files (x86)NetMakev5wwwrootscriptcaseappSVSBgrid_blzgrid_blz.php:1512)
FPDF error: Some data has already been output to browser, can’t send PDF file2


How to do that …?

Best regards
Uwe Pfeiffer

Re: Creating PDF-File with Button in Grid

I had the same problem a while ago. Problem seems to be that before the Output() statement, some other output is send to the display. Is there an “echo” somewhere in your php code that is executed before the output() ?

If so, remove it.

Re: Creating PDF-File with Button in Grid

Hello,

it seems that this is not possible, because of the internal code of SC.
I now created a control to create pdf much more complex then SC does with PDF-Report.

Best regards
Uwe Pfeiffer

Re: Creating PDF-File with Button in Grid

you can find in help the change of fpdf method.
ex:
addPage become sc_pdf_add_page

regards