Solved

dompdf background image problem

Posted on 2009-05-18
2
2,325 Views
Last Modified: 2012-08-13
I'm using dompdf to generate pdf with background image but I can't make background-image to work. I have copied dompdf's example background_image.html from www/test/ folder that works when I click on their link to generate pdf, but it won't work when I use my code.
Please help, below is the code that I use.
<?php
ini_set("memory_limit","64M");
set_time_limit(300);
require_once("dompdf_config.inc.php");
 
$html ='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'.
 '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>'.
'<style>'.
'p.c1 { background-image: url(dompdf_simple.png); background-repeat: repeat-x; background-position: 100px 1%; }'.
'p.c2 { background-image: url(php.gif); background-position: top left; background-repeat: repeat-y; }'.
'</style>'.
'</head>'.
'<body>'.
'<h1>Lorem ipsum dolor sit amet</h1>'.
'<p class="c1">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec at'.
'odio vitae libero tempus convallis. Cum sociis natoque penatibus et'.
'magnis dis parturient montes, nascetur ridiculus mus. Vestibulum purus'.
'mauris, dapibus eu, sagittis quis, sagittis quis, mi. Morbi fringilla'.
'massa quis velit. Curabitur metus massa, semper mollis, molestie vel,'.
'adipiscing nec, massa. Phasellus vitae felis sed lectus dapibus'.
'facilisis. In ultrices sagittis ipsum. In at est. Integer iaculis'.
'turpis vel magna. Cras eu est. Integer porttitor ligula a'.
'tellus. Curabitur accumsan ipsum a velit. Sed laoreet lectus quis'.
'leo. Nulla pellentesque molestie ante. Quisque vestibulum est id'.
'justo. Ut pellentesque ante in neque.</p>'.
 
'<p class="c2">Curabitur ut diam eu dui vestibulum pharetra. Nam pellentesque, justo'.
'non hendrerit venenatis, mi orci pretium mi, et vehicula leo arcu quis'.
'diam. Nullam mattis laoreet quam. Morbi mollis sem ut tellus. Nam mi'.
'massa, lobortis eu, sollicitudin et, iaculis et, massa. Maecenas purus'.
'mauris, luctus sit amet, pharetra in, facilisis sit amet, elit. Nullam'.
'vel erat tempus purus molestie suscipit. <span>Vestibulum odio lorem,'.
'sollicitudin non, volutpat sit amet, tincidunt vel, nunc. Nulla quis'.
'ante vestibulum odio feugiat facilisis. Proin lorem nisl, viverra at,'.
'rhoncus quis, semper nec, mi. Donec euismod enim vitae velit</span>. Nulla'.
'sed lectus. Vivamus placerat, lacus sed vehicula sagittis, arcu massa'.
'adipiscing lorem, bibendum luctus nisl tortor vitae leo.</p>'.
 
'<p class="c1">Etiam a mauris. Proin justo elit, accumsan sit amet, tempus et,'.
'blandit id, tellus. Morbi varius, nisi id iaculis aliquam, lacus'.
'ligula facilisis velit, ac pharetra ipsum augue a massa. Etiam rhoncus'.
'commodo orci. Mauris ullamcorper sagittis turpis. Nullam magna libero,'.
'sagittis sed, auctor faucibus, accumsan vitae, urna. Pellentesque'.
'volutpat. Aliquam sapien ipsum, eleifend nec, imperdiet vitae,'.
'consectetuer id, quam. Donec a urna. Suspendisse sit amet'.
'velit. Curabitur quis nisi id dui viverra ornare. Sed condimentum enim'.
'quis tortor. Ut condimentum, magna non tempus tincidunt, leo nibh'.
'molestie tellus, vitae convallis dolor ante sed ante. Nunc et'.
'metus. Phasellus ultricies. Fusce faucibus tortor sit amet mauris.</p>'.
 
 
 
'</body>'.
'</html>';
 
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>

Open in new window

0
Comment
Question by:mankis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
ycTIN earned 500 total points
ID: 24412014
do you put dompdf_simple.png into same folder?
or you got some other error message?
0
 

Author Comment

by:mankis
ID: 24415163
My mistake, image was not in the same folder. It seams that it's working only when the image is in the same folder.

Thank you for helping.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question