Export My Page as PDF

shoaib 06 Jan, 2011
Hi,

I have used ChronoConnectivity to display my table with dropdow filter. I like to export reports as pdf.

How it is possible with chronoconnectivity. I have attached my screenshot
GreyHead 06 Jan, 2011
Hi shoaib,

ChronoConnectivity doesn't have this ability. You may be able to do it with one of the Joomla! PDF extensions abut I'm not certain.

Bob
shoaib 18 Jan, 2011
Hi ozneilau,

Thanks For ur Reply I downloaded the Fpdf and copied the files fpdf.css and fpdf.php to ../administrator/fpdf directory And applied the coding in my form .The code is
<h1> <b> Hai This is smaple form for testing pdf link </b> </h1>



<?php
require('/administrator/fpdf/fpdf.php');

//Create PDF
$pdf=new FPDF('P','mm','A4');
$pdf->AddPage();

//Add Logo
$pdf->Image('images/save.png',57,38,42,24);

//Add Box
$pdf->SetLineWidth(0.2);
$pdf->Rect(9,9,92,55,'D');

//Add Address
$pdf->SetXY(11,11);
$pdf->SetFont('Helvetica','',7);
$pdf->MultiCell(35,3,"\nyour_title_here\nyour_phone_no_here\nyour_address_here",0,'L');

//Add Other Text including variables from Database
$pdf->SetXY(10,28);
$pdf->SetFont('Helvetica','B',9);
$pdf->Cell(25,4,'Name:',0,0);
$pdf->SetFont('Helvetica','',9);
$pdf->Cell(65,4,$MyRow->Firstname . ' ' . $MyRow->Surname,0,1);

// etc.
// etc.

//Save PDF to temporary file in /tmp folder
$file = basename(tempnam('.', '../administrator/tmp'));
rename($file, $file.'.pdf');
$file .= '.pdf';
$file = 'tmp/' . $file;
$pdf->Output($file, 'F');
header('Location: '.$file);

//Delete temporary PDF files in /tmp folder over an hour old
$t = time();
$dir='tmp/';
$h = opendir($dir);
while($file=readdir($h))
  {
  if(substr($file,0,3)=='tmp' && substr($file,-4)=='.pdf')
    {
    $path = $dir.$file;
    if($t-filemtime($path)>3600)
    @unlink($path);
    }
  }
closedir($h);
?>


When I tried to Execute The form I got the Error like this
Hai This is sd smaple form for testing pdf link

Warning: require(../administrator/fpdf/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/osmodels/public_html/subdomains/spreadindia/components/com_chronocontact/chronocontact.html.php(180) : eval()'d code on line 6

Warning: require(../administrator/fpdf/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/osmodels/public_html/subdomains/spreadindia/components/com_chronocontact/chronocontact.html.php(180) : eval()'d code on line 6

Fatal error: require() [function.require]: Failed opening required '../administrator/fpdf/fpdf.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/osmodels/public_html/subdomains/spreadindia/components/com_chronocontact/chronocontact.html.php(180) : eval()'d code on line 6




Regards,
Shoaib.
GreyHead 18 Jan, 2011
Hi shoaib,

Most of these are because $MyRow isn't defined before it is used in this line
$pdf->Cell(65,4,$MyRow->Firstname . ' ' . $MyRow->Surname,0,1);

Bob
shoaib 18 Jan, 2011
Hi Bob,

I have Edited the above thread. Please Check it again.


Regards,
Shoaib
GreyHead 18 Jan, 2011
Hi Shaoib,

The error messages are pretty clear. Please read them carefully and fix the errors.

Bob
shoaib 18 Jan, 2011
Hi Bob


I used require function path as require ("../sample/fpdf.php");

I have copied fpdf.php file at the ftp location /public_html/subdomains/spreadindia/sample


I have given the path right but I have this problem.

can u help me add the right path in require function
ozneilau 18 Jan, 2011
Hi shoaib,

You seem to have a problem with the way you are defining the path to the required library files.

You have:

require('/administrator/fpdf/fpdf.php');

and:

require ("../sample/fpdf.php");

but what worked for me was:

require('libraries/fpdf/fpdf.php');

You could also try (at least temporarily) the absolute path to see if that works:

require('http://websitename.com/libraries/fpdf/fpdf.php');

Obviously, you need to change "websitename.com" to your one and "libraries" to "administrator" or "sample" or wherever you copied the library files to.

Neil.
shoaib 18 Jan, 2011
Hi Neil,

Thanks for your Support.

I applied your first method require('libraries/fpdf/fpdf.php'); But had the Same Problem.

Then I tried the Second one require('http://websitename.com/libraries/fpdf/fpdf.php');


But I got an error as
Fatal error: Class 'FPDF' not found in /home/osmodels/public_html/subdomains/spreadindia/administrator/components/com_chronocontact/admin.chronocontact.php(2736) : eval()'d code on line 7


At Backend on Saving the form.


Regards,
Shoaib
ozneilau 18 Jan, 2011
Hi Shoaib,

Did you substitute your own particular path in the statement?

If I assume your website is http://www.spreadinternational.org and the FPDF files are at:

www.spreadinternational.org/sample/fpdf/fpdf.php
www.spreadinternational.org/sample/fpdf/fpdf.css
www.spreadinternational.org/sample/fpdf/font/courier.php
www.spreadinternational.org/sample/fpdf/font/helvetica.php
etc.

Then your statement should be:

require('sample/fpdf/fpdf.php');

or

require('http://www.spreadinternational.org/sample/fpdf/fpdf.php');

Neil.
This topic is locked and no more replies can be posted.