SlideShare una empresa de Scribd logo
1 de 22
PHP to pdf files May 7,2009 By Eric Michalsen [email_address]
WHAT? PHP to pdf files, dynamically cool stuff!
Why in the world would you want to do that?? pfd's are cool, fun, secure, scary, pain in the butt...
Cody says “Hmmm, I'm intrigued. Tell me more.”
Tools To Use: TCPDF www.tcpdf.org TCPDF project was started in 2002 and now it is  freely used all over the world by millions of people.  TCPDF is a Free Libre Open Source Software (FLOSS).
- no external libraries are required for the basic functions; - supports all ISO page formats; - supports custom page formats, margins and units of measure; - supports UTF-8 Unicode and Right-To-Left languages; - supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts; - supports document encryption; - includes methods to publish some (x)HTML code; - includes graphic (geometric) and transformation methods; - includes Javascript and forms support; blah blah blah... Copy/Paste from their website...
Cody says “ROCK ON! This is going to be easy!”
RTFM Follow the installation instructions. Seriously.  If I can do it, so can you! Most of the examples in this presentation are bastardized from the tcpdf.org site.
<? $dir_file = &quot;files/&quot;.$file; require_once('config/lang/eng.php'); require_once('tcpdf.php'); class MYPDF extends TCPDF  { public function LoadData($file)  { $lines=file($file); $data=array(); foreach($lines as $line)‏ { $data[]=explode(';',chop($line)); } return $data; } public function ColoredTable($header,$data)  { $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetDrawColor(128,0,0); $this->SetLineWidth(.3); $this->SetFont('','B'); $w=array(40,167,30,30); for($i=0;$i<count($header);$i++)‏ $this->Cell($w[$i],7,$header[$i],1,0,'C',1); $this->Ln(); $this->SetFillColor(224,235,255); $this->SetTextColor(0); $this->SetFont(''); $fill=0; foreach($data as $row)  { $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);   $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);   $this->Cell($w[2],6,$row[2],'LR',0,'R',$fill);   $this->Cell($w[3],6,$row[3],'LR',0,'R',$fill);  $this->Ln();   $fill=!$fill; } $this->Cell(array_sum($w),0,'','T'); } } $pdf = new MYPDF(PDF_PAGE_ORIENTATION,   PDF_UNIT,   PDF_PAGE_FORMAT, true);  $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(&quot;Eric Michalsen&quot;); $pdf->SetTitle(&quot;TrendEyes  www.trendeyes.com&quot;); $pdf->SetSubject(&quot;PDF Report&quot;); $pdf->SetKeywords(&quot;PDF Report&quot;); $pdf->SetHeaderData(PDF_HEADER_LOGO,    PDF_HEADER_LOGO_WIDTH,    PDF_HEADER_TITLE,    PDF_HEADER_STRING); $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);  $pdf->setLanguageArray($l);  $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont(&quot;helvetica&quot;, &quot;&quot;, 8); $header=array('Metric','Detail','Description','Alternate'); $data=$pdf->LoadData($dir_file); $pdf->ColoredTable($header,$data); $pdf->Output(&quot;report.pdf&quot;);  ?>
“ Hey, I thought you said this would be easy!”
Step 1 :: Hello World <?PHP //////////////////////////// ///  Include the TCPDF files //////////////////////////// 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);   $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Eric Michalsen'); $pdf->SetTitle('Example 1'); $pdf->SetSubject('Western Suburb PHP Meetup'); $pdf->SetKeywords('PHP, PDF, example');  $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);  $pdf->setLanguageArray($l);  $pdf->SetFont('times', 'BI', 20); $pdf->AddPage(); $pdf->Cell(0, 10, 'Hello World', 1, 1, 'C'); $pdf->Output('example.pdf', 'I');  ?>
 
<?PHP require_once('config/lang/eng.php'); require_once('tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Eric Michalsen'); $pdf->SetTitle('example 2'); $pdf->SetSubject('Image'); $pdf->SetKeywords('TCPDF, PDF, example'); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);  $pdf->setLanguageArray($l);  $pdf->AddPage(); $pdf->setJPEGQuality(75); $pdf->Image('images/lightning.jpg', 50, 50, 100, 150, '', 'http://www.foxvalleycp.com', '', true, 150); $pdf->Output('2.pdf', 'I'); ?>
 
<?php require_once('config/lang/eng.php'); require_once('tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Eric Michalsen'); $pdf->SetTitle('example 3'); $pdf->SetSubject('hmmmm...pie'); $pdf->SetKeywords('TCPDF, PDF, example'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->SetFont('helvetica', '', 14); $pdf->AddPage(); $xc = 70;  // from left $yc = 70;  // from top $r = 50;  // radius $pdf->SetFillColor(120, 120, 255); // blue $pdf->PieSector($xc, $yc, $r, 0, 90); //x,y,r,starting,ending degrees $pdf->SetFillColor(120, 255, 120); // green $pdf->PieSector($xc, $yc, $r, 90, 100); $pdf->SetFillColor(255, 120, 120); // red $pdf->PieSector($xc, $yc, $r, 130, 270); $pdf->Output('3.pdf', 'I'); ?>
 
$xc = 70;  $yc = 70;  $r = 50;  // text annotation $pdf->Annotation(100, 10, 20, 10, &quot;First LineSecond Line&quot;,  array('Subtype'=>'Text',  'Name' => 'Comment',  'T' => '90% Blue',  'Subj' => 'example',  'C' => array(255, 255, 0))); $pdf->SetFillColor(120, 120, 255); // blue $pdf->PieSector($xc, $yc, $r, 0, 90); //x,y,r,starting,ending degrees hmmm....pie ...but what does it mean? We Need Annotation Baby!
Mouse Over Fancy Stuff
$pdf->SetFillColor(120, 120, 255); // blue $pdf->PieSector($xc, $yc, $r, 0, 90); //x,y,r,starting,ending degrees $pdf->SetFillColor(120, 255, 120); // green $pdf->PieSector($xc, $yc, $r, 90, 100); $pdf->SetFillColor(255, 120, 120); // red $pdf->PieSector($xc, $yc, $r, 130, 270); $pdf->Text(100, 20, '90% is Blue'); $pdf->Text(130, 75, '10% is Green'); $pdf->Text(20, 125, '82% is Red'); ...or just plain text...
 
end
Eric Michalsen [email_address] Fox Valley Computing Professionals www.foxvalleycp.com Twitter #FVCP

Más contenido relacionado

Destacado

Cool A*S PIX
Cool A*S PIXCool A*S PIX
Cool A*S PIXtrippa
 
Appendix B Community Outreach Report Nov 30
Appendix B   Community Outreach Report Nov 30Appendix B   Community Outreach Report Nov 30
Appendix B Community Outreach Report Nov 30city of dania beach
 
17 Jan
17 Jan17 Jan
17 Janepaper
 
14jun nas
14jun nas14jun nas
14jun nasepaper
 
Wie snackt in foodservice meer mof v
Wie snackt in foodservice meer mof vWie snackt in foodservice meer mof v
Wie snackt in foodservice meer mof vRien De Koning
 
Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...
Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...
Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...Dmitry Karasev
 
February 2011 Newsletter
February 2011 NewsletterFebruary 2011 Newsletter
February 2011 NewsletterKabir Luthra
 
7jun nas
7jun nas7jun nas
7jun nasepaper
 
TIM Day - Stefano De Angelis
TIM Day - Stefano De AngelisTIM Day - Stefano De Angelis
TIM Day - Stefano De AngelisTIM RI
 
12jan Aceh
12jan Aceh12jan Aceh
12jan Acehepaper
 
The of Social Media - Women in Management
The of Social Media - Women in ManagementThe of Social Media - Women in Management
The of Social Media - Women in ManagementThomas Clifford
 
Edisi 21 Feb Medan
Edisi 21 Feb MedanEdisi 21 Feb Medan
Edisi 21 Feb Medanepaper
 
201110 vujade shift-happened
201110 vujade shift-happened201110 vujade shift-happened
201110 vujade shift-happenedVujàdé
 
Bardotti gabriela ppt
Bardotti gabriela pptBardotti gabriela ppt
Bardotti gabriela pptGabi Bardotti
 

Destacado (18)

Cool A*S PIX
Cool A*S PIXCool A*S PIX
Cool A*S PIX
 
Appendix B Community Outreach Report Nov 30
Appendix B   Community Outreach Report Nov 30Appendix B   Community Outreach Report Nov 30
Appendix B Community Outreach Report Nov 30
 
Is There Sun Behind Those Clouds
Is There Sun Behind Those CloudsIs There Sun Behind Those Clouds
Is There Sun Behind Those Clouds
 
17 Jan
17 Jan17 Jan
17 Jan
 
Park Plantings
Park PlantingsPark Plantings
Park Plantings
 
Tackk demo slides
Tackk demo slidesTackk demo slides
Tackk demo slides
 
14jun nas
14jun nas14jun nas
14jun nas
 
Wie snackt in foodservice meer mof v
Wie snackt in foodservice meer mof vWie snackt in foodservice meer mof v
Wie snackt in foodservice meer mof v
 
Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...
Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...
Презентация Фонда на IV Евразийском конгрессе Дерматологии, Косметологии и Эс...
 
February 2011 Newsletter
February 2011 NewsletterFebruary 2011 Newsletter
February 2011 Newsletter
 
7jun nas
7jun nas7jun nas
7jun nas
 
TIM Day - Stefano De Angelis
TIM Day - Stefano De AngelisTIM Day - Stefano De Angelis
TIM Day - Stefano De Angelis
 
12jan Aceh
12jan Aceh12jan Aceh
12jan Aceh
 
The of Social Media - Women in Management
The of Social Media - Women in ManagementThe of Social Media - Women in Management
The of Social Media - Women in Management
 
Edisi 21 Feb Medan
Edisi 21 Feb MedanEdisi 21 Feb Medan
Edisi 21 Feb Medan
 
201110 vujade shift-happened
201110 vujade shift-happened201110 vujade shift-happened
201110 vujade shift-happened
 
Bardotti gabriela ppt
Bardotti gabriela pptBardotti gabriela ppt
Bardotti gabriela ppt
 
Wcf routing kt
Wcf routing ktWcf routing kt
Wcf routing kt
 

Más de Straight North

Website Speed :: Fox Valley Computing Professionals, September 2014
Website Speed :: Fox Valley Computing Professionals, September 2014Website Speed :: Fox Valley Computing Professionals, September 2014
Website Speed :: Fox Valley Computing Professionals, September 2014Straight North
 
FVCP Advanced Google Anlytics for landing pages
FVCP Advanced Google Anlytics for landing pagesFVCP Advanced Google Anlytics for landing pages
FVCP Advanced Google Anlytics for landing pagesStraight North
 
FVCP Google Analytics Setup and Use for landing pages
FVCP Google Analytics Setup and Use for landing pagesFVCP Google Analytics Setup and Use for landing pages
FVCP Google Analytics Setup and Use for landing pagesStraight North
 
FVCP Splunk Presentation
FVCP Splunk PresentationFVCP Splunk Presentation
FVCP Splunk PresentationStraight North
 
Bitly Presentation Ron Pringle
Bitly Presentation   Ron PringleBitly Presentation   Ron Pringle
Bitly Presentation Ron PringleStraight North
 
Building Your Toastmasters Online
Building Your Toastmasters OnlineBuilding Your Toastmasters Online
Building Your Toastmasters OnlineStraight North
 
Drupal Presentation for CBEID
Drupal Presentation for CBEIDDrupal Presentation for CBEID
Drupal Presentation for CBEIDStraight North
 
Fvcp Presentation Cbeid Sugar M
Fvcp Presentation Cbeid Sugar MFvcp Presentation Cbeid Sugar M
Fvcp Presentation Cbeid Sugar MStraight North
 
New Trends in SEO by FVCP by the CBEID
New Trends in SEO by FVCP by the CBEIDNew Trends in SEO by FVCP by the CBEID
New Trends in SEO by FVCP by the CBEIDStraight North
 
Fvcp Presentation Openoffice
Fvcp Presentation OpenofficeFvcp Presentation Openoffice
Fvcp Presentation OpenofficeStraight North
 
Fvcp Presentation Gimp
Fvcp Presentation GimpFvcp Presentation Gimp
Fvcp Presentation GimpStraight North
 
Fvcp Presentation 0909 Pete Du Melle
Fvcp Presentation 0909 Pete Du MelleFvcp Presentation 0909 Pete Du Melle
Fvcp Presentation 0909 Pete Du MelleStraight North
 
Fvcp Presentation 0909 (Ubuntu)
Fvcp Presentation 0909 (Ubuntu)Fvcp Presentation 0909 (Ubuntu)
Fvcp Presentation 0909 (Ubuntu)Straight North
 
August 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle TwitterAugust 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle TwitterStraight North
 
August 10th, 2009 Tom Rogers YouTube
August 10th, 2009 Tom Rogers YouTubeAugust 10th, 2009 Tom Rogers YouTube
August 10th, 2009 Tom Rogers YouTubeStraight North
 
August 10th, 2009 Dan Day ifbyphone
August 10th, 2009 Dan Day ifbyphoneAugust 10th, 2009 Dan Day ifbyphone
August 10th, 2009 Dan Day ifbyphoneStraight North
 
August 10th, 2009 Mike Cruezer Twitter
August 10th, 2009 Mike Cruezer TwitterAugust 10th, 2009 Mike Cruezer Twitter
August 10th, 2009 Mike Cruezer TwitterStraight North
 
Fvcp Googleadwords July13
Fvcp Googleadwords July13Fvcp Googleadwords July13
Fvcp Googleadwords July13Straight North
 

Más de Straight North (20)

Website Speed :: Fox Valley Computing Professionals, September 2014
Website Speed :: Fox Valley Computing Professionals, September 2014Website Speed :: Fox Valley Computing Professionals, September 2014
Website Speed :: Fox Valley Computing Professionals, September 2014
 
FVCP Advanced Google Anlytics for landing pages
FVCP Advanced Google Anlytics for landing pagesFVCP Advanced Google Anlytics for landing pages
FVCP Advanced Google Anlytics for landing pages
 
FVCP Google Analytics Setup and Use for landing pages
FVCP Google Analytics Setup and Use for landing pagesFVCP Google Analytics Setup and Use for landing pages
FVCP Google Analytics Setup and Use for landing pages
 
FVCP Splunk Presentation
FVCP Splunk PresentationFVCP Splunk Presentation
FVCP Splunk Presentation
 
Bitly Presentation Ron Pringle
Bitly Presentation   Ron PringleBitly Presentation   Ron Pringle
Bitly Presentation Ron Pringle
 
Attention Wizard
Attention WizardAttention Wizard
Attention Wizard
 
Fvc Pbob20100208
Fvc Pbob20100208Fvc Pbob20100208
Fvc Pbob20100208
 
Building Your Toastmasters Online
Building Your Toastmasters OnlineBuilding Your Toastmasters Online
Building Your Toastmasters Online
 
Drupal Presentation for CBEID
Drupal Presentation for CBEIDDrupal Presentation for CBEID
Drupal Presentation for CBEID
 
Fvcp Presentation Cbeid Sugar M
Fvcp Presentation Cbeid Sugar MFvcp Presentation Cbeid Sugar M
Fvcp Presentation Cbeid Sugar M
 
New Trends in SEO by FVCP by the CBEID
New Trends in SEO by FVCP by the CBEIDNew Trends in SEO by FVCP by the CBEID
New Trends in SEO by FVCP by the CBEID
 
Fvcp Presentation Openoffice
Fvcp Presentation OpenofficeFvcp Presentation Openoffice
Fvcp Presentation Openoffice
 
Fvcp Presentation Gimp
Fvcp Presentation GimpFvcp Presentation Gimp
Fvcp Presentation Gimp
 
Fvcp Presentation 0909 Pete Du Melle
Fvcp Presentation 0909 Pete Du MelleFvcp Presentation 0909 Pete Du Melle
Fvcp Presentation 0909 Pete Du Melle
 
Fvcp Presentation 0909 (Ubuntu)
Fvcp Presentation 0909 (Ubuntu)Fvcp Presentation 0909 (Ubuntu)
Fvcp Presentation 0909 (Ubuntu)
 
August 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle TwitterAugust 10th, 2009 Pete De Mulle Twitter
August 10th, 2009 Pete De Mulle Twitter
 
August 10th, 2009 Tom Rogers YouTube
August 10th, 2009 Tom Rogers YouTubeAugust 10th, 2009 Tom Rogers YouTube
August 10th, 2009 Tom Rogers YouTube
 
August 10th, 2009 Dan Day ifbyphone
August 10th, 2009 Dan Day ifbyphoneAugust 10th, 2009 Dan Day ifbyphone
August 10th, 2009 Dan Day ifbyphone
 
August 10th, 2009 Mike Cruezer Twitter
August 10th, 2009 Mike Cruezer TwitterAugust 10th, 2009 Mike Cruezer Twitter
August 10th, 2009 Mike Cruezer Twitter
 
Fvcp Googleadwords July13
Fvcp Googleadwords July13Fvcp Googleadwords July13
Fvcp Googleadwords July13
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 

Php2pdf

  • 1. PHP to pdf files May 7,2009 By Eric Michalsen [email_address]
  • 2. WHAT? PHP to pdf files, dynamically cool stuff!
  • 3. Why in the world would you want to do that?? pfd's are cool, fun, secure, scary, pain in the butt...
  • 4. Cody says “Hmmm, I'm intrigued. Tell me more.”
  • 5. Tools To Use: TCPDF www.tcpdf.org TCPDF project was started in 2002 and now it is freely used all over the world by millions of people. TCPDF is a Free Libre Open Source Software (FLOSS).
  • 6. - no external libraries are required for the basic functions; - supports all ISO page formats; - supports custom page formats, margins and units of measure; - supports UTF-8 Unicode and Right-To-Left languages; - supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts; - supports document encryption; - includes methods to publish some (x)HTML code; - includes graphic (geometric) and transformation methods; - includes Javascript and forms support; blah blah blah... Copy/Paste from their website...
  • 7. Cody says “ROCK ON! This is going to be easy!”
  • 8. RTFM Follow the installation instructions. Seriously. If I can do it, so can you! Most of the examples in this presentation are bastardized from the tcpdf.org site.
  • 9. <? $dir_file = &quot;files/&quot;.$file; require_once('config/lang/eng.php'); require_once('tcpdf.php'); class MYPDF extends TCPDF { public function LoadData($file) { $lines=file($file); $data=array(); foreach($lines as $line)‏ { $data[]=explode(';',chop($line)); } return $data; } public function ColoredTable($header,$data) { $this->SetFillColor(255,0,0); $this->SetTextColor(255); $this->SetDrawColor(128,0,0); $this->SetLineWidth(.3); $this->SetFont('','B'); $w=array(40,167,30,30); for($i=0;$i<count($header);$i++)‏ $this->Cell($w[$i],7,$header[$i],1,0,'C',1); $this->Ln(); $this->SetFillColor(224,235,255); $this->SetTextColor(0); $this->SetFont(''); $fill=0; foreach($data as $row) { $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill); $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill); $this->Cell($w[2],6,$row[2],'LR',0,'R',$fill); $this->Cell($w[3],6,$row[3],'LR',0,'R',$fill); $this->Ln(); $fill=!$fill; } $this->Cell(array_sum($w),0,'','T'); } } $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor(&quot;Eric Michalsen&quot;); $pdf->SetTitle(&quot;TrendEyes www.trendeyes.com&quot;); $pdf->SetSubject(&quot;PDF Report&quot;); $pdf->SetKeywords(&quot;PDF Report&quot;); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont(&quot;helvetica&quot;, &quot;&quot;, 8); $header=array('Metric','Detail','Description','Alternate'); $data=$pdf->LoadData($dir_file); $pdf->ColoredTable($header,$data); $pdf->Output(&quot;report.pdf&quot;); ?>
  • 10. “ Hey, I thought you said this would be easy!”
  • 11. Step 1 :: Hello World <?PHP //////////////////////////// /// Include the TCPDF files //////////////////////////// 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); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Eric Michalsen'); $pdf->SetTitle('Example 1'); $pdf->SetSubject('Western Suburb PHP Meetup'); $pdf->SetKeywords('PHP, PDF, example'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->SetFont('times', 'BI', 20); $pdf->AddPage(); $pdf->Cell(0, 10, 'Hello World', 1, 1, 'C'); $pdf->Output('example.pdf', 'I'); ?>
  • 12.  
  • 13. <?PHP require_once('config/lang/eng.php'); require_once('tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Eric Michalsen'); $pdf->SetTitle('example 2'); $pdf->SetSubject('Image'); $pdf->SetKeywords('TCPDF, PDF, example'); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->AddPage(); $pdf->setJPEGQuality(75); $pdf->Image('images/lightning.jpg', 50, 50, 100, 150, '', 'http://www.foxvalleycp.com', '', true, 150); $pdf->Output('2.pdf', 'I'); ?>
  • 14.  
  • 15. <?php require_once('config/lang/eng.php'); require_once('tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Eric Michalsen'); $pdf->SetTitle('example 3'); $pdf->SetSubject('hmmmm...pie'); $pdf->SetKeywords('TCPDF, PDF, example'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->SetFont('helvetica', '', 14); $pdf->AddPage(); $xc = 70; // from left $yc = 70; // from top $r = 50; // radius $pdf->SetFillColor(120, 120, 255); // blue $pdf->PieSector($xc, $yc, $r, 0, 90); //x,y,r,starting,ending degrees $pdf->SetFillColor(120, 255, 120); // green $pdf->PieSector($xc, $yc, $r, 90, 100); $pdf->SetFillColor(255, 120, 120); // red $pdf->PieSector($xc, $yc, $r, 130, 270); $pdf->Output('3.pdf', 'I'); ?>
  • 16.  
  • 17. $xc = 70; $yc = 70; $r = 50; // text annotation $pdf->Annotation(100, 10, 20, 10, &quot;First LineSecond Line&quot;, array('Subtype'=>'Text', 'Name' => 'Comment', 'T' => '90% Blue', 'Subj' => 'example', 'C' => array(255, 255, 0))); $pdf->SetFillColor(120, 120, 255); // blue $pdf->PieSector($xc, $yc, $r, 0, 90); //x,y,r,starting,ending degrees hmmm....pie ...but what does it mean? We Need Annotation Baby!
  • 19. $pdf->SetFillColor(120, 120, 255); // blue $pdf->PieSector($xc, $yc, $r, 0, 90); //x,y,r,starting,ending degrees $pdf->SetFillColor(120, 255, 120); // green $pdf->PieSector($xc, $yc, $r, 90, 100); $pdf->SetFillColor(255, 120, 120); // red $pdf->PieSector($xc, $yc, $r, 130, 270); $pdf->Text(100, 20, '90% is Blue'); $pdf->Text(130, 75, '10% is Green'); $pdf->Text(20, 125, '82% is Red'); ...or just plain text...
  • 20.  
  • 21. end
  • 22. Eric Michalsen [email_address] Fox Valley Computing Professionals www.foxvalleycp.com Twitter #FVCP