Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I tried to store my pdf file inside the folder in database.but it works only MAMP server.My code is below:

$dompdf->load_html($html);
$dompdf->set_paper("A4", "landscape");
$dompdf->render();

 $dompdf->stream($projectdetail->project_name." - Cost Report.pdf", array("Attachment" => false));
 $canvas = $dompdf->get_canvas();
 $font = Font_Metrics::get_font("helvetica", "bold");
 $canvas->page_text(750, 570, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
 $canvas->page_text(25, 570, "II International P Ltd", $font, 6, array(0,0,0));
 $output = $dompdf->output();
 $file_to_save = '../files/'.$projectdetail->project_name.'/'.$projectdetail->project_name.'.pdf';
 file_put_contents($file_to_save, $output);

Can anyone help me?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
223 views
Welcome To Ask or Share your Answers For Others

1 Answer

Early in your code you call $dompdf->stream(). This method streams the PDF and halts execution of the script. I'm not sure why it's working on MAMP but not other servers, but if you re-arrange your script as such you should have more luck.

$dompdf->load_html($html);
$dompdf->set_paper("A4", "landscape");
$dompdf->render();

$canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "bold");
$canvas->page_text(750, 570, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 6, array(0,0,0));
$canvas->page_text(25, 570, "II International P Ltd", $font, 6, array(0,0,0));
$output = $dompdf->output();

$file_to_save = '../files/'.$projectdetail->project_name.'/'.$projectdetail->project_name.'.pdf';
file_put_contents($file_to_save, $output);

$dompdf->stream($projectdetail->project_name." - Cost Report.pdf", array("Attachment" => false));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...