SlideShare uma empresa Scribd logo
1 de 43
Baixar para ler offline
PHPConf Taiwan 2012
November 03, 2012 at 10:10.




     Template-Based DOCX,
     DOC & PDF Generation
     with Zend Framework 2.
                  @JonathanMaron
                       E-Mail or Google+.
About Jonathan Maron

   Head of Web Development and Operations.
   I work for a software and hardware
    manufacturer in Taipei, Germany and USA.
   We manufacture digital cameras for
    industrial, scientific and medical applications.
   We author desktop and server software
    components.

    http://www.theimagingsource.com
    http://www.textcontrol.com
New approach to generating
DOCX, DOC, PDF etc. files
 with Zend Framework 2.
Creating PDFs with PHP

   HTML-to-PDF           Programmatic
    approach:              approach:
       domPDF.               Zend_Pdf.
       HtmlToPdf.            PDFlib.
       HTML_ToPDF.           FPDF.
       wkhtmltopdf.          Cpdf.
       etc.                  etc.
Ralf Eggert quote

  “I personally consider
  the current version [of
 Zend_Pdf] to be limited
 in scope. It is extremely
difficult, if not impossible,
     to achieve usable
 results. At the moment,
   developers, including
  myself, are looking for
      alternatives [...]”
PHP Magazin
February 2011 – March 2011, Ralf Eggert.
The template approach.
LiveDocx and Zend Framework 2

   LiveDocx is a SOAP-based document
    generation service.
   ZendService_LiveDocx (New BSD license):
       PHP 5.3 implementation of LiveDocx.
       Easy-to-use PHP API to rich SOAP service.
       Native component of the Zend Framework 2.
   PHP 5 SoapClient and NuSOAP supported.
   All languages with SOAP are supported.
Sounds interesting.
But how does it work?
3 steps of document generation


   STEP 1: In a word processor, create a template
    containing merge-fields.

   STEP 2: Populate merge-fields in PHP.

   STEP 3: Write generated document* to disk.

    * DOCX, DOC, HTML, RTF, PDF, TXT
Document generation process (1)



                    LiveDocx




Template
                                Document



             Data


       Template + Data = Document.
Step 1: Creating a template (2)
Steps 2 & 3: Assign data & create doc
Multiple output formats, one API
Sample 2:
Merging complex data structures.
Repeating blocks (loops)
Sample 3:
Merging image data.
Merging image data
Sample 4:
Exporting to one or
 more image files.
Exporting to image files
Multiple output formats, one API
Working with templates:
  Local vs. remote.
Using local templates




                        Specify template
                        in every request.
Using remote templates




                         Upload template once.




                         Reference template
                         in all subsequent
                         requests.
Supported file formats.
Supported template formats (input)

   DOCX - Office Open XML format.
   DOC - Microsoft Word DOC format.
   RTF - Rich text format.
   TXD - TX Text Control format.
Supported document formats (output)

   DOCX - Office Open XML format.
   DOC - Microsoft Word DOC format.
   HTML - XHTML 1.0 transitional format.
   RTF - Rich text format.
   PDF - Acrobat portable document format.
   TXD - TX Text Control format.
   TXT - ANSI plain text.
Supported image export formats

   Documents can also be exported to images:
       BMP - Bitmap image file format.
       GIF - Graphics interchange format.
       JPG - Joint photographic experts group format.
       PNG - Portable network graphics format.
       TIFF - Tagged image file format.
Supported image import formats

   Images can be imported from:
       BMP - Bitmap image file format.
       GIF - Graphics interchange format.
       JPG - Joint photographic experts group format.
       PNG - Portable network graphics format.
       TIFF - Tagged image file format.
       WMF - Windows meta file format.
Case study:
PHP Unconferences.
PHP Unconferences

   Well established unconferences about PHP.
   PHP Unconference Europe (Manchester, UK):
       1st year: 100 attendees in February 2011.
   PHP Unconference Hamburg (Germany):
       6th year: 320 attendees in August 2012.
   LiveDocx was used to create:
       Attendee badges (approx. 450 units).
       Vote posters (approx. 100 units).
Live demonstrations

   SAMPLE 1: license-agreement

   SAMPLE 2: telephone-bill

   SAMPLE 3: conference-pass

   SAMPLE 4: bitmaps
Get involved! Try it out yourself!

   ZendService_LiveDocx Web Site.
    http://www.phplivedocx.org and http://goo.gl/oXUcf
   Download Demo VMware Virtual Machine
    http://goo.gl/3aAGb        (great way to get started)
   ZendService_LiveDocx Source and Demos.
    https://github.com/jonathanmaron/ZendService_LiveDocx
   LiveDocx Web Site and Blog.
    http://www.livedocx.com
   Sign up for a LiveDocx account.
    https://www.livedocx.com/user/account_registration.aspx
Full-time web developer wanted!

   You love PHP, Zend Framework, HTML
    and Javascript.
   You want to develop web applications with an
    international team of specialists in Germany
    and Taiwan.
   You want to work at our Taipei office
    (Song-Shan District 10555, Taipei City).

   Interested? Talk to me!
Public / Hosted / Cloud

   LiveDocx Free is available for all to use.
    Documentation and registration at www.livedocx.com.


   LiveDocx Premium hosted service is available.
    TWD 1,140.00 per month.

   Cloud-based solutions in the pipeline.
    AWS EC2 and Windows Azure. Pay-as-you-go model.

Mais conteúdo relacionado

Destaque

Phalcon the fastest php framework 阿土伯
Phalcon   the fastest php framework 阿土伯Phalcon   the fastest php framework 阿土伯
Phalcon the fastest php framework 阿土伯Hash Lin
 
kepemimpinan dan karakteristik pekerjaan managerial
kepemimpinan dan karakteristik pekerjaan managerialkepemimpinan dan karakteristik pekerjaan managerial
kepemimpinan dan karakteristik pekerjaan managerialPiter Sadabe
 
Primera castanyada a l’escola pilar mestres
Primera castanyada a l’escola pilar mestresPrimera castanyada a l’escola pilar mestres
Primera castanyada a l’escola pilar mestresMercè Gimeno
 
Lễ tốt nghiệp của học viên tại trường UV ESL
Lễ tốt nghiệp của học viên tại trường UV ESLLễ tốt nghiệp của học viên tại trường UV ESL
Lễ tốt nghiệp của học viên tại trường UV ESLUV ESL Center
 
Developing thinking handouts_2010
Developing thinking handouts_2010Developing thinking handouts_2010
Developing thinking handouts_2010mund123
 
私校退輔簡報
私校退輔簡報私校退輔簡報
私校退輔簡報華強 吳
 
HealthCare Reform Exec Brief - Companies Under 250 Employees
HealthCare Reform Exec Brief - Companies Under 250 EmployeesHealthCare Reform Exec Brief - Companies Under 250 Employees
HealthCare Reform Exec Brief - Companies Under 250 EmployeesPaul (E) Kilzer
 
Keddi csoport
Keddi csoportKeddi csoport
Keddi csoportaromoj
 
Bh europe-01-grossman
Bh europe-01-grossmanBh europe-01-grossman
Bh europe-01-grossmananiba2000
 
Taking notes
Taking notesTaking notes
Taking notesabujumana
 
Kako redizajnom telefonskih govornica unaprijediti turizam?
Kako redizajnom telefonskih govornica unaprijediti turizam?Kako redizajnom telefonskih govornica unaprijediti turizam?
Kako redizajnom telefonskih govornica unaprijediti turizam?Ivana Preiss
 
Middle Earth 12 Board Approval
Middle Earth 12 Board ApprovalMiddle Earth 12 Board Approval
Middle Earth 12 Board Approvalthielmann
 

Destaque (20)

Phalcon the fastest php framework 阿土伯
Phalcon   the fastest php framework 阿土伯Phalcon   the fastest php framework 阿土伯
Phalcon the fastest php framework 阿土伯
 
kepemimpinan dan karakteristik pekerjaan managerial
kepemimpinan dan karakteristik pekerjaan managerialkepemimpinan dan karakteristik pekerjaan managerial
kepemimpinan dan karakteristik pekerjaan managerial
 
Primera castanyada a l’escola pilar mestres
Primera castanyada a l’escola pilar mestresPrimera castanyada a l’escola pilar mestres
Primera castanyada a l’escola pilar mestres
 
Ombres1
Ombres1Ombres1
Ombres1
 
αρχαϊκη εποχη
αρχαϊκη εποχηαρχαϊκη εποχη
αρχαϊκη εποχη
 
Story board for speaking
Story board for speakingStory board for speaking
Story board for speaking
 
Lễ tốt nghiệp của học viên tại trường UV ESL
Lễ tốt nghiệp của học viên tại trường UV ESLLễ tốt nghiệp của học viên tại trường UV ESL
Lễ tốt nghiệp của học viên tại trường UV ESL
 
Developing thinking handouts_2010
Developing thinking handouts_2010Developing thinking handouts_2010
Developing thinking handouts_2010
 
私校退輔簡報
私校退輔簡報私校退輔簡報
私校退輔簡報
 
HealthCare Reform Exec Brief - Companies Under 250 Employees
HealthCare Reform Exec Brief - Companies Under 250 EmployeesHealthCare Reform Exec Brief - Companies Under 250 Employees
HealthCare Reform Exec Brief - Companies Under 250 Employees
 
Catálogo de Productos
Catálogo de ProductosCatálogo de Productos
Catálogo de Productos
 
Keddi csoport
Keddi csoportKeddi csoport
Keddi csoport
 
Bh europe-01-grossman
Bh europe-01-grossmanBh europe-01-grossman
Bh europe-01-grossman
 
Taking notes
Taking notesTaking notes
Taking notes
 
Kako redizajnom telefonskih govornica unaprijediti turizam?
Kako redizajnom telefonskih govornica unaprijediti turizam?Kako redizajnom telefonskih govornica unaprijediti turizam?
Kako redizajnom telefonskih govornica unaprijediti turizam?
 
tagxedo
tagxedotagxedo
tagxedo
 
Middle Earth 12 Board Approval
Middle Earth 12 Board ApprovalMiddle Earth 12 Board Approval
Middle Earth 12 Board Approval
 
Intan softskill
Intan softskillIntan softskill
Intan softskill
 
52342176
5234217652342176
52342176
 
Epic Awards 101
Epic Awards 101Epic Awards 101
Epic Awards 101
 

Semelhante a Phpconf taiwan-2012

Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!Francesco Fullone
 
Federico Feroldi Php In Yahoo
Federico Feroldi Php In YahooFederico Feroldi Php In Yahoo
Federico Feroldi Php In YahooFederico Feroldi
 
PHP and Zend Framework on Windows
PHP and Zend Framework on WindowsPHP and Zend Framework on Windows
PHP and Zend Framework on WindowsShahar Evron
 
shobhit training report (3) (4).pdf report
shobhit training report (3) (4).pdf reportshobhit training report (3) (4).pdf report
shobhit training report (3) (4).pdf reportpoojaranga2911
 
Windows Server and Fast CGI Technologies For PHP
Windows Server and Fast CGI Technologies For PHPWindows Server and Fast CGI Technologies For PHP
Windows Server and Fast CGI Technologies For PHPTim Keller
 
PDF Generation in Rails with Prawn and Prawn-to: John McCaffrey
PDF Generation in Rails with Prawn and Prawn-to: John McCaffreyPDF Generation in Rails with Prawn and Prawn-to: John McCaffrey
PDF Generation in Rails with Prawn and Prawn-to: John McCaffreyJohn McCaffrey
 
Adobe AIR. NativeProcess. FFMPEG. Awesome.
Adobe AIR. NativeProcess. FFMPEG. Awesome.Adobe AIR. NativeProcess. FFMPEG. Awesome.
Adobe AIR. NativeProcess. FFMPEG. Awesome.Joseph Labrecque
 
Plone Integration with eXist-db - Structured Content rocks
Plone Integration with eXist-db - Structured Content rocksPlone Integration with eXist-db - Structured Content rocks
Plone Integration with eXist-db - Structured Content rocksAndreas Jung
 
Php Storm 8 The Most Intelligent php ide
Php Storm 8 The Most Intelligent php idePhp Storm 8 The Most Intelligent php ide
Php Storm 8 The Most Intelligent php ideMindfire Solutions
 
Flex and PHP For the Flash Folks
Flex and PHP For the Flash FolksFlex and PHP For the Flash Folks
Flex and PHP For the Flash Folks10n Software, LLC
 
[Mentor Graphics] A Perforce-based Automatic Document Generation System
[Mentor Graphics] A Perforce-based Automatic Document Generation System[Mentor Graphics] A Perforce-based Automatic Document Generation System
[Mentor Graphics] A Perforce-based Automatic Document Generation SystemPerforce
 
Lotus Symphony has matured quite a bit the past year, but are you taking full...
Lotus Symphony has matured quite a bit the past year, but are you taking full...Lotus Symphony has matured quite a bit the past year, but are you taking full...
Lotus Symphony has matured quite a bit the past year, but are you taking full...John Head
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)Eric Johnson
 
Flash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile developmentFlash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile developmentMihai Corlan
 

Semelhante a Phpconf taiwan-2012 (20)

Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!Federico Feroldi: PHP in Yahoo!
Federico Feroldi: PHP in Yahoo!
 
Federico Feroldi Php In Yahoo
Federico Feroldi Php In YahooFederico Feroldi Php In Yahoo
Federico Feroldi Php In Yahoo
 
unit1 part 1 sem4 php.docx
unit1 part 1 sem4 php.docxunit1 part 1 sem4 php.docx
unit1 part 1 sem4 php.docx
 
PHP and Zend Framework on Windows
PHP and Zend Framework on WindowsPHP and Zend Framework on Windows
PHP and Zend Framework on Windows
 
shobhit training report (3) (4).pdf report
shobhit training report (3) (4).pdf reportshobhit training report (3) (4).pdf report
shobhit training report (3) (4).pdf report
 
Check
CheckCheck
Check
 
Windows Server and Fast CGI Technologies For PHP
Windows Server and Fast CGI Technologies For PHPWindows Server and Fast CGI Technologies For PHP
Windows Server and Fast CGI Technologies For PHP
 
Php documentor
Php documentorPhp documentor
Php documentor
 
PDF Generation in Rails with Prawn and Prawn-to: John McCaffrey
PDF Generation in Rails with Prawn and Prawn-to: John McCaffreyPDF Generation in Rails with Prawn and Prawn-to: John McCaffrey
PDF Generation in Rails with Prawn and Prawn-to: John McCaffrey
 
Adobe AIR. NativeProcess. FFMPEG. Awesome.
Adobe AIR. NativeProcess. FFMPEG. Awesome.Adobe AIR. NativeProcess. FFMPEG. Awesome.
Adobe AIR. NativeProcess. FFMPEG. Awesome.
 
Plone Integration with eXist-db - Structured Content rocks
Plone Integration with eXist-db - Structured Content rocksPlone Integration with eXist-db - Structured Content rocks
Plone Integration with eXist-db - Structured Content rocks
 
Php Storm 8 The Most Intelligent php ide
Php Storm 8 The Most Intelligent php idePhp Storm 8 The Most Intelligent php ide
Php Storm 8 The Most Intelligent php ide
 
Flex and PHP For the Flash Folks
Flex and PHP For the Flash FolksFlex and PHP For the Flash Folks
Flex and PHP For the Flash Folks
 
Adobe AIR & Printing
Adobe AIR & PrintingAdobe AIR & Printing
Adobe AIR & Printing
 
[Mentor Graphics] A Perforce-based Automatic Document Generation System
[Mentor Graphics] A Perforce-based Automatic Document Generation System[Mentor Graphics] A Perforce-based Automatic Document Generation System
[Mentor Graphics] A Perforce-based Automatic Document Generation System
 
Lotus Symphony has matured quite a bit the past year, but are you taking full...
Lotus Symphony has matured quite a bit the past year, but are you taking full...Lotus Symphony has matured quite a bit the past year, but are you taking full...
Lotus Symphony has matured quite a bit the past year, but are you taking full...
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)
 
Firefox-Addons
Firefox-AddonsFirefox-Addons
Firefox-Addons
 
ResumeCurrent
ResumeCurrentResumeCurrent
ResumeCurrent
 
Flash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile developmentFlash Builder for PHP and Mobile development
Flash Builder for PHP and Mobile development
 

Phpconf taiwan-2012

  • 1. PHPConf Taiwan 2012 November 03, 2012 at 10:10. Template-Based DOCX, DOC & PDF Generation with Zend Framework 2. @JonathanMaron E-Mail or Google+.
  • 2. About Jonathan Maron  Head of Web Development and Operations.  I work for a software and hardware manufacturer in Taipei, Germany and USA.  We manufacture digital cameras for industrial, scientific and medical applications.  We author desktop and server software components. http://www.theimagingsource.com http://www.textcontrol.com
  • 3. New approach to generating DOCX, DOC, PDF etc. files with Zend Framework 2.
  • 4. Creating PDFs with PHP  HTML-to-PDF  Programmatic approach: approach:  domPDF.  Zend_Pdf.  HtmlToPdf.  PDFlib.  HTML_ToPDF.  FPDF.  wkhtmltopdf.  Cpdf.  etc.  etc.
  • 5. Ralf Eggert quote “I personally consider the current version [of Zend_Pdf] to be limited in scope. It is extremely difficult, if not impossible, to achieve usable results. At the moment, developers, including myself, are looking for alternatives [...]” PHP Magazin February 2011 – March 2011, Ralf Eggert.
  • 7. LiveDocx and Zend Framework 2  LiveDocx is a SOAP-based document generation service.  ZendService_LiveDocx (New BSD license):  PHP 5.3 implementation of LiveDocx.  Easy-to-use PHP API to rich SOAP service.  Native component of the Zend Framework 2.  PHP 5 SoapClient and NuSOAP supported.  All languages with SOAP are supported.
  • 9. 3 steps of document generation  STEP 1: In a word processor, create a template containing merge-fields.  STEP 2: Populate merge-fields in PHP.  STEP 3: Write generated document* to disk. * DOCX, DOC, HTML, RTF, PDF, TXT
  • 10. Document generation process (1) LiveDocx Template Document Data Template + Data = Document.
  • 11.
  • 12. Step 1: Creating a template (2)
  • 13. Steps 2 & 3: Assign data & create doc
  • 14.
  • 16. Sample 2: Merging complex data structures.
  • 17.
  • 19.
  • 22.
  • 23. Sample 4: Exporting to one or more image files.
  • 26. Working with templates: Local vs. remote.
  • 27. Using local templates Specify template in every request.
  • 28. Using remote templates Upload template once. Reference template in all subsequent requests.
  • 30. Supported template formats (input)  DOCX - Office Open XML format.  DOC - Microsoft Word DOC format.  RTF - Rich text format.  TXD - TX Text Control format.
  • 31. Supported document formats (output)  DOCX - Office Open XML format.  DOC - Microsoft Word DOC format.  HTML - XHTML 1.0 transitional format.  RTF - Rich text format.  PDF - Acrobat portable document format.  TXD - TX Text Control format.  TXT - ANSI plain text.
  • 32. Supported image export formats  Documents can also be exported to images:  BMP - Bitmap image file format.  GIF - Graphics interchange format.  JPG - Joint photographic experts group format.  PNG - Portable network graphics format.  TIFF - Tagged image file format.
  • 33. Supported image import formats  Images can be imported from:  BMP - Bitmap image file format.  GIF - Graphics interchange format.  JPG - Joint photographic experts group format.  PNG - Portable network graphics format.  TIFF - Tagged image file format.  WMF - Windows meta file format.
  • 35. PHP Unconferences  Well established unconferences about PHP.  PHP Unconference Europe (Manchester, UK):  1st year: 100 attendees in February 2011.  PHP Unconference Hamburg (Germany):  6th year: 320 attendees in August 2012.  LiveDocx was used to create:  Attendee badges (approx. 450 units).  Vote posters (approx. 100 units).
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. Live demonstrations  SAMPLE 1: license-agreement  SAMPLE 2: telephone-bill  SAMPLE 3: conference-pass  SAMPLE 4: bitmaps
  • 41. Get involved! Try it out yourself!  ZendService_LiveDocx Web Site. http://www.phplivedocx.org and http://goo.gl/oXUcf  Download Demo VMware Virtual Machine http://goo.gl/3aAGb (great way to get started)  ZendService_LiveDocx Source and Demos. https://github.com/jonathanmaron/ZendService_LiveDocx  LiveDocx Web Site and Blog. http://www.livedocx.com  Sign up for a LiveDocx account. https://www.livedocx.com/user/account_registration.aspx
  • 42. Full-time web developer wanted!  You love PHP, Zend Framework, HTML and Javascript.  You want to develop web applications with an international team of specialists in Germany and Taiwan.  You want to work at our Taipei office (Song-Shan District 10555, Taipei City).  Interested? Talk to me!
  • 43. Public / Hosted / Cloud  LiveDocx Free is available for all to use. Documentation and registration at www.livedocx.com.  LiveDocx Premium hosted service is available. TWD 1,140.00 per month.  Cloud-based solutions in the pipeline. AWS EC2 and Windows Azure. Pay-as-you-go model.