Closed JanBliznicenko closed 1 year ago
When SVG exporter overwrites existing file, it only overwrites the amount of characters needed for new svg, but if the original one was larger than the new one, it keeps the rest of original content after new content, resulting in invalid file.
Example producing invalid svg:
canvas := RSCanvas new. box1 := RSBox new. box2 := RSBox new. box2 translateTo: 200@200. canvas add: box1; add: box2. canvas svgExporter fileName: 'test.svg'; export. box2 remove. canvas svgExporter fileName: 'test.svg'; export.
Resulting SVG:
<?xml version="1.0" encoding="UTF-8"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="500pt" height="500pt" viewBox="0 0 500 500" style="background-color:#FFFFFF" version="1.1"> <rect x="-5" y="-5" width="10" height="10" fill="#9F9F9F" transform="matrix(1,0,0,1,250,250)" /> </svg>x="-5" y="-5" width="10" height="10" fill="#9F9F9F" transform="matrix(1,0,0,1,450,450)" /> </svg>
It probably needs to remove the original file first.
Hi thank you for the feedback, now exporter remove old file before write on it
When SVG exporter overwrites existing file, it only overwrites the amount of characters needed for new svg, but if the original one was larger than the new one, it keeps the rest of original content after new content, resulting in invalid file.
Example producing invalid svg:
Resulting SVG:
It probably needs to remove the original file first.