简体   繁体   中英

Save a pdf, png, jpeg from webpage

I am developing a website for a charity, in which a user gets a receipt generated after making a donation.

My client wants the user to be able save this receipt as an image or pdf.

I have tried many API's and plugins, and even had my server admin install phantom.js, but I am unfamiliar with phantom, and couldn't get it to work.

Any help would be greatly appreciated.

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();

You can use FPDF php library to achieve this . FPDF is a free , php class which provide high level function and support many features like :

  • Image Support(Jpeg,png)
  • Color
  • Links, Automatic page break and many more

click here for quick tutorial.

Demo Code

<?php
 require('fpdf.php');

 $pdf = new FPDF();
 $pdf->AddPage();
 $pdf->SetFont('Arial','B',16);
 $pdf->Cell(40,10,'Hello World!');
 $pdf->Output();
?>

Don't forget to include fpdf.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM