Explore GitHub
Search
Features
Blog
Sign up for free Sign in
Star 41
Fork 8

public psliwa / PdfBundle
Code
Network
Pull R...
README.markdown

PsPdfBundle
This bundle integrates Symfony2 with PHPPdf library. Thanks to this bundle you can easily gen...
in dev environment cache should be off.
markdown_stylesheet_filepath - filepath of stylesheet for markdown parser
markdown...
Speaker Deck: Presentations
Gist: Code snippets
Job board
Documentation
GitHub Help
Developer API
GitHub Flavored Markdown...
Upcoming SlideShare
Loading in …5
×

Crear un Pdf con un bundle en symfony 2

2,464 views

Published on

Tutorial Como crear un PDF desde symfony 2 a partir de un pdf bundle,

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,464
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Crear un Pdf con un bundle en symfony 2

  1. 1. Explore GitHub Search Features Blog Sign up for free Sign in Star 41 Fork 8 public psliwa / PdfBundle Code Network Pull Requests 0 Issues 2 Graphs PHP 1. PHP 100% This bundle integrates Symfony2 with PHPPdf library. — Read more http://ohey.pl Clone in Windows ZIP HTTP SSH Git Read-Only https://github.com/psliwa/PdfBundle.git Read-Only access Tags 0 branch: master Switch branches/tags Filter branches/tags Branches Tags 1.0.x master zf1-in-backend Nothing to show Nothing to show Files Commits Branches 3 71 commits PdfBundle / fix composer.json file latest commit 623579091a psliwa authored 14 days ago Annotation a year ago new @Pdf annotation argument (enableCache), fix DI configuration [psliwa] Controller 7 months agoupdate composer.json, README and examples [psliwa] DependencyInjection a year ago update supported PHPPdf version to 1.1.x branch [psliwa] EventListener a month ago [#28] responses with error code > 299 do not trigger pdf rendering [psliwa] PHPPdf a year ago support for bundle based paths in fonts configuration file and source… [psliwa] Reflection a year ago [#3] fix compatibility to new versions of JMS bundles [psliwa] Resources a year ago support for bundle based paths in fonts configuration file and source… [psliwa] Templating 8 months agofix image location [psliwa] Tests a month ago [#28] responses with error code > 299 do not trigger pdf rendering [psliwa] Twig a year ago pdf_image Twig function [psliwa] 6 months agoreadme update [psliwa] vendor .travis.yml a year ago travis-ci fix [psliwa] CHANGELOG 5 months agoupdate version of PHPPdf in composer file [psliwa] LICENSE 2 years ago initial commit [psliwa] PsPdfBundle.php 2 years ago fix [psliwa] README.markdown6 months agoreadme update [psliwa] composer.json 14 days ago fix composer.json file [psliwa]
  2. 2. README.markdown PsPdfBundle This bundle integrates Symfony2 with PHPPdf library. Thanks to this bundle you can easily generate PDF or image (png, jpg) files. Documentation of PHPPdf you can find on github (README file). Installation 1. If you use composer to resolve dependencies, you can skip 2nd, 3rd and 4th steps. PsPdfBundle requires "minimum-stability" equals to dev. PHPPdf uses zendframework packages, so if you want to use composer, you must add zendframework composer repository to your composer.json file. "eoiois:[ rpstre" { "ye:"opsr, tp" cmoe" "r" "tp/pcae.edrmwr.o/ ul: ht:/akgsznfaeokcm" } , { "ye:"opsr, tp" cmoe" "r" "tp/pcaitog" ul: ht:/akgs.r/ } ] 2. Add this bundle and PHPPdf library to deps file and update vendors: [dBnl] Pfude gtgt/gtu.o/siaPfudegt i=i:/ihbcmplw/dBnl.i tre=bnlsP/dBnl agt/ude/sPfude [HPf PPd] gtgt/gtu.o/siaPPd.i i=i:/ihbcmplw/HPfgt vrinoii/.. eso=rgn11x 3. Download dependencies (for example ZF2) of PHPPdf library. You can skip this step, if your application has had dependency on ZF2 framework and Imagine already. For more details see installation section of PHPPdf documentation. ppvno/HPfvnospp h edrPPd/edr.h 4. Register bundle, PHPPdf, Imagine and ZF libraries in autoloader: /apatla.h /p/uoodpp $odr>eitraepcsary lae-rgseNmsae(ra( 's = _DR_'./edrbnls, P' > _I_./.vno/ude' 'HPf = _DR_'./edrPPd/i' PPd' > _I_./.vno/HPflb, 'mgn'= ary_DR_'./edrPPd/i' _DR_'./edrPPd/i/edrIaielb) Iaie > ra(_I_./.vno/HPflb, _I_./.vno/HPflbvno/mgn/i', 'ed = _DR_'./edrPPd/i/edrZn/irr'/I yuhv ue Z2pcae aray yusol si ti ety Zn' > _I_./.vno/HPflbvno/edlbay,/f o ae sd F akgs led, o hud kp hs nr 'edd'= _DR_'./edrPPd/i/edrZnPflbay, ZnPf > _I_./.vno/HPflbvno/edd/irr' ); ) 5. Register bundle in AppKernel: /apApenlpp /p/pKre.h pbi fnto rgseBnls) ulc ucin eitrude( { rtr ary eun ra( / . / . nwPdBnlsdBnl(, e sPfudePPfude) / . / . ) ; } Configuration All options are optional. #apcni/ofgyl p/ofgcni.m p_d: spf ndsfl:~ oe_ie fnsfl:~ ot_ie cmlxatiue_ie ~ ope_trbtsfl: clr_ie ~ oosfl: ueccei_tlset ~ s_ah_nsyehe: cce ah: tp:~ ye otos ~ pin: mrdw_tlsetflpt:~ akonsyehe_ieah mrdw_ouettmlt_ieah ~ akondcmn_epaeflpt: dcmn_asrtp:~ ouetpre_ye nodes_file - path to file with nodes/tags definitions, internal nodes.xml file from PHPPdf library is used by default fonts_file - path to file with fonts definitions, internal fonts.xml file from PHPPdf library is used by default complex_attributes_file - path to file with complex attributes definitions, internal complex-attributes.xml file from PHPPdf library is used by default colors_file - path to file with default palette of colors, internal colors.xml file from PHPPdf library is used by default cache.type - type of cache, supported are all backend cache from Zend_Cache component (for instance File, Apc, Memcached, Sqlite etc.). File engine is used by default. cache.options - specyfic options for cache engine (for instance "cache_dir" for File engine). cache_dir by default is as same as kernel.cache_dir. use_cache_in_stylesheet - stylesheet maching rules will be cache, if this option is set. In complex stylesheet cache significantly improves performance. Default is true, but
  3. 3. in dev environment cache should be off. markdown_stylesheet_filepath - filepath of stylesheet for markdown parser markdown_document_template_filepath - xml document template form output of markdown parser document_parser_type - default parser type: xml or markdown Images in source document If you want to display image, you must provide absolute path to image file via "src" attribute of image tag. Asset Twig function dosn't work, because it converts image path to relative path according to web directory. To make using of images easier, bundle provides Twig function, that converts image logical name to real, absolute path. Example: <d> pf <yai-ae dnmcpg> <- pfiae'udeaeiaenm.xeso' -> !- d_mg(BnlNm:mg-aeetnin) <m sc"{pfiae'yfnWbofgrtrudebu-ro.n' }"/ ig r={ d_mg(SmoyeCniuaoBnl:learwpg) } > <dnmcpg> /yai-ae <pf /d> Bundle based paths in fonts and document xml file If you want to use custom fonts, you should create your own fonts.xml config file (default fonts filepath is PHPPdfResourcesconfigfonts.xml). To make easier defining fonts paths, bundle based paths are supported. Example: <- sm fnsxlfl -> !- oe ot.m ie <tlcsc"SmBnl:ietf"/ iai r=%oeudefl.t% > "%SomeBundle:file.ttf%" will be replaced by "path/to/SomeBundle/Resources/file.ttf" Example / I cnrle / n otolr /.. /. uePdBnlnoainPf s sPfudeAnttod; /.. /. /* * *@d( Pf) * / pbi fnto hlocin$ae ulc ucin elAto(nm) { $omt=$hs>e(rqet)>e(_omt) fra ti-gt'eus'-gt'fra'; rtr $hs>edrsrnf'oeudeSmCnrle:elAto.sti' $omt,ary eun ti-rne(pit(SmBnl:oeotolrhlocin%.wg, fra) ra( 'ae = $ae nm' > nm, ); ) } / i hlocinhm.wg / n elAto.tlti Hlo{ nm }! el { ae } / i hlocinpfti / n elAto.d.wg <d> pf <yai-ae dnmcpg> Hlo{ nm }! el { ae } <dnmcpg> /yai-ae <pf /d> Bundle automatically detects pdf format (via _format) request and create pdf document from response. Pdf annotation has four optional properties: headers - associative array of specyfic headers stylesheet - pdf stylesheet template file in standard Symfony2 notation ("Bundle:Controller:file.format.engine") documentParserType - type of parser: xml or markdown enableCache - pdf output should by cached? True or false, default: false. Hash (md5) from template and stylesheet content is a cache key, only PHPPdf invocation is cached, controller is always called. GitHub About us Blog Contact & support GitHub Enterprise Site status Applications GitHub for Mac GitHub for Windows GitHub for Eclipse GitHub mobile apps Services Gauges: Web analytics
  4. 4. Speaker Deck: Presentations Gist: Code snippets Job board Documentation GitHub Help Developer API GitHub Flavored Markdown GitHub Pages More Training Students & teachers The Shop Plans & pricing The Octodex © 2013 GitHub Inc. All rights reserved. Terms of Service Privacy Security Something went wrong with that request. Please try again.

×