CodeIgniter Forums
problem with using dompdf - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: problem with using dompdf (/showthread.php?tid=6680)

Pages: 1 2


problem with using dompdf - El Forum - 03-07-2008

[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()
{
    $this->load->helper('file');
        
    $this->load->plugin('to_pdf');
    // page info here, db calls, etc.    
    $html = $this->load->view('home', $data=false, true);
    pdf_create($html, 'filename');
}

The problem come when i run it i get the following errors...

Code:
A PHP Error was encountered
Severity: Warning
Message: DOMXPath::query() [function.DOMXPath-query]: Invalid expression
Filename: include/stylesheet.cls.php
Line Number: 573

A PHP Error was encountered
Severity: Warning
Message: DOMXPath::query() [function.DOMXPath-query]: Invalid expression
Filename: include/stylesheet.cls.php
Line Number: 573

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: include/stylesheet.cls.php
Line Number: 575

Unable to stream pdf: headers already sent

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


problem with using dompdf - El Forum - 03-09-2008

[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


problem with using dompdf - El Forum - 03-12-2008

[eluser]Jauhari[/eluser]
Can you give me more detail information?


problem with using dompdf - El Forum - 04-07-2008

[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()Wink;
}
}
?>


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">&lt;!-- <h2>&nbsp;</h2> --&gt;
<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>
&lt;!-- <img src="&lt;?php echo base_url()?&gt;application/images/logo/logotnb.png" align="absmiddle"><br> --&gt;
<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">&nbsp;</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>&lt;?php echo $nama ?&gt;</strong> (Nombor Pekerja: <strong>&lt;?php echo $noPekerja ?&gt;</strong> dan Nombor K/P: <strong>&lt;?php echo $noIC ?&gt;</strong>) telah diterima menjadi seorang <strong>&lt;?php echo $jenisAhliDesc ?&gt;</strong> Kumpulan Wang Khairat Pekerja dan Pesara TNB berkuatkuasa mulai <strong>&lt;?php echo $tarikhMasuk ?&gt;</strong> dengan Nombor Ahli: <strong>&lt;?php echo $jenisAhliCode.$ahliKhairatID ?&gt;</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>

&lt;/body&gt;
&lt;/html&gt;


...but not display as pdf file..
is that anything error thru' my coding
appreciate if u can help me...
thank you...


problem with using dompdf - El Forum - 07-23-2008

[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:
&lt;style type="text/css"&gt;
&lt;!--

body { font-family: helvetica }

--&gt;
&lt;/style&gt;

To:

Code:
&lt;style type="text/css"&gt;

body { font-family: helvetica }

&lt;/style&gt;



problem with using dompdf - El Forum - 01-17-2009

[eluser]Unknown[/eluser]
Hi folks,

I encountered the same problem and andyrut gave the good trick!


problem with using dompdf - El Forum - 02-10-2009

[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...


problem with using dompdf - El Forum - 02-22-2010

[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.


problem with using dompdf - El Forum - 02-26-2010

[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)


problem with using dompdf - El Forum - 05-20-2010

[eluser]ClaudioBasckeira[/eluser]
I'm having the same error message, only i simply not using any CSS! Any clues?