How-to create PDF documents using PHP | Web Development Blog [PDF]

Yes right, the first plan was to write this tutorial about the Zend Framework, but after writing a few rows of code I've

1 downloads 4 Views 9MB Size

Recommend Stories


PDF Download PHP and MySQL Web Development
What you seek is seeking you. Rumi

[PDF] Review PHP and MySQL Web Development
If your life's work can be accomplished in your lifetime, you're not thinking big enough. Wes Jacks

[PDF] PHP and MySQL Web Development
Almost everything will work again if you unplug it for a few minutes, including you. Anne Lamott

PdF Download PHP and MySQL Web Development
It always seems impossible until it is done. Nelson Mandela

[PDF] PHP and MySQL Web Development
Suffering is a gift. In it is hidden mercy. Rumi

PDF Download PHP and MySQL Web Development
Make yourself a priority once in a while. It's not selfish. It's necessary. Anonymous

PDF DOWNLOAD PHP and MySQL Web Development
Live as if you were to die tomorrow. Learn as if you were to live forever. Mahatma Gandhi

PDF PHP and MySQL Web Development
Never wish them pain. That's not who you are. If they caused you pain, they must have pain inside. Wish

PdF PHP and MySQL Web Development
If you feel beautiful, then you are. Even if you don't, you still are. Terri Guillemets

PHP Beyond the Web Pdf
The greatest of richness is the richness of the soul. Prophet Muhammad (Peace be upon him)

Idea Transcript


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { public function Header() { $this->setJPEGQuality(90); $this->Image('logo.png', 120, 10, 75, 0, 'PNG', 'https://www.finalwebsites.com'); } public function Footer() { $this->SetY(-15); $this->SetFont(PDF_FONT_NAME_MAIN, 'I', 8); $this->Cell(0, 10, 'finalwebsites.com - PHP Script Resource, PHP classes and code for web developer', 0, false } public function CreateTextBox($textval, $x = 0, $y, $width = 0, $height = 10, $fontsize = 10, $fontstyle = '', $this->SetXY($x+20, $y); // 20 = margin left $this->SetFont(PDF_FONT_NAME_MAIN, $fontstyle, $fontsize); $this->Cell($width, $height, $textval, 0, false, $align); } }

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

// create a PDF object $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document (meta) information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Olaf Lederer'); $pdf->SetTitle('TCPDF Example'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, tutorial'); // add a page $pdf->AddPage(); // create address box $pdf->CreateTextBox('Customer name Inc.', 0, 55, 80, 10, 10, 'B'); $pdf->CreateTextBox('Mr. Tom Cat', 0, 60, 80, 10, 10); $pdf->CreateTextBox('Street address', 0, 65, 80, 10, 10); $pdf->CreateTextBox('Zip, city name', 0, 70, 80, 10, 10); // invoice title / number $pdf->CreateTextBox('Invoice #201012345', 0, 90, 120, 20, 16); // date, order ref $pdf->CreateTextBox('Date: '.date('Y-m-d'), 0, 100, 0, 10, 10, '', 'R'); $pdf->CreateTextBox('Order ref.: #6765765', 0, 105, 0, 10, 10, '', 'R');

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

// list headers $pdf->CreateTextBox('Quantity', 0, 120, 20, 10, 10, 'B', 'C'); $pdf->CreateTextBox('Product or service', 20, 120, 90, 10, 10, 'B'); $pdf->CreateTextBox('Price', 110, 120, 30, 10, 10, 'B', 'R'); $pdf->CreateTextBox('Amount', 140, 120, 30, 10, 10, 'B', 'R'); $pdf->Line(20, 129, 195, 129); // some example >nulla libero, eu sagittis diam. Aenean egestas //Close and output PDF document $pdf->Output('test.pdf', 'F');

+1

6

Tweet

(https://twitter.c om/share? original_referer =/&text=Create +PDF+docume nts+Online+wit h+TCPDF&url= https://www.we b-developmentblog.com/archi ves/create-pdfdocumentsonline-withtcpdf/&via=final websites)

(https://plus.go ogle.com/share ? url=https%3A% 2F%2Fwww.we b-developmentblog.com%2Far chives%2Fcreat e-pdfdocumentsonline-withtcpdf%2F)

Stumble 3K

(http://www.stu mbleupon.com/ submit? url=https://www .webdevelopmentblog.com/archi ves/create-pdfdocumentsonline-withtcpdf/&title=Cre ate+PDF+docu ments+Online+ with+TCPDF)

Share 25

(https://www.fa cebook.com/sh are.php? u=https%3A%2 F%2Fwww.webdevelopmentblog.com%2Far chives%2Fcreat e-pdfdocumentsonline-withtcpdf%2F)

3K

Share 3

(https://www.lin kedin.com/cws/ share? url=https%3A% 2F%2Fwww.we b-developmentblog.com%2Far chives%2Fcreat e-pdfdocumentsonline-withtcpdf%2F)



SHARES

Õ

1 2 3 4 5 6

1 2 3 4 5

$txt = 'Example of File Attachment. Double click on the icon to open the attached file.'; $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0); // attach an external file $pdf->Annotation(85, 27, 5, 5, 'text file', array('Subtype'=>'FileAttachment', 'Name' =

// create address box $pdf->CreateTextBox($_POST['company'], 0, 55, 80, 10, 10, 'B'); $pdf->CreateTextBox($_POST['contact'], 0, 60, 80, 10, 10); $pdf->CreateTextBox($_POST['address'], 0, 65, 80, 10, 10); $pdf->CreateTextBox($_POST['zipcity'], 0, 70, 80, 10, 10);

$count = 0; $perPage = 5; while ($rows = mysql_fetch_object($result)) { // show the rows here if ($count % $perPage == 0) $pdf->AddPage(); $count++; }

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95

require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { public function Header() { $this->setJPEGQuality(90); $this->Image('../images/tcpdf_cell.png', 120, 10, 75, 0, 'PNG', 'https://www.finalwebsites.com' } public function Footer() { $this->SetY(-15); $this->SetFont(PDF_FONT_NAME_MAIN, 'I', 8); $this->Cell(0, 10, 'finalwebsites.com - PHP Script Resource, PHP classes and code for web developer' } public function CreateTextBox($textval, $x = 0, $y, $width = 0, $height = 10, $fontsize $this->SetXY($x+20, $y); // 20 = margin left $this->SetFont(PDF_FONT_NAME_MAIN, $fontstyle, $fontsize); $this->Cell($width, $height, $textval, 0, false, $align); } } ///////////////////////////////////////// // create a PDF object $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document (meta) information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Olaf Lederer'); $pdf->SetTitle('TCPDF Example'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, tutorial'); // add a page $pdf->AddPage(); // create address box $pdf->CreateTextBox('Customer name Inc.', 0, 55, 80, 10, 10, 'B'); $pdf->CreateTextBox('Mr. Tom Cat', 0, 60, 80, 10, 10); $pdf->CreateTextBox('Street address', 0, 65, 80, 10, 10); $pdf->CreateTextBox('Zip, city name', 0, 70, 80, 10, 10); // invoice title / number $pdf->CreateTextBox('Invoice #201012345', 0, 90, 120, 20, 16); // date, order ref $pdf->CreateTextBox('Date: '.date('Y-m-d'), 0, 100, 0, 10, 10, '', 'R'); $pdf->CreateTextBox('Order ref.: #6765765', 0, 105, 0, 10, 10, '', 'R'); /////////////////////////////////// // list headers $pdf->CreateTextBox('Quantity', 0, 120, 20, 10, 10, 'B', 'C'); $pdf->CreateTextBox('Product or service', 20, 120, 90, 10, 10, 'B'); $pdf->CreateTextBox('Price', 110, 120, 30, 10, 10, 'B', 'R'); $pdf->CreateTextBox('Amount', 140, 120, 30, 10, 10, 'B', 'R'); $pdf->Line(20, 129, 195, 129); // some example rel="nofollow">nulla libero, e //Close and output PDF document $pdf->Output('test.pdf', 'F'); // End of file

1 2 3 4

$pdf->SetFont('Times','',10); $pdf->cell(20,0,"Address3",0,0,''); $pdf->cell(0,0,$address3,0,0,'12'); $pdf->SetFont('Times','',10);

1 $pdf->setXY(80, 85); 2 $pdf->SetFont(PDF_FONT_NAME_MAIN, '', 10); 3 $pdf->MultiCell(110, 10, 'Place here your content (including HTML if you like', 0, 'L', 0, 1

+1

6

Tweet

Stumble 3K

(https://plus.go (https://twitter.c (http://www.stu

Share 25

Share 3

(https://www.fa (https://www.lin

3K

SHARES

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.