Why does TCPDF ignore my inline CSS?

TCPDF has a very limited CSS support. It doesn’t support all attributes.

Currently, only the following CSS attributes are supported:

  • font-family
  • font-size
  • font-weight
  • font-style
  • color
  • background-color
  • text-decoration
  • width
  • height
  • text-align

So try removing the other attributes, and tell if it works.

Also, this is an active forum for TCPDF related discussion.

TCPDF Documentation

Alternatives to TCPDF that are definitely worth trying:

domPDF

Key Features

  • handles most CSS 2.1 and a few CSS3 properties, including @import, @media & @page rules
  • supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
  • supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling

domPDF Documentation

Helpful tutorial: http://kyokasuigetsu25.wordpress.com/2011/07/14/how-to-use-dompdf-with-css/

mPDF

Examples (both PHP and generated PDF) can be found here and here.

mPDF Documentation

Leave a Comment