1

Hello everybody!
I'm working on a webpage with a CKEditor. Currently my prorject runs on an XAMPP/WindowsXP-system. The CKEditor generates HTML-code, I use a table to generate a graphical border for my content and (to work around a weakness of the CKEditor (and it's user)) I use a CSS to fill in the backgroundimages of the table.

Now I wanted to use your script to generate a pdf from it and as soon as I use the external CSS I only get an error!?

The relevant pathes are
\xampp\htdocs\project
\xampp\htdocs\project\html2pdf
\xampp\htdocs\project\userdata\
\xampp\htdocs\project\template\
\xampp\htdocs\project\template\feier1


The html-code is:
<html><head><title></title><link href="content.css" rel="stylesheet" type="text/css"/></head><body>
<div class="feier1">
	<table style="width: 271px; height: 142px;">
		<tbody>
			<tr> <td class="upperleft"> </td><td class="upperhorizon"> </td><td class="upperright"> </td></tr>
			<tr>
				<td class="leftvertical"> </td>
				<td class="eingabefeld"><img src="userdata/elefants.png" style="height: 106px; width: 162px; float: left;" />Love message!</td>
				<td class="rightvertical"> </td>
			</tr>
			<tr> <td class="lowerleft"> </td><td class="lowerhorizon"> </td><td class="lowerright"> </td> </tr>
		</tbody>
	</table>
</div>
</body></html>


For the beginning (and to narrow down the error) I toned down content.css to this single line:

.feier1 table .upperleft  {width:10px;  height:10px; background-image:url("template/feier1/lo.png");}


My PHP-script runs in \xampp\htdocs\project\ and looks like that:
    $postArray = &$_POST;
    $html=$postArray["CKE_HTML"];
    echo "debuginfo" . $html; //which gives the correct HTML-code
    require_once('html2pdf/html2pdf.class.php');
    $html2pdf = new HTML2PDF('P','A4','en'); 
    $html2pdf->WriteHTML($html);
    $html2pdf->Output('exemple.pdf', "F");



This is what I get:
Fatal error: Uncaught <span style="color: #AA0000; font-weight: bold;">ERROR n°6</span><br>File : G:\xampp\htdocs\project\html2pdf\html2pdf.class.php<br>Line : 2545
<br><br>Impossible to load the image <b>"template/feier1/lo.png"</b>  thrown in G:\xampp\htdocs\project\html2pdf\html2pdf.class.php  on line 2545

How to prevent/work around this error?

Thanks for your attention!

2

toktok (./1) :
<html><head><title></title><link href="content.css" rel="stylesheet" type="text/css"/></head><body>

this is not good. look at the examples. <html>, <head>, and <body> mlust not be used...

for css, the pb is relative / absolute path from the main php file. try with embed css in you html. -you can use file_get_content to include directly your CSS in the html, in a <style></style tag

Ancien pseudo : lolo

3

Thanks for the fast answer! You're Awesome!

However, I still get the same error.
Since English is not my native language, I'll do this step by step:

I did set up the CKEDITOR, to just submit what's inside <body></body>. This is what I get:
<div class="feier1"> 
	<table style="width: 271px; height: 142px;"> 
		<tbody> 
			<tr> <td class="upperleft"> </td><td class="upperhorizon"> </td><td class="upperright"> </td></tr> 
			<tr> 
				<td class="leftvertical"> </td> 
				<td class="eingabefeld"><img src="userdata/elefants.png" style="height: 106px; width: 162px; float: left;" />Love message!</td> 
				<td class="rightvertical"> </td> 
			</tr> 
			<tr> <td class="lowerleft"> </td><td class="lowerhorizon"> </td><td class="lowerright"> </td> </tr> 
		</tbody> 
	</table> 
</div> 


With this, I tried...
echo "Debug:<style>". file_get_contents("contentOA.css"). "</style>" . $htmlbody;
...
$html2pdf->WriteHTML("<style>". file_get_contents("contentOA.css"). "</style>" . $htmlbody);
...
...and while the HTML-output looks ok, the error remains the same.

Fatal error: Uncaught <span style="color: #AA0000; font-weight: bold;">ERROR n&#65533;6</span><br>File : G:\xampp\htdocs\project\html2pdf\html2pdf.class.php<br>Line : 2545<br>
<br>Impossible to load the image <b>"template/feier1/lo.png"</b> thrown in G:\xampp\htdocs\project\html2pdf\html2pdf.class.php on line 2545

---
Since I got a little confused about your comment about the css ("for css, the pb is relative / absolute path from the main php file."), I'll try to clarify as well:

My program is located in the file
/xampp/htdocs/project/confirm.php

the first error happens with:
/xampp/htdocs/project/template/feier1/lo.png

I tried both:
Absolute:
.feier1 table .upperleft {width:10px; height:10px; background-image:url("/project/template/feier1/lo.png");}
Relative:
.feier1 table .upperleft {width:10px; height:10px; background-image:url("template/feier1/lo.png");}
The error remains the same.

4

for style, it is <style stype="text/css>

if you don't put the background-image, does it work ?
Ancien pseudo : lolo

5

I expanded it to

$html2pdf->WriteHTML("<style type=\"text/css\">". file_get_contents("contentOA.css"). "</style>" . $htmlbody);
but still got the same error.


Then to test the whole thing without backgrounds, I removed the file_get (there's nothing else but that background in the file anyways) and included one of the backgroundsimages as an IMG with the same path, just to test if the path is correct:

$html2pdf->WriteHTML("<style type=\"text/css\">". "</style>" . $htmlbody);

<div class="feier1">  
	<table style="width: 271px; height: 142px;">  
		<tbody>  
			<tr> <td class="upperleft"> </td><td class="upperhorizon"> </td><td class="upperright"> </td></tr>  
			<tr>  
				<td class="leftvertical"> </td>  
				<td class="eingabefeld"><img alt="" src="template/feier1/lo.png" style="width: 10px; height: 10px;" /> Love message!</td>  
				<td class="rightvertical"> </td>  
			</tr>  
			<tr> <td class="lowerleft"> </td><td class="lowerhorizon"> </td><td class="lowerright"> </td> </tr>  
		</tbody>  
	</table>  
</div>
This works.

6

so, put the backgroud directly on you html smile style="...."
Ancien pseudo : lolo

7

I'm afraid this doesn't work,

To clarify myself: "to work around a weakness of the CKEditor I use a CSS-FILE to fill in the backgroundimages of the table". I hoped it was somehow possible to make the CSS-file work with your script.

However under this circumstances I can't help myself but to rework the CKEditor anyways. Thanks for your patience and your help!!!

8

try this :

$htmlbody = '<style type="text.css">
<!--
.feier1 table .upperleft  {width:10px;  height:10px; background-image:url('.dirname(__FILE__).'/path from this php file to your template directory/template/feier1/lo.png);}
-->
</style>
<page>'.$htmlbody.'</page>';
Ancien pseudo : lolo

9

toktok,

Did you look at the examples? Also keep in mind that what you see in the CKEditor will probably be a 'broken' image. The path is relative to the script location when it executes.I have used html2pdf with both CKEditor and YUI editor without a problem.

10

It looks like I have to experiment a little with the the DPI-settings, but it works! Thanks a lot!

-
Experimenting a little, this even let's me use the external css-file (which is great because it's also used for the ckeditor):

$htmlbody ='<style type="text.css">
    <!--
    '
    . str_replace("\"","", str_replace("url(\"", "url(\"".dirname(__FILE__). "/", file_get_contents("contentOA.css")))  . '
    -->
    </style><page>'.$htmlbody.'</page>';


Thanks a lot!!!

11

rlg0613 (./9) :
toktok,

Did you look at the examples? Also keep in mind that what you see in the CKEditor will probably be a 'broken' image. The path is relative to the script location when it executes.I have used html2pdf with both CKEditor and YUI editor without a problem.
I looked at the examples, but I missed a "startingpoint" and went quite confused through the files trying to figure out what they were good for. Speaking english not all that fluently and french not at all, it confused me more than it helped. Sorry.
Also keep in mind that what you see in the CKEditor will probably be a 'broken' image.
This confuses me. Why should I see the images broken (most likely invisible) if I set up the images and the CKE correctly?

12

rlg0613 > we are talkibng about images in css background, not image in fck editor wink
Ancien pseudo : lolo

13

Now I'm kinda curiuos:

I did setup the CKeditor with my own templates. In these templates the table-cells have classes.
I use these class-names and my modified contentOA.css (containing the css with "background-image=..."),
to present the user with a pretty limited choice of pre-formatted layouts (with actually background images
for cells). This works so far.

Why should our little experiement with html2pdf change that?