FPDF Help
Posted on
16th Feb 2014 07:03 pm by
admin
I've been playing with the FPDF module. I was building a form and rolling right along and then suddenly I started getting the "FPDF error: Some data has already been output, can't send PDF file" error when trying to view the page I'm building.
It had been working fine until I converted my structure data into an array for cleaner coding. I'd alresdy been using an array to draw my lines, so I knw that the use of an array isn't the issue in itself.
I know that this error has to do with headers, but I can't figure out where the issue is developing. How can I go about finding out where the issue is? When I first tested a sample FPFD script I got this error and discovered that I had inadvertently put a couple spaces in front of the <?PHP bracket. It worked fine after removing the spaces.
I experienced some issues with my editor between the time itwas working and when it wasn't. I'm wondering if it's possible that something got corrupted. The document outputs to file without issue - just having trouble displaying the document on the browser.
For what it's worth, here's my code:
Code:
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/fpdf/fpdf.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/pe_lib/pe.inc.php';
$pdf=new FPDF();
// front page
$pdf->AddPage();
//draw lines
$fp_lines = array();
$fp_lines = get_fplines();
for ($ctr=0;$ctr<=count($fp_lines);$ctr++ ){
$pdf->Line($fp_lines[$ctr]['x1'], $fp_lines[$ctr]['y1'], $fp_lines[$ctr]['x2'],$fp_lines[$ctr]['y2']);
}
//add boiler plate
$fp_bp=array();
$fp_bp = get_fpbp();
for ($ctr=0;$ctr<=count($fp_bp);$ctr++){
$pdf->SetFont($fp_bp[$ctr]['font'],$fp_bp[$ctr]['font_type'], $fp_bp[$ctr]['font_size']);
$pdf->SetXY($fp_bp[$ctr]['x'], $fp_bp[$ctr]['y']);
$pdf->Write(5,$fp_bp[$ctr]['text']);
}
$pdf->Output($_SERVER['DOCUMENT_ROOT']. '/pdf_docs/test2.pdf',"F");
$pdf->Output();
?>
No comments posted yet
Your Answer:
Login to answer
88
17
Other forums
Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing
Upload file and add HTML
Hey everyone,
I have a client has meeting agendas and minutes that should be posted online. I
unoconv doc convert to pdf code prob
PHP/5.3.1
Hi. I am trying to use this code to convert docs to .pdf utilizing unoconv. Howe
I would like "for" to wait 5 sec
I would like my 'for' loop to wait 5 sec before second iteration.
for ($i=0; $i<10
Where is my php.ini???
Hi
First off - apologies - i'm not a coder so this may sound very amateur.
I'm having
Loop column after 2 results
Hello All.
Here is what I have:
Client ID Company name Clien
gmmktime or mktime
I live in the UK, i am within the GMT (with daylight saving time ie 1 hour difrence between summer a
Help? Need help on project with templates involving mysql and php.
I'm having a hard time explaining what I want but basically here is what I have in place:
-Da
How to add an image/C++ OpenGL?
Hi,
I have been trying to look online for this and, so far, I haven't found anything usef
Adding to the next element in a multidimensional array
Hi, I'm trying to add a value to $node->field_spaces['nid'] where x is the next available spo