PDFs à la volée avec TCPDF

  • View
    2.455

  • Download
    1

  • Category

    Internet

Preview:

Citation preview

TCPDFPDFs à la volée avec

@jennybeaumont#wptech

PDF

Portable Document Format

Portable Document Format

PDF• Développé par Adobe• 1ère sortie 1993• Format propriétaire jusqu’en 2008• ISO TC 171 SC 2 WG 8 (v1.7)

“ La spécificité du PDF est de préserver la mise en forme d’un fichier– polices d'écritures, images, objets graphiques, etc. – telle qu'elle a été définie par son auteur, et cela quels que soient le logiciel, le système d'exploitation et l'ordinateur utilisés pour l’imprimer ou le visualiser. 

https://fr.wikipedia.org/wiki/Portable_Document_Format

• Typos intégrées (ou pas !)• Photos / Graphiques vectoriels• Pagination• Codes à barres / QR• Signatures électroniques • Formulaires dynamiques• Extensible XML, javascript

Document vivant

• Factures• Billets de train / avion• eBooks• CVs, courriers• Impôts

Le PDF est partout

• Quels usages ?• Quelles considérations ?• Quelles contraintes ?

PDF + WP

Le défi• Mise en page complexe• CPT, taxonomies, champs

personnalisés• Aucune page

correspondante• Multilingue

Limitations• Peu d’options pour la mise en

page• Pas d’options pour inclure des

champs personnalisés• Sortie uniquement pour la page

active

<code>

</code>

• Abordable en simple HTML (comme pour un template email)

• Certaines contraintes de CSS• Difficultés dans le maitrise de la conversion

des unités de mesure des images

CONCLUSIONS

Le défi• Typos intégrées• SVG avec user préfs• Taille adaptée aux images• Marques de découpe• Compatible

WooCommerce

Solutions alternatives• PDFLib (sous licence)

http://www.pdflib.com/fileadmin/pdflib/pdf/purchase_order/PDFlib-9-purchase-order.pdf

• FPDFhttp://www.fpdf.org

• DOMPDF https://github.com/dompdf/dompdf

• wkhtmltopdfhttp://wkhtmltopdf.org/

TCPDF• Class PHP open source

http://www.tcpdf.org/• Développé par Nicola Asuni (2001) • SourceForge / GitHub 6.0.090 (août 2014)• Active v6.2.12 (sept 2015)

Fonctionnalités principales• No external libraries are required for the basic functions;• All standard page formats, custom page formats, custom

margins and units of measure;• UTF-8 Unicode and Right-To-Left languages;• TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType,

Type1 and CID-0 fonts;• Font subsetting;• Methods to publish some XHTML + CSS code, Javascript and

Forms;• Images, graphic (geometric figures) and transformation

methods;• Supports JPEG, PNG and SVG images natively• 1D and 2D barcodes• ICC Color Profiles, Grayscale, RGB, CMYK, Spot Colors and

Transparencies;• Automatic page header and footer management;• Document encryption up to 256 bit and digital signature

certifications;

• Transactions to UNDO commands;• PDF annotations, including links, text and file attachments;• Ttext rendering modes (fill, stroke and clipping);• Multiple columns mode;• No-write page regions;• Bookmarks and table of content;• Text hyphenation;• Text stretching and spacing (tracking/kerning);• Automatic page break, line break and text alignments including

justification;• Automatic page numbering and page groups;• Move and delete pages;• Page compression (requires php-zlib extension);• XOBject templates;• PDF/A-1b (ISO 19005-1:2005) support.

<code>

</code>

CONCLUSIONS• Toutes les typos ne sont pas égales• Contraintes dans la taille des SVGs• Certaines incompatibilités avec des tierces

parties

Extensions WP pour démarrer• WP Post to PDF Enhanced

https://wordpress.org/plugins/wp-post-to-pdf-enhanced/

• TCPDF Libraryhttps://wordpress.org/plugins/tcpdf/

Ressources• https://en.wikipedia.org/wiki/Portable_Document_Format• https://en.wikipedia.org/wiki/

List_of_PDF_software#Development_libraries• http://www.tcpdf.org/• http://fonts.snm-portal.com• http://www.pdfa.org/2015/06/what-will-pdf-2-0-bring/• http://www.jennybeaumont.com/testing-tcpdf-css/

5-6 février #wcparis

@jennybeaumont#wptech

Recommended