Closed UweKeim closed 7 years ago
Same is true for the next if
condition just below the previous one:
Instead of
if ($fill = $style->fill) {
You should write
if (($fill = $style->fill) && $fill !== "none") {
Even afer adding this check, an SVG image of mine caused an error in the very next line:
$canvas->setColor(array($fill[0]/255, $fill[1]/255, $fill[2]/255), true);
Because $fill
was set to the value "black
".
It seems that there is a function Style::parseColor()
which translates values like "black
" to their hex values.
I'm not sure, why SurfaceCpdf.php does not use this parse function.
My suggestion:
Please make the erroneous line work for PHP 7.1, e.g. by using the parseColor
function.
I also get errors in the parseColor
function in Styles.php:
if ($color[0] === "#") {
This failed for $color
being an empty string with an error
Uninitialized string offset: 0
I'm not sure whether the SVG stuff was ever tested with PHP 7.1, or whether I'm simply completely on the wrong track.
Same errors here: vendor/phenx/php-svg-lib/src/Svg/Surface/SurfaceCpdf.php. \Svg\Surface\SurfaceCpdf::setStyle
if ($stroke = $style->stroke && is_array($style->stroke)) {
$canvas->setStrokeColor(array($stroke[0]/255, $stroke[1]/255, $stroke[2]/255), true);
}
if ($fill = $style->fill && is_array($style->fill)) {
$canvas->setColor(array($fill[0]/255, $fill[1]/255, $fill[2]/255), true);
}
I think this is solved by 34b53c9a149cb7fd978d3d9be9879ee6607fa198
SurfaceCpdf.php, line 379 reads:
Unfortunately this breaks when
$stroke
is "none
" which was the case for an image of mine.In my opinion, it should read like in SurfacePDFLib.php, line 318:
I discovered that this breaks for PHP 7.1 (not 7.0) with the error
because the next line after the
if
condition fails:I'm not sure what the exact difference between these two files is.
My suggestion:
Please add the check condition for "
none
".