Environment: tecnickcom/tcpdf 7.0.6, tc-lib-pdf 8.70.3, PHP 8.5
In TCPDF 7, CSS rules with element/type selectors (body { … }, table { … },
td { … }) inside a <style> block are silently ignored by writeHTML().
Class selectors from the same block are applied fine. TCPDF 6 applied type
selectors, so documents relying on e.g. body { text-align: center } +
table { width: 205mm } lose their entire layout after upgrading, while
class-based rules (.title { font-weight: bold }) keep working — which makes
the regression easy to miss partially.
Reproduce:
$pdf = new TCPDF('P');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->setMargins(0, 0, 0, true);
$pdf->setAutoPageBreak(false, 0);
$pdf->setFont('freesans', '', 14);
$pdf->AddPage();
$html = '<!DOCTYPE html><html><head><style>
body { text-align: center; } /* ignored in 7.x */
table { width: 205mm; } /* ignored in 7.x */
.big { font-size: 1.5em; } /* applied */
</style></head><body>
<table><tr><td class="big">This should be centered in a 205mm-wide table</td></tr></table>
</body></html>';
$pdf->writeHTML($html, true);
$pdf->Output('repro.pdf', 'I');
Expected (TCPDF 6): table is 205mm wide, text centered, .big applied.
Actual (7.0.6): table shrinks to content, text left-aligned; only .big
is applied.
If dropping type-selector support is intentional for the new engine, it would
be worth listing under "Breaking Changes" in the README — currently the docs
state the HTML output is structurally equivalent to legacy.
Environment: tecnickcom/tcpdf 7.0.6, tc-lib-pdf 8.70.3, PHP 8.5
In TCPDF 7, CSS rules with element/type selectors (
body { … },table { … },td { … }) inside a<style>block are silently ignored bywriteHTML().Class selectors from the same block are applied fine. TCPDF 6 applied type
selectors, so documents relying on e.g.
body { text-align: center }+table { width: 205mm }lose their entire layout after upgrading, whileclass-based rules (
.title { font-weight: bold }) keep working — which makesthe regression easy to miss partially.
Reproduce:
Expected (TCPDF 6): table is 205mm wide, text centered,
.bigapplied.Actual (7.0.6): table shrinks to content, text left-aligned; only
.bigis applied.
If dropping type-selector support is intentional for the new engine, it would
be worth listing under "Breaking Changes" in the README — currently the docs
state the HTML output is structurally equivalent to legacy.