problem with using dompdf |
[eluser]Unknown[/eluser]
Hello, I found "PDF generation using dompdf" in the wiki and though it would be very useful to my application. I followed the instructions in the wiki... renamed the folder the same, put it in the same plugins directory, created the plugin "to_pdf_pi.php" the same, I did slightly change the controller... Code: function itinerys() The problem come when i run it i get the following errors... Code: A PHP Error was encountered I'm guessing the "Unable to stream pdf: headers already sent" come up because of the other errors but can anyone help me with the other error? I've search these forums but i can't find the same problem anywhere else. Thanks very much Durham
[eluser]Unknown[/eluser]
I've found an answer to this myself in the dompdf forums. The problem is with css in html i was trying to convert as it is unsupported by dompdf. To get rid of the problem just get rid of the problem css. Hope this helps others, Durham
[eluser]Unknown[/eluser]
Hai, I found “PDF generation using dompdf” in the wiki and though it would be very useful to my application. I followed the instructions in the wiki… renamed the folder the same, put it in the same plugins directory, created the plugin “to_pdf_pi.php” the same, the controller <?php //require_once('basecontroller.php'); class Membercert extends Controller { function Membercert() { parent::Controller(); } function index() { $this->load->library('rapyd'); $this->load->view('membercert'); } function pdf() { $this->load->plugin('to_pdf'); $this->load->helper('file'); // page info here, db calls, etc. $html = $this->load->view('membercert/pdf', $data, true); pdf_create($html, 'filename'); } plugin <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); function pdf_create($html, $filename, $stream=TRUE) { require_once("dompdf/dompdf_config.inc.php"); $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); if ($stream) { $dompdf->stream($filename.".pdf"); } else { write_file("./invoices_temp/invoice_$filename.pdf", $dompdf->output(); } } ?> the view <html> <head> <title>Cetak Sijil Keahlian</title> <style type="text/css"> body { background-color: #fff; margin: 40px; font-family: Arial, Lucida Grande, Verdana, Sans-serif; font-size: 12px; color: #4F5155; } a { color: #003399; background-color: transparent; font-weight: normal; } h1 { color: #444; background-color: transparent; border-bottom: 1px solid #D0D0D0; font-size: 16px; font-weight: bold; margin: 24px 0 2px 0; padding: 5px 0 6px 0; } code { font-family: Arial, Monaco, Verdana, Sans-serif; font-size: 12px; background-color: #f9f9f9; border: 1px solid #D0D0D0; color: #002166; display: block; margin: 14px 0 14px 0; padding: 12px 10px 12px 10px; } </style> </head> <body> <div align="center"><!-- <h2> </h2> --> <div style="position: absolute; width: 763px; height: 76px; z-index: 3; left: 95px; top: 74px" id="layer5"> <font size="5"><strong>Kumpulan Wang Khairat Pekerja dan Pesara TNB</strong></font><br> <!-- <img src="<?php echo base_url()?>application/images/logo/logotnb.png" align="absmiddle"><br> --> <font size="1">(8592-U)</font><br><br><br><br><p><i><u><font size="4">Sijil Keahlian</font></u></i></p></div> </div> <p align="center"> </p> <div style="position: absolute; width: 762px; height: 100px; z-index: 2; left: 95px; top: 230px" id="layer4"> <font size="3"><p style="line-height: 150%" align="justify">Adalah disahkan bahawa <strong><?php echo $nama ?></strong> (Nombor Pekerja: <strong><?php echo $noPekerja ?></strong> dan Nombor K/P: <strong><?php echo $noIC ?></strong>) telah diterima menjadi seorang <strong><?php echo $jenisAhliDesc ?></strong> Kumpulan Wang Khairat Pekerja dan Pesara TNB berkuatkuasa mulai <strong><?php echo $tarikhMasuk ?></strong> dengan Nombor Ahli: <strong><?php echo $jenisAhliCode.$ahliKhairatID ?></strong>.</p></font> </div> <div style="position: absolute; width: 155px; height: 100px; z-index: 1; left: 95px; top: 370px" id="layer1"> <font size="2"><p align="center">........................<br>Tarikh</p></font> </div> <div style="position: absolute; width: 155px; height: 100px; z-index: 1; left: 692px; top: 370px" id="layer3"> <font size="2"><p align="center">........................<br>Setiausaha</p></font> </div> <div style="position: absolute; width: 155px; height: 100px; z-index: 1; left: 497px; top: 370px" id="layer2"> <font size="2"><p align="center">........................<br>Pengerusi</p></font> </div> </body> </html> ...but not display as pdf file.. is that anything error thru' my coding appreciate if u can help me... thank you...
[eluser]Unknown[/eluser]
I also encountered the "Invalid expression" error, what fixed it for me was to remove the comments inside the STYLE tag: From: Code: <style type="text/css"> To: Code: <style type="text/css">
[eluser]Unknown[/eluser]
Hi folks, I encountered the same problem and andyrut gave the good trick!
[eluser]splendidus[/eluser]
Hi everybody! I had the same "Invalid Expression" Problem. I have my styles in a separate css-file, which I link to my php-file. After several hours of searching and trying, I finally found 'the' solution in my case. The key words are: character encoding, UTF-8, BOM. My editor added a BOM (http://unicode.org/faq/utf_bom.html#BOM) at the beginning of my css-file, while saving it using a UTF-8 encoding. It was not visible in the editor, but the DOMPDF read it as a '' directly prior to my first style element 'body', and 'body' is indeed an invalid expression. Hope this helps somebody...
[eluser]Eric Cope[/eluser]
[quote author="splendidus" date="1234338022"]Hi everybody! I had the same "Invalid Expression" Problem. I have my styles in a separate css-file, which I link to my php-file. After several hours of searching and trying, I finally found 'the' solution in my case. The key words are: character encoding, UTF-8, BOM. My editor added a BOM (http://unicode.org/faq/utf_bom.html#BOM) at the beginning of my css-file, while saving it using a UTF-8 encoding. It was not visible in the editor, but the DOMPDF read it as a '' directly prior to my first style element 'body', and 'body' is indeed an invalid expression. Hope this helps somebody...[/quote] I am having this very problem. How did you solve it? Edit: I changed the encoding of a view file from UTF-8 to Western Latin-1.
[eluser]splendidus[/eluser]
In the settings of my editor there was an option, where I could select which types of files should be saved with BOM, and which without. In notepad++ for example, there is besides UTF-8 also the option "UTF-8 without BOM" (Settings > Options > New/Open/Save)
[eluser]ClaudioBasckeira[/eluser]
I'm having the same error message, only i simply not using any CSS! Any clues? |
Welcome Guest, Not a member yet? Register Sign In |