php - PDF Creator Output Error -


i try build pdf creator dynamically pdf file errors when want output it. why errors when try output it? if delete $pdf->output(); no error's nothing shows of pdf.

error message:

fatal error: uncaught exception 'exception' message 'fpdf error: data has been output, can't send pdf file' in c:\xampp\htdocs\test\pdf_creator\fpdf.php:271 stack trace: #0 c:\xampp\htdocs\test\pdf_creator\fpdf.php(1063): fpdf->error('some data has a...') #1 c:\xampp\htdocs\test\pdf_creator\fpdf.php(999): fpdf->_checkoutput() #2 c:\xampp\htdocs\test\pages\rechnung_pdf.php(44): fpdf->output() #3 c:\xampp\htdocs\test\index.php(38): include('c:\xampp\htdocs\htdocs...') #4 {main} thrown in c:\xampp\htdocs\test\pdf_creator\fpdf.php on line 271

my code: ( whole file code how tried )

<?php require_once("pdf_creator/fpdf.php"); $pdf = new fpdf('p','mm','a4'); $pdf->addpage();  $pdf->setfont('arial','b', 16);   # kunden daten $pdf->setfont('arial','i', 13); $pdf->cell(0, 8, 'herr', 0, 1, 'l'); $pdf->cell(0, 8, utf8_decode('max'), 0, 1, 'l'); $pdf->cell(0, 8, utf8_decode('mustermann'), 0, 1, 'l');  # header rechnung $pdf->setfont('arial','i', 13); $pdf->cell(0, 10, utf8_decode('rechnungsdatum: xx.xx.xxxx'), 0, 1, 'r'); $pdf->cell(0, 10, utf8_decode('liefer- bzw. leistungsdatum: xx.xx.xxxx'), 0, 1, 'r'); $pdf->cell(0, 10, utf8_decode('steuernummer: xxx xxx xxx'), 0, 1, 'r');   # rechnung content $pdf->setfont('arial','b', 13); $pdf->cell(0, 20, utf8_decode('rechnung nr. xxxxxxxxxx'), 0, 1);  $pdf->setfont('arial','i', 13); $pdf->cell(0, 20, utf8_decode('wir bedanken uns für die gute zusammenarbeit und stellen ihnen'), 0, 1); $pdf->cell(0, 0, utf8_decode('vereinbarungsgemäß folgende lieferungen und leistungen in rechnung:'), 0, 1);  $pdf->cell(0, 20, '______________________________________________________________', 0, 1); $pdf->cell(0, -8, utf8_decode('nummer                    bezeichnung          menge      einzel/€      gesammt/€'), 0, 1); $pdf->cell(0, 13, '______________________________________________________________', 0, 1);  $pdf->cell(0, 60, '______________________________________________________________', 0, 1);  $pdf->setfont('arial', 'b', 13); $pdf->cell(0, -30, 'rechnungsbetrag: xx euro', 0, 1);  # footer nachricht $pdf->setfont('arial','i', 13); $pdf->cell(0, 80, utf8_decode('nach §19 abs. 1 ustg wird keine umsatzsteuer berechnet.'), 0, 1); $pdf->cell(0, -60, utf8_decode('die rechnung ist sofort fällig.'), 0, 1); $pdf->cell(0, 80, utf8_decode('wir bedanken uns für ihr vertrauen!'), 0, 1); $pdf->cell(0, -60, utf8_decode('für jegliche rückfragen stehen wir ihnen gerne zur verfügung.'), 0, 1); $pdf->output(); ?> 

i hope can me, read lot in documentation nothing helped me :/

let's sort things.

  1. the output() method of fpdf works if there absolutely no data sent browser before. no whitespace, no carriage return – nothing.

  2. but, there is output before call $pdf->output(). it's @ least 1 error message. fpdf class throws exception (as error message posted says):

    "#0 c:\xampp\htdocs\test\pdf_creator\fpdf.php(1063): fpdf->error('some data has a...')"

my guess euro sign. convert text data utf-8 iso-8859-1. due behavior of uft8_decode. unfortunately, iso-8859-1 charset not contain euro sign encoding.

try use iconv target encoding window-1252 instead of utf8_decode.

for debugging, try replace data ansi-text, remove transcoding @ , promise work.

best regards, andreas


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -