I'd like to create a vector PDF using an SVG string. But ImageMagick draw function always returns 'unable to draw image' 500 error.
$image = new \Imagick();
$draw = new \ImagickDraw();
$draw->setVectorGraphics('<root>'.$svg.'</root>');
$image->newImage(1052, 697, $bg);
$image->setColorspace(\Imagick::COLORSPACE_CMYK);
$image->setImageResolution(300,300);
$image->setImageFormat('pdf');
$image->drawImage($draw);
file_put_contents('image.pdf', $image);
I tried with just simple drawings, not from SVG source, that didn't work either.
Hope someone can help. Thanks
My SVG:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1052" height="697" style="background-color: #fff" viewBox="0 0 1052 697" xml:space="preserve">
<desc>Created with Fabric.js 1.6.6</desc>
<defs></defs>
<line x1="NaN" y1="NaN" x2="NaN" y2="NaN" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" transform="translate(NaN NaN)"/>
<rect x="-50" y="-50" rx="0" ry="0" width="100" height="100" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(155,89,182); fill-rule: nonzero; opacity: 1;" transform="translate(576.5 399)"/>
<polygon points="-50 50,0 -50,50 50" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(241,196,15); fill-rule: nonzero; opacity: 1;" transform="translate(236.5 257)"/></svg>