Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG-GRAVITYPDF.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Bugfixes
* Styling a table row or row group, such as `tr.total { font-weight: bold }` or `<thead style="color: #fff">`, did not change the text of its cells, only their background. A `tr`, `thead`, `tbody` or `tfoot` now hands every inherited property to its cells, over the table's and under the cell's own, and a `tbody` rule reaches the rows written straight into a table. A row's `font-size: 80%` is taken of its row group's size, and a cell's of its row's. A row's `currentColor` is its row group's colour, and a cell's is its row's. A `th` stays bold, and is centred only when it inherits no `text-align` from its row, row group or table, as HTML's rendering rules have it. Under the standard `cssMode` only; set `'cssMode' => \Mpdf\CssMode::LEGACY` to keep the old output. [#542] [#655]
* `text-outline-width` with no `text-outline-color` raised an undefined-key warning (`outline-COLOR`) and drew the outline black. The warning is gone in either `cssMode`. In standard mode the outline is now drawn in the colour of the text, as `text-outline-color` is `currentColor` by default, and `text-outline` with a width alone, such as `text-outline: 0.2mm`, which was ignored, outlines the text in its colour too. A text outline in `currentColor`, written or by default, is passed on as the keyword, so a `<span>` of another colour inside the outlined text is outlined in its own colour. Set `'cssMode' => \Mpdf\CssMode::LEGACY` to keep black outlines and to ignore that shorthand. [#552] [#650] [#681]
* A percentage `border-radius` on a block, such as `border-radius: 50%` on a box 40 mm by 12 mm, drew a pill instead of an ellipse. Both radii were taken of the width of the block around it, and then shrunk to fit. A percentage is now of the block's own border box, as in CSS: a horizontal radius of its width and a vertical one of its height, so `50%` draws an ellipse and `10%` a corner a tenth of each side. A block split across pages resolves a vertical percentage against the height of the part on each page. With `autoPadding` on, a percentage radius no longer adds padding, since the box is not known when the padding is set. In both `cssMode`s. [#552] [#586]
* A table split across pages raised `Undefined array key "gradient"` warnings on each later page when the table had a `background-image` from a URL. The image was drawn; the warnings are gone in either `cssMode`. [#552] [#742]

### Images and SVG

Expand Down Expand Up @@ -969,3 +970,4 @@ These changes do not change output.
[#584]: https://github.com/GravityPDF/mpdf/issues/584
[#689]: https://github.com/GravityPDF/mpdf/pull/689
[#609]: https://github.com/GravityPDF/mpdf/issues/609
[#742]: https://github.com/GravityPDF/mpdf/issues/742
2 changes: 1 addition & 1 deletion src/Mpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -23537,7 +23537,7 @@ function _tableWrite(&$table, $split = false, $startrow = 0, $startcol = 0, $spl
// The layers of a list are drawn in their order, so its gradients go in with its images
$gradientSlot = isset($table['background-image']['layers']) ? 2 : 1;
foreach ($this->backgroundLayers($table['background-image']) as $bg) {
if ($bg['gradient'] && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $bg['gradient'])) {
if (!empty($bg['gradient']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $bg['gradient'])) {
$g = $this->gradient->parseMozGradient($bg['gradient']);
if ($g) {
$this->tableBackgrounds[$level * 9 + $gradientSlot][] = ['gradient' => true, 'x' => $bx, 'y' => $by, 'w' => $bw, 'h' => $bh, 'gradtype' => $g['type'], 'stops' => $g['stops'], 'colorspace' => $g['colorspace'], 'coords' => $g['coords'], 'extend' => $g['extend'], 'clippath' => ''];
Expand Down
26 changes: 26 additions & 0 deletions tests/Mpdf/TableBackgroundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class TableBackgroundTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase
{
use PageStreams;
use DrawnStyles;

const RED = '1.000 0.000 0.000 rg';

Expand Down Expand Up @@ -103,4 +104,29 @@ public function testATableWithNoBackgroundAfterAColouredOneIsStillUnaffected()
$this->assertCount(1, $this->redRectangles($this->render($html)));
}

/**
* A table's background image from a URL has no gradient, and the background drawn again on each later page of a
* table split across pages must not expect one: the image is tiled on every page and nothing is raised.
*
* @dataProvider modes
*
* @param string $cssMode
*/
public function testASplitTableWithABackgroundImageDrawsItOnEveryPageWithoutWarnings($cssMode)
{
$html = '<table style="background-image: url(' . $this->backgroundImage() . ')">'
. str_repeat('<tr><td>Row</td><td>Row</td></tr>', 80)
. '</table>';

$pdf = $this->assertDrawsSilently(function (Mpdf $mpdf) use ($html) {
$mpdf->WriteHTML($html);
}, ['cssMode' => $cssMode]);

$pages = $this->pageContents($pdf);
$this->assertGreaterThan(1, count($pages));
foreach ($pages as $page) {
$this->assertStringContainsString('/Pattern cs', $page);
}
}

}