CodeIgniter - Plugin for DOMPDF
Posted by Mohammad Sajjad Hossain on June 21st, 2008
I have modified the plugin for DOMPDF which is found in CodeIgniter forum. I have added the paper size and orientation parameters. Here is the code to share with you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); function pdf_create($html, $filename, $stream=true, $papersize = 'letter', $orientation = 'portrait') { require_once("dompdf/dompdf_config.inc.php"); $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->set_paper($papersize, $orientation); $dompdf->render(); if ($stream) { $options['Attachment'] = 1; $options['Accept-Ranges'] = 0; $options['compress'] = 1; $dompdf->stream($filename.".pdf", $options); } else { write_file("$filename.pdf", $dompdf->output()); } } ?> |
June 22nd, 2008 at 2:30 pm
I also working on CodeIgniter. Hope your tips help me. Thanks for the sharing
Oh ya, Nice design of your site.
Keep in touch.
June 23rd, 2008 at 7:18 pm
Hello,
I’m using XAMPP too, but I wonder why I can’t run “Hello world” example of DOMpdf, it made my apache crashed many times :’(
I unzip dompdf-0.5.1.zip to htdocs, then just open a hello_world.php.
If you have any suggestion please help me
Thanks a lot
June 23rd, 2008 at 10:21 pm
DOMPDF by default uses PDFLib as back-end. If you do not want to use PDFLib then you may read this. The version of PDFLib with XAMPP (last checked with XAMPP 1.6.x) crashes Apache server. To resolve this issue do the following:
1. Downloaded the latest free version of PDFLib from http://www.pdflib.com.
2. Put the dll file in your PHP extension directory. (I assume it is C:\Program Files\xampp\php\ext\. To get the location of extension directory you may search in xampp/apache/bin/php.ini file or search in content generated by phpinfo()).
3. Open xampp/apache/bin/php.ini file and comment this line (put ‘;’ before this line):
extension=php_pdf.dll;
And add the following line after this line (Assuming the dll file name is lib_pdf.dll):
extension=lib_pdf.dll;
4. Restart Apache server and now see.
Hope this will solve your problem.
June 24th, 2008 at 9:13 am
hello,
I just did one step
Comment this line “extension=php_pdf.dll;”
And it works now ! Thanks so much
btw, do I need to use libpdf_php.dll ? What will be the difference if I don’t use it ?
June 24th, 2008 at 5:38 pm
Yaah! It worked because DOMPDF did not find the PDFLib because of commenting the line. So, it moves for next option to use as back-end.
If you want to use PDFLib as back-end then you may use the libpdf_php.dll. Else no need
June 26th, 2008 at 7:21 am
I have new trouble
Can’t create files with font Unicode, they asked for licensed PDFLib 
June 26th, 2008 at 5:13 pm
Try changing the following line in dompdf_config.inc.php -
To:
It will use the bundled CPDF library.
June 27th, 2008 at 6:58 am
still not work :’(
I tried this document, the last word “b?n” becomes “b?n”
chào các b?n
July 6th, 2008 at 1:50 pm
Nice to see this blog.
However i also use this dompdf plugin in CI. It’s really very easy. But i faced a problem when i crawl a site and wanted to pdf with that site CSS . But i failed to print that pdf with css.
July 8th, 2008 at 10:20 pm
Thanks Bijon :).
I haven’t tried that yet. When I will do that I will definitely let others know through this site.