/    Sign up×
Community /Pin to ProfileBookmark

php pdf receipt genarate

I wanna generate pdf repoert usind fpdf.

I get this error.

FPDF error: Some data has already been output, can’t send PDF file. I cannot change the order of the coding.

[code=php]
<?php
require “Classes/receipt/receipt.php”;
?>
<p>test number</p>
<p>some texts BLlllllllllllllllllllll</p>
<?php
@$_SESSION[‘pay’] = “K.K.H Randeny”;
@$_SESSION[‘date’] = “12-Aug-2011”;
@$_SESSION[‘description’] = “Business Promortion”;
@$_SESSION[‘amount’] = “4,250.00”;

$print_receipt = new receipt_print();
$print_receipt->AddPage();
$print_receipt->Main_Body($_SESSION[‘pay’],$_SESSION[‘date’],$_SESSION[‘amount’]);
$print_receipt->Left_Body($_SESSION[‘pay’],$_SESSION[‘date’],$_SESSION[‘description’],$_SESSION[‘amount’]);
$print_receipt->Output();
?>[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@sodaauthorAug 31.2011 — Please somebody help

if i remove below part it works.

<p>test number</p>

<p>some texts BLlllllllllllllllllllll</p> [/QUOTE]
Copy linkTweet thisAlerts:
@ehimeAug 31.2011 — Try

[code=php]
<?php
require "Classes/receipt/receipt.php";

@$_SESSION['pay'] = "K.K.H Randeny";
@$_SESSION['date'] = "12-Aug-2011";
@$_SESSION['description'] = "Business Promortion";
@$_SESSION['amount'] = "4,250.00";

// I think this has something to do with your session data above?
$output = "<p>$testumber}</p>n";
foreach($texts as $text) { $output .= "<p>$text</p>n"; }

$print_receipt = new receipt_print();
$print_receipt->AddPage();
$print_receipt->Main_Body($_SESSION['pay'],$_SESSION['date'],$_SESSION['amount']);
$print_receipt->Left_Body($_SESSION['pay'],$_SESSION['date'],$_SESSION['description'],$_SESSION['amount']);
$output .= $print_receipt->Output();


?>[/code]
Copy linkTweet thisAlerts:
@aj_nscSep 01.2011 — The reason why it works is because the Output() method tries to send the PDF file to the browser, with headers. If you have given any output already (including whitespace, or in your case, HTML) then headers were already sent and cannot be sent again.
Copy linkTweet thisAlerts:
@sodaauthorSep 02.2011 — Still it didn't work. ;(

i wanna print the receipt when a button is clicked


[code=php]if(isset($_POST["update"]))
{

//add to cashbook
$msg = add_to_cashbook($_POST["cheque_no"],$_POST["payable_to"],$_POST["description"],$_POST["voucher_no"],$_POST["date"],$_POST["comments"],$_POST["total"],$_SESSION['location'],$_POST["account"]);

//update check no & voucher no
$update_cheque_and_voucher_no = update_cheque_and_voucher_no($_POST["cheque_no"],$_POST["voucher_no"],$_SESSION['location'],$_POST["account"]);

// receipt print
$print_receipt = new receipt_print();
$print_receipt->print_receipt();

}[/code]


and i wanna open pdf in a different window.

pls somebody help
×

Success!

Help @soda spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...