how can i make the horizontal pdf file - php

hi guys how can i make a harizontal pdf file by using php.i created for the register form(name ,email, street,city country) can any one say some ideas.
thanks in adv

For that purpose you need to include a library of php after downloading it FPDF
And this is just an example to use fpdf library.
<?php
require('fpdf.php');
$pdf=new FPDF('l','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'NAME');
$pdf->Cell(40,30,'EMAIL');
$pdf->Cell(40,50,'STREET');
$pdf->Cell(40,70,'CITY');
$pdf->Cell(40,100,'COUNTRY');
$pdf->Output();
?>

Take a look at FPDF to generate the PDF, or for converting HTML straight into a PDF - wkhtmltopdf.

Related

using MPDF malayalam fonts in pdf generation using PHP

any way to add malayalam font to PDF generation. any methods existing?
mPDF supports default malayalam font. after including mpdf folder to third party directory in codeIgniter insert code like
$html = $this->load->view('masterentries/pdfReport',$data,TRUE);
include_once APPPATH.'/third_party/mpdf/mpdf.php';
$pdf = new mPDF('ml', 'A4');
$pdf->SetFooter($_SERVER['HTTP_HOST'].'{PAGENO}|'.date(DATE_RFC822));
$pdf->WriteHTML($html); // write the HTML into the PDF
$pdf->Output();
will produce the pdf containing malayalam.

How to export variables data with fpdf

This is the code for index which will export what ever is in page under HTML varialbe:
<?php
require('fpdf/fpdf.php');
$html = 'kkjkjkjkjjkj';
$pdf = new FPDF();
$pdf->AliasNbPages($html);
$pdf->AddPage($html);
$pdf->SetFont('Times','',12);
$pdf->Output();
?>
Here it's exporting it to PDF but here how I can let the $html to get export to PDF using FPDF
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
1) Have a look at the Manual and Tutorial sections of the FPDF website
There are a lot of simple examples to take a look at.
2) You can't send html code with the AddPage() function. It should be orientation ("P" or "L") and size (like "A4") (see their documentation here)
3) It is not possible to just insert html into FPDF. You have to cut it up into text, links, images, tables and build the PDF content up just as you build up the HTML. There are some script that do support html input, but even those make mistakes now and then. My advise: instead of creating/building/compiling HTML, generate FPDF elements.
This example clearly exports a (simple) $html variable to a PDF
http://fpdf.org/en/tutorial/tuto6.htm
It is not possible to directly write HTML to a PDF using FPDF - you would have to separate the data into strings, set formatting to them, etc - basically, you will not be dealing with HTML anymore.
However, if you are not limited to FPDF, I would suggest looking into wkhtmltopdf, which can take HTML as an input, and render it to PDF using Webkit rendering engine. It can even take a remote URL and convert it to a PDF on your server.

Converting html webpage into a pdf page(pdf file which user will download)

I am developing a website in Cakephp framework, what i want to do, is to give the user option of downloading the page he is viewing in pdf format.I am using html2pdf plugin but its giving problem integrating with Cakephp. How can i solve this. Thanx for your interest.
Try TCPDF. It is simple and powerful enough.
Two options, one is paid and another open source. Both are good, and well documented.
PDFLib
FPDF
I would suggest starting with FPDF, and then learning/moving to PDFLib
Using DOMPDF.
Example Code :
<?php
require_once("dompdf/dompdf_config.inc.php");
$html = "<h1>some document</h1>";
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('A4');
$dompdf->render();
$dompdf->stream("pdfReport.pdf");
?>

FPDF image not displaying

I tried to put an image in my pdf document, but when I use that method it only loading for a while, and do nothing (no errors, or such things) only a grey site...
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('logo.png');
$pdf->Output();
So what I do wrong? If I only use text in the pdf, it's no problem, but with the Image. The Image is in the root-directory.
Edit: Added $pdf->AddPage(); as per the comment in Ewan Heming's answer.
Your example doesn't include a method call to add a page to the PDF before placing the image on it:
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('logo.png');
$pdf->Output();
Sry guys i found out the problem , the resolution of the picture was too big

Convert text to PDF in PHP

What would be the simplest, shortest way to turn a text file into a PDF file with PHP? With some basic example code if possible.
I've seen this but the examples don't show how to use a text file as input.
http://uk3.php.net/manual/en/book.pdf.php
Thanks
TCPDF and FPDF can both render PDF output. If you're on a Linux system, you could also call the system's ghostscript to do it.
You'll definitely need a library to write PDFs. I'd say try FPDF.
TCPDF is the best way to convert text or HTML to PDF.
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf
Throwing Zend_Pdf into the ring as well.
And a somewhat old tutorial to get you started in addition to the extensive docs in the ZF manual:
http://devzone.zend.com/article/2525
You can use MPDF.
I wrote a smalll instruction:
1) download Full version(http://www.mpdf1.com/mpdf/index.php?page=Download ) and extract inside anyfolder
2) create sample.php in anyfolder and insert like this:
<?php
include('./mpdf.php');
$mpdf=new mPDF();
$mpdf->WriteHTML('<div style="color:yellow;">SAMPLE TEXT, WITH HTML TAGS Too!</div>');
$mpdf->Output(); die('');
?>
3) then open sample.php in your browser to see the result!
MANY OTHER ONES - Convert HTML + CSS to PDF with PHP?

Categories