CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 DOMPDF - PHP, MySQL

Print topic Send  topic

Author Message
Zye

Posts: 56
Posted: 10/10/2008, 11:04 AM

Here's how I got DOMPDF to work within CCS - PHP, MySQL

Download the files from http://www.digitaljunkies.ca/dompdf/
I installed them in a folder on my server called 'dompdf' - minus the www folder with the example files.
In the 'dompdf' folder I created a folder called tmp and made it writable (chmod) - dompdf/tmp
Make the folder with the fonts writable also - dompdf/lib/fonts
In the code view of my page (not events) I put the require_once line in the white space under - //End Include Common Files

//End Include Common Files
require_once("./dompdf/dompdf_config.inc.php");

In my HTML view of CCS I deleted all HTML, leaving nothing. Like an example I saw for FPDF on the CCS forums.

In beforeshow event of my page I have my code. The second code snippet below is not my actual code, but you should be able to get the idea.
I have my code in this way because I needed to have a few SQL WHILE loop queries happening.

You can get a simple result by just using a few lines like the example from digitaljunkies website:

--------------------------------------------------------------------------------------------------

 $html =    
    '<html><body>'.    
    '<p>Some text</p>'.    
    '</body></html>';    
    
$dompdf = new DOMPDF();    
$dompdf->load_html($html);    
    
$dompdf->render();    
$dompdf->stream("my_pdf.pdf", array("Attachment" => 0));

--------------------------------------------------------------------------------------------------

This is the method I used to create my while loops.

$db = new clsDBconnection;  
$data = CCGetParam("data_id","");  
$SQL = "SELECT data_title, data_desc, data_img FROM data WHERE data_id =". $data;  
  
$db->query($SQL);  
while($db->next_record())  
{  
$datatitle = $db->f("data_title");  
$datadesc = $db->f("data_desc");  
$dataimg = $db->f("data_img");  
  
$strHtml = '<p><table cellspacing="0" cellpadding="5" width="90%" align="center" border="0">';  
$strHtml .= '<tr>';  
$strHtml .= '<td valign="top">';  
$strHtml .= '<strong>Data Title: '. $datatitle .'</strong><br>';  
$strHtml .= 'Description: '. $datadesc .'<br>';  
$strHtml .= '<td align="right" valign="top"><img src="' . $_SERVER['DOCUMENT_ROOT'] . '/images/'. $dataimg .'"> </p></td>';  
$strHtml .= '</tr>';  
$strHtml .= '</table>';  
$strHtml .= '<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">';  
$strHtml .= '<tr>';  
}  
$strHtml .= '</td>';  
$strHtml .= '<td valign="top"> </td>';  
$strHtml .= '</tr>';  
$strHtml .= '</table>';  
$strHtml .= '</body></html>';  
  
$dompdf = new DOMPDF();  
//$dompdf->set_paper('A4');  
$dompdf->load_html($strHtml);  
$dompdf->render();  
$dompdf->stream("brochure.pdf", array("Attachment" => 0)); // switch Attachment to 1 to view PDF in Acrobat.

Thats it. I will post if there is something I may have left out. Need to apply more fonts next.

Zye ...
View profile  Send private message
jjrjr1


Posts: 942
Posted: 10/11/2008, 12:09 PM

Hey Zye

Thanks for this info and thanks for the post at CCSElite.com

We are thinking of setting up scheduled chats over there and the DOMPDF subject came up. Hope you will join us for that discussion when we set it up.

Take Care..

See You Later
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.