Fiji Web Design
Welcome, Guest
Please Login or Register.    Lost Password?
Re:PDF Generator for the com_php (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:PDF Generator for the com_php
#885
Prakash2009 (User)
Fresh Boarder
Posts: 9
graphgraph
User Offline Click here to see the profile of this user
PDF Generator for the com_php 2 Years, 9 Months ago Karma: 0  
Hi All,

I am using Joomla 1.5 version.
Installed com_php.
Created a page using this component.
The requirement is to Generate PDF for the page as we can do for Articles.

Unable to find the solution

This is urgent requriement, please help...

Thanks in advance
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#887
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:PDF Generator for the com_php 2 Years, 9 Months ago Karma: 10  
Joomla used TCPDF library. (www.tcpdf.org)

Here is the code documentation: http://www.tecnick.com/pagefiles/tcpdf/doc/index.html

Examples: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_examples

Joomla uses this in libraries/document/pdf/pdf.php to generate the PDF version of the articles.

The library is in: libraries/tcpdf

So for example you'd include tcpdf:

require_once(JPATH_BASE.'/libraries/tcpdf/tcpdf.php';

Then do what you need.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#889
Prakash2009 (User)
Fresh Boarder
Posts: 9
graphgraph
User Offline Click here to see the profile of this user
Re:PDF Generator for the com_php 2 Years, 9 Months ago Karma: 0  
Hi,

Thanks for your immediate response.

I tried putting the following code in my PHP page.
As soon as I tried accessing that page, the page becomes blank

<?php
require_once('../config/lang/eng.php' );
require_once('../tcpdf.php' );

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni' );
$pdf->SetTitle('TCPDF Example 001' );
$pdf->SetSubject('TCPDF Tutorial' );
$pdf->SetKeywords('TCPDF, PDF, example, test, guide' );

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//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('times', 'BI', 16);

// add a page
$pdf->AddPage();

// print a line using Cell()
$pdf->Cell(0, 12, 'Example 001 - €à èéìòù', 1, 1, 'C' );

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('example_001.pdf', 'I' );

//============================================================+
// END OF FILE                                                 
//============================================================+
?>
 
Report to moderator   Logged Logged  
 
Last Edit: 2009/05/14 05:53 By admin. Reason: code syntax hilighting
  The administrator has disabled public write access.
#890
Prakash2009 (User)
Fresh Boarder
Posts: 9
graphgraph
User Offline Click here to see the profile of this user
Re:PDF Generator for the com_php 2 Years, 9 Months ago Karma: 0  
Hi,

Want to add one more thing to make the point clearer about what I want.

I want the PDF and PRINT button on my PAGE(created in COM_PHP) exactly the same way as with ARTICLES created in ARTICLE MANAGER.

Still breaking my head
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#891
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:PDF Generator for the com_php 2 Years, 9 Months ago Karma: 10  
The blank page is probably because there is a fatal error, and you have error reporting turned off.

At the top of your PHP, place:

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
Also make sure the paths of the files you are including are correct. This is probably where the error lies. eg:
require_once(JPATH_BASE.'/libraries/tcpdf/tcpdf.php' );
instead of
require_once('../tcpdf.php' );
 
Report to moderator   Logged Logged  
 
Last Edit: 2009/05/14 06:55 By admin.
  The administrator has disabled public write access.
#892
admin (Admin)
Admin
Posts: 475
graph
User Online Now Click here to see the profile of this user
Re:PDF Generator for the com_php 2 Years, 9 Months ago Karma: 10  
QUOTE:
I want the PDF and PRINT button on my PAGE(created in COM_PHP) exactly the same way as with ARTICLES created in ARTICLE MANAGER.


You'll have to look into how Joomla does it.

Search through the API:
http://api.joomla.org/li_Joomla-Framework.html

or SVN repository:
http://joomlacode.org/gf/project/joomla/scmsvn/?action=browse&path=%2Fdevelopment%2Ftags%2F1.5.x%2F1.5.10%2F

I use a local SVN repository of the latest Joomla stable, and have an SVN search engine that allows quick search of the Joomla files, or other projects I'm interested in.

You can also do this online at code.google.com by importing the Joomla stable into their SVN repo. This is already done for Joomla1.5.9 here:
http://joomlacode.org/gf/project/joomla/scmsvn/?action=browse&path=%2Fdevelopment%2Ftags%2F1.5.x%2F1.5.10%2F

You can then use the "trunk search" to search through the files to find what you want.

An example for "pdf print email icon"

http://www.google.com/codesearch?q=pdf+print+email+icon+package:http://joomla-project\.googlecode\.com&origq=pdf+print+email+icon&btnG=Search+Trunk

The second result is probably what you're interested in.
 
Report to moderator   Logged Logged  
 
Last Edit: 2009/05/14 07:01 By admin.
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Joomla Downloads

DownloadsDownload our free Joomla! Components, Modules and Plugins.