Why does TCPDF ignore my inline CSS?

佐手、 提交于 2019-11-27 00:51:41
abhshkdz

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

Hope it helps :)

metalfight - user868766

I used the code you provided, and changed the color to red for 'Visit - www.bookings.7sisters.in' using inline CSS.

See my sample output at https://www.box.com/s/520e9e1f4976802696ec

in my case server added slashes to double quotes - tcpdf ignored attributes like style without warning. so I removed slashes by stripslashes function

well there is a work around that I found :

<h1>Heading<small>Text(is smaller than heading.)</small></h1>

hope this helps someone.

There is no PHP library which supports fully CSS. TCPDF does quite nice job with relatively good performance even for larger strings. Check out examples e.g. 006, 007, 21 or 061.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!