intelsys
Posts: 3
|
Posted: 02/18/2011, 9:33 AM |
|
Hi -
Just downloaded and installed TCPDF -
Checked install and examples work OK -
However -
I am having some difficulty filling in the parameters for the convert to PDF action in the page's before show event - (some is an understatement) -
Could someone provide me with a example of how they have set this up -
Not sure re:
command
options
parameter name
temporary folder
Really appreciate any help
Thanks
|
|
|
Waspman
Posts: 948
|
Posted: 02/23/2011, 1:38 AM |
|
I put this in the page_BeforeOutput event
global $main_block;
$save_block = $main_block;
require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF {
//Page header
public function Header() {
// Full background image
$auto_page_break = $this->AutoPageBreak;
$this->SetAutoPageBreak(false, 0);
$img_file = K_PATH_IMAGES.'Certificat-CPC.gif';
$this->Image($img_file, $x=0, $y=0, $w=210, $h=297, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0);
$this->SetAutoPageBreak($auto_page_break);
}
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(C2T);
//$pdf->SetAuthor('Nicola Asuni');
//$pdf->SetTitle('TCPDF Example 051');
//$pdf->SetSubject('TCPDF Tutorial');
//$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(25, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
// remove default footer
$pdf->setPrintFooter(false);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
//$htmlcontent = include 'certest.php';
// Pritn a text
//$pdf->writeHTML($htmlcontent, true, 0, true, 0);
$pdf->writeHTML('<br><br>'.$save_block, $ln=true, $fill=false, $reseth=false, $cell=false, $align='');
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('C2TDoc.pdf', 'I');
I styled the elements in the HTML.
_________________
http://www.waspmedia.co.uk |
|
|
intelsys
Posts: 3
|
Posted: 02/24/2011, 5:33 AM |
|
Hi Waspman -
Thanks for the code -
It works well -
However -
Have you noticed if there's a 'limit' of some kind on the size of the document -
It works well on a 'small' page -
but ends up with a 'blank' document on a long complex report -
I echo'd the main_block and the document is all there -
Any ideas appreciated -
Thanks again for the help -
|
|
|
datadoit
|
Posted: 02/24/2011, 6:02 AM |
|
Bump up your PHP memory limit in php.ini. I think it defaults to 8MB
(?). Usually not enough for generating PDF's.
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 128M
|
|
|
chiryphp
Posts:
|
Posted: 02/24/2011, 6:20 PM |
|
Hi,
May be you can try it anther PHP PDF class.
Some PHP pdf projects listed on the site PHPKode http://www.phpkode.com/projects/category/php-pdf/
|
|
|
intelsys
Posts: 3
|
Posted: 02/26/2011, 2:22 PM |
|
Thanks for the leads chiryphp - I will follow up -
datadoit
I had the php.ini memory bumped up to 256M -
However it still only shows 1/2 of the first html page in the pdt that is created and it does not create a second page for the second of the two html pages generated by ccs -
Am I missing something to tell it there is more than one page
Wish there was better documentation on this thing -
If you can think of anything I'm missing I'd appreciate the insights -
Thanks for the help so far -
|
|
|
damian
Posts: 838
|
Posted: 02/26/2011, 2:52 PM |
|
is this a hosted hosting account? check with your host to see what the actual mem limit can beset to. i had to change hosts when i started running into mem limitations and now use a vps so i can set my own limits. try it on your local environment and see if it completes.
_________________
if you found this post useful take the time to help someone else.... :)
|
|
|
datadoit
|
Posted: 02/26/2011, 2:56 PM |
|
The best I can recommend now is to use FPDF, along with the FPDI
extension. That scenario allows you to load in pre-existing PDF
documents such as forms, invoices, quotes, etc., then just overlay your
dynamic data onto them.
I suspect what's happening with your using the main block is that the
subsequent pages haven't been loaded or referenced yet (?). The main
block only contains the HTML output of the current page.
|
|
|
gulam
Posts: 55
|
Posted: 10/09/2011, 11:05 AM |
|
Hi,
Thanks for the code waspman, I have used it and it works, however it is quite slow. Is there any way to speed this up?
Gulam
|
|
|
|