Creating PDFs With Code Charge Studio PDF
Creating PDFs With Code Charge Studio PDF
This document will provide you some insight into creating your own reports, output as PDF files, from
CodeCharge pages. Actually, the process works for any URL want to capture.
There is a very powerful set of functions available as GPL'd code. Most of what you need will be installed
and ready to go if your webserver is Linux. I set this up on a Fedora Core distribution from RedHat and it
was extremely easy. Only the outer "wrapper" from http://www.rustyparts.com was missing - everything
else is in the Fedora distribution.
The code called by the Run Report button is shown below. It is mostly unchanged from the example
provided at rustyparts.com. I just pasted it into the event code-file for my report page.
$pdf->setTmpDir(dirname('__FILE__') .'/reports/pdf/tmp/');
//reports_Button_Run_OnClick @19-E856C3FF
function reports_Button_Run_OnClick()
{
$reports_Button_Run_OnClick = true;
//End reports_Button_Run_OnClick
//
$hostdomain = "localhost"; // Change this if the reports
are not on a different server
// The list of POST parameters here must correspond to each of the form
fields that accept user input
// By convention, all .php report files are designed to recognize
parameters
// by the names cid, pid, yr,st and en
$sep = "?";
$temp = CCGetFromPost("cid","0");
if ($temp !== "0") {
$params = $params . $sep . "cid=" . $temp;
$sep = "&";
}
$temp = CCGetFromPost("List_Ppty","0");
if ($temp !== "0") {
$params = $params . "&pid=" . $temp;
$sep = "&";
}
$temp = CCGetFromPost("Text_Year","0000");
if ($temp !== "0") {
$params = $params . "&yr=" . $temp;
$sep = "&";
}
$temp = CCGetFromPost("Text_From","0000");
if ($temp !== "0") {
$params = $params . "&st=" . $temp;
$sep = "&";
}
$temp = CCGetFromPost("Text_To","0000");
if ($temp !== "0") {
$params = $params . "&en=" . $temp;
$sep = "&";
}
$file_exists = true;
$index = 0;
while($file_exists) {
$ActualFileName = dirname(__FILE__) . $rptpath . date("YmdHis") .
$index . "." . $filename;
$output_file = $ActualFileName;
$report_URL = $reports->new_URL->GetValue();
}
else {
// Construct a URL from various parts
CCSetSession("last_report_file",$last_report_file);
// -------------------------
//End Custom Code