How To Generate PDF File In CakePHP

TCPDF is a free and open source software one of the widely used PHP libraries in the world. This is because of the fact that it already included in the most popular PHP-based CMS and applications including CakePHPHow to generate pdf file in cakephp.

The installation is pretty straight forward and easy-to-use in CakePHP Framework. Many web applications use this as output documents like invoices, contracts or just web pages in the PDF format.

 

Following are the steps to integrate TCPDF in CakePHP MVC framework.

Step 1:

  • Go to http://www.tcpdf.org and download the latest version of TCPDF zip file.
  • Then unzip the zip file and save under the Vendor folder in cakephp framework(app\vendors)
  • This creates a directory tcpdf there with tcpdf.php and more in it (app\vendors\tcpdf)
  •  You can configure the PDF file Like header Logo Image, Page Title, page Margin etc. in the TCPDF configure file (app->vendors->tcpdf-> tcpdf_config.php)

Step 2:

You can create your own header and footer page of your PDF file. Create a page “xtcpdf.php” under app/vendors with these contents as shown below.

App::import('Vendor','tcpdf/tcpdf');
class XTCPDF extends TCPDF
{
var $xheadertext = 'PDF created using CakePHP and TCPDF';
var $xheadercolor = array(0,0,200);
var $xfootertext = 'Copyright © %d XXXXXXXXXXX. All rights reserved.';
var $xfooterfont = PDF_FONT_NAME_MAIN ;
var $xfooterfontsize = 8 ;
/* Change header text and font size as per your requirement in the above variable*******/
function Header()
{
list($r, $b, $g) = $this->xheadercolor;
$this->setY(10); // shouldn't be needed due to page margin, but helas, otherwise it's at the page top
$this->SetFillColor($r, $b, $g);
$this->SetTextColor(0 , 0, 0);
$this->Cell(0,20, '', 0,1,'C', 1);
$this->Text(15,26,$this->xheadertext );
}
function Footer()
{
$year = date('Y');
$footertext = sprintf($this->xfootertext, $year);
$this->SetY(-20);
$this->SetTextColor(0, 0, 0);
$this->SetFont($this->xfooterfont,'',$this->xfooterfontsize);
$this->Cell(0,8, $footertext,'T',1,'C');
}
}
?>

Step 3:

Create your layout under app/views/layouts/pdf.ctp;

header("Content-type: application/pdf");
echo $content_for_layout;
?>

Step 4:

Here is the Controller code which will display output code of generating PDF file;

function view_pdf($id = null) {
if (!$id) {
$this->Session->setFlash('Sorry, there was no PDF selected.');
$this->redirect(array('action'=>'index'), null, true);
}
$this->layout = 'pdf'; //this will use the pdf.ctp layout
$this->render();
}

Step 5:

Create a page under your view directory (app/views/) named as “view_pdf.ctp” (this name can be change as per your controller method) and write your HTML code/PHP code.

IT Consulting Services & Its Offerings

Consulting Service

In this era of stiff competition, everyone wants to capitalize on the cost-effectiveness factor. Lower is the cost; higher is the profit margin for any organization.

IT consulting services not only offer to garner more profits for your business, they enable your business to reach the pinnacle of success.

The dimension of IT consulting services can be manifolds. Starting from website designing, development, testing to data migration, monitoring, and maintenance, etc.; IT consulting covers it all.

Consulting service providers develop target specific IT solutions as per their clients’ business requirements.

IT consultation has facilitated and brought a Win-Win situation for the clients. With the right quality of service, you not only reduce your operational costs but also improve your productivity for your business.

And since service providers take care of most of the issues like conceptualizing, developing, and implementing your business plans, you can concentrate on your core business to maximize its performance and growth.

Do you want to catalyze your business growth and profit aspects?

Then Andolasoft’s IT consulting services can be a trusted choice. Andolasoft offers a full range of IT service consultations including strategic consulting, system integration, monitoring to outsourcing.

We have the best technical pool of resources to meet any type of business challenge. Our developers work with our clients to understand their problem areas and accordingly develop solutions by applying the right mix of services.

With expertise in cutting edge technology, in-depth business insight as well as industrial experience, our IT consultation services help you make wise technological investments in sync with your business objectives.

SEO Helps You Make Money Online!

 

SEO is considered as one of the most cost-effective forms of marketing available. Today the optimized result pages of most search engines are just like the yellow pages of earlier times.

Starting from business names to product names to the type of services in the offering; people now prefer to look for search engines for any kind of information.

SEO will widen up your business to the online market segments which you have never considered earlier.

Getting a higher rank on the search engine page will help you attract higher traffic. But getting higher traffic is not the solution; you need to get quality traffic that can turn to be your potential business leads.

Only a quality SEO service provider like Andolasoft can generate quality traffic for your site.

Unlike other search engine optimization service providers, Andolasoft doesn’t guarantee an overnight result for your website.

There are sites that might be using Google Adwords or Yahoo Search Marketing to bring your site to the top.

But then these methods are more like pay-per-click engines where you will have to pay for each click on your link. Moreover, it’s no guarantee to reach through your target audience.

At Andolasoft, we don’t claim to make your site into the top of the search engine result pages (SERP) because it depends on several factors.

What we can guarantee is our efforts for ethical SEO services. Our successful clients’ list is a guarantee of our successful stint in the SEO service arena.