Jump to content

Recommended Posts

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:


<?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();

?>

 

Link to comment
https://forums.phpfreaks.com/topic/180938-fpdf-help/
Share on other sites

Thanks waterssaz, that appears to have been the issue. Kiind of rough trying debug "emptiness", but it helps to know what to look for. I've had one other minor issue regarding viewing PDF files on the browser. As I'm plotting and checking, I go back and forth between my code and the browser. When I execute the page after it's been open and I've made an adjustment, I get a 404. Try again and the page appears.

 

I'm guessing it has something to do with needing to close or delete something after the page has been created. Should there be another command after my Output statements to clean up the object?

Link to comment
https://forums.phpfreaks.com/topic/180938-fpdf-help/#findComment-955013
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.