Print docs in PDF format in Yii - php

I have made an application in Yii. Now as per my application requirement I have to make them print in PDF format. I searched over Yii docs but did not got any docs about converting file into printable PDF format. So any help and suggestions will be highly appreciable.

Look into WkHtmlToPdf:
http://code.google.com/p/wkhtmltopdf/
It uses Webkit's rendering engine to make PDFs from HTML / CSS. It's the best library out there that I've found and I've done a bunch of research.
Edit:
Mike on the Yii forum has already built an OO wrapper for WkHtmlToPdf and just released a Yii extension for it.

I have recently used MPDF for a project. It allows you to convert HTML output into PDF format. If you are looking for something simple this might be what you are looking for. Personally, I find it easier to work with HTML/CSS for layout than PDF boxes. I am not sure just how well it scales with complex layouts, though.
Yii also supports using Zend modules. You can use Zend_Pdf if you so choose.
See this documentation page on how to integrate third-party libraries with your Yii code.
Either way, as has already been mentioned, there are tons of PDF libraries available for PHP.

You should search for php libraries to do that. Link to one of them - http://www.tcpdf.org/

I have had great success using fpdf - http://www.fpdf.org/

Unfortunately this feature is not part of Yii. You can try TCPDF, though. http://www.tcpdf.org/
TCPDF lets you parses your HTML output to PDF document. The PDF document can be output in your server or to the user as a direct download.

Hers the extension to create PDF files.
Yii2-PDF

Related

CakePHP export html/data to PowerPoint Format

I am facing a problem with CakePHP 2.X. My client wants to export some data generated from a mysql database, to a powerpoint (.ppt or .pptx) format(s) in a specific template. I allready knew the PHPPowerPoint is at the alpha status so I don't want to make a plugin for Cake based on this. I also found
this! little gem but It works only for Windows PHP and I am using a linux based server (CentOs).
It is possible to create an xml or an html, encoded with something compatible of powerpoint format and just put the right php headers at the top? And what is this something?
or a better solution is there an api or a plugin something to work for all the platforms?
And could this plugin or api is compatible for Cake?
Thank you
PHPPowerPoint seem to be at a good place now, check out their GitHub: PHPPowerpoint
Installation instructions: http://phppowerpoint.readthedocs.org/en/latest/installing.html

Insert Text in PDF with PHP but without Zend Framework

At the moment I am using this code to insert text in a PDF:
$pdf = Zend_Pdf::load("test_document.pdf");
$font = Zend_Pdf_Font::fontWithPath('arial_unicode_ms.ttf');
foreach ($pdf->pages as &$page) {
$page->setFont($font, 12);
$page->drawText("Inserted some text.", 200, 10);
}
The problem is, that I want to include this functionality in a Joomla plugin and I don't want to include all the data from Zend Framework to my project.
Is there any easy way or any small library which provides this pdf tagging mechanism?
If you still want to use Zend_Pdf, you'll probably need to have a look at the dependencies in the Zend/Pdf directory. You can grep for require_once to have a rough idea, and filter out the Zend/Pdf results:
grep -r require_once Pdf.php Pdf | grep -v "Zend/Pdf"
The first step outputs Zend_Memory, Zend_Exception and Zend_Log.
You can follow a similar method to check additional dependencies, and you'll see that Zend_Memory needs Zend_Cache, which needs only Zend_Log, which is self-contained, like Zend_Exception. I think you won't need to go much further, once you have included these four additional libraries.
EDIT: I found this link that lists all the dependencies between ZF modules (don't know how up to date it is, though): http://files.zend.com/help/Zend-Framework/requirements.dependencies.html
Hope that helps,
There are other pdf libraries available. I have used tcpdf in place of Zend_Pdf occassionally. It is all self contained, so you won't have any dependency issues with it.
In answer to your comment
I started using TCPDF as Zend_Pdf was incomplete and I needed a solution that would allow me to use existing pdf's as base documents as you seem to need. The solution I eventually opted for was to use FPDI in conjunction with TCPDF.
I haven't worked on that project for a while now, but I used the FPDI web site as the start of the solution that eventually worked for me.
I'm not sure if it will be a solution for you too, but it's worth having a look.
It is not necessary to include the whole Zend Framework with your project, you only need to include the Zend/Pdf.php and the Zend/Pdf folder. This isn't that large (combined size of ~ 1.2mb).

How to create pdf files in drupal?

I want to create pdf files in drupal .module file.
I have view of bulk operations in which I have added an operation send pdf file and download pdf file.
I want to get some data from the database and and create a pdf file from it and when I select an operations it should create and send the pdf file in an email.
So how could I do this???
You should look first in the PHP library for creating PDF files. You can use TCPDF or many others in the PHP libraries:
https://stackoverflow.com/questions/560583/which-is-the-best-pdf-library-for-php
After doing a quick search at Drupal Modules I found this module. And I also found this by Googling. The latter one seems to need no additional PHP modules and should be easy to integrate.
There is a new module named PHP WK HTML to PDF
From his site:
This is intended for module developers, nothing is usable from the
front-end.
This module is a Drupal Library implementation for the PHPWkHtmlToPdf
wrapper and as a result is extremely small because it uses WkHtmlToPdf
to do the heavy work.
And you can use if you want Views PDF
With this module you can output a view as a PDF document. Each field
of the view can be placed on the PDF page directly in the
administration interface. Therefore a new display called "PDF" is
added.
You should use the module print. This module allow you to print a node but also any page of your site. After enable the module you can generate pdf simply by visiting url starting with printpdf/NID or printpdf/AnyPAth.
To generate the pdf it can use the following libraries: dompdf, TCPDF, wkhtmltopdf.
Follow the installation guide
TCPDF is good for pdf creation.
There is new module TCPDF. See tcpdf_example submodule to get started.
For installation see INSTALL.txt:
Download and install libraries module.
Download TCPDF library from http://sourceforge.net/projects/tcpdf/files/
Extract it to sites/all/modules/libraries.
Download and install TCPDF module.
Check the status report to verify if the installation was successful.
Have fun.
I had a very intricately styled view recently that I just couldn't get looking the same as a pdf, I used this service to do it and I was pretty impressed. http://www.html2pdfrocket.com/

How to read/write xml files using Drupal 6

I would like to know how can I parse XML files and perform read write operations using Drupal 6.
There is no API for this in Drupal -- use the SimpleXML extension from PHP. It works wonders.
It depends on the specifics of what you need to do. Modules such as Import / Export API, Views Datasource, XML Parser, and others may be useful, depending on what exactly you need to accomplish.
Also, this XML Parser for the Feeds module looks promising.
Drupal is a PHP application. There is no specific XML API in Drupal and any PHP one can be used in a custom module for a specific user case or feature. There is a large collection of XML APIs in PHP. If you have experience with jQuery, look also at QueryPath and the QueryPath module for Drupal.
You will need to create a module to embed your custom PHP code in your Drupal site.
As pointed by Matt V., there is a lot of modules in Drupal that deal with XML. Some may fit your needs and avoid you to write any custom code.

generation of multiple reports and zipping in codeigniter php

I want to generate multiple pdf reports on click of single print button and zip all the pdf's and store it in a folder.
Any help please. I need this functionality in my project.
According to https://stackoverflow.com/questions/560583/which-is-the-best-pdf-library-for-php
, the best pdf php library is FPDF.
They also mention that Zend has a nice PDF Lib. If you are using CodeIgniter you may wish to use the Zend library, as Zend libraries work nicely inside of CodeIgniter. (A simple Google search will show up several tutorials on using Zend libs as CI libs).
Someone on the CI Forums has instructions on using FPDF with CodeIgniter:
http://codeigniter.com/forums/viewthread/45365/
As for the second part of your question, wrapping data in a zip file is easily done with with CodeIgniter Zip Encoding library as detailed in the user guide.

Categories