Created
July 2, 2021 06:07
-
-
Save tango4567/d38b00cb3df97fbd0e5ebb455ccc049e to your computer and use it in GitHub Desktop.
Installtion Steps for mpdf in CodeIgnitor3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Installations steps for mPDF | |
1. Check PHp, Codeignioter and Composer Version | |
Php = 7.4.3 | |
CI3 = 3.1x | |
Composer = 2.1x | |
2. Install composer | |
composer require mpdf/mpdf | |
3. While installing mpdf you might get following error (Optional) | |
If you are getting any error related to "mikey179/vfsStream" which say capital letters not allowed | |
then you need to open composer.json file and find these line | |
"mikey179/vfsstream": "1.1.*", | |
and replace like this | |
vfsStream -> vfsstream | |
After this repeact step 2. | |
4. Implementation need to include complete path of autoloader in you controller | |
include('/var/www/html/ci3/vendor/autoload.php'); | |
Example: | |
public function downloadReceipt() | |
{ | |
try { | |
$mpdf = new \Mpdf\Mpdf(); | |
$data = file_get_contents('/var/www/html/ci3/application/views/demo.html'); // Pass file path | |
$mpdf->WriteHTML($data); | |
$mpdf->Output('download.pdf', 'D'); //For Download | |
$mpdf->Output(); //For Preview | |
} catch (\Mpdf\MpdfException $e) { | |
echo $e->getMessage(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment