0

I am trying to use a linux command line to hide all layers in an svg file. Most of the time it works well but sometime inkscape failed at opening it. I am using inkscape 0.92.3.

I compared the svg files to find the problem and it seems to be due to a simple line return before a flowRegion. Here is a minimal illustration of the problem.

This file can be opened with inkscape:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   inkscape:version="0.92.3 (unknown)">
    <flowRoot
       xml:space="preserve"
       id="flowRoot12255"
       style="font-style:normal;font-weight:normal;font-size:15px;line-height:748.99997711%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"><flowRegion
       id="flowRegion12257"><rect
           id="rect12259"
           width="253.54829"
           height="194.95944"
           x="204.05081"
           y="217.423" /></flowRegion>
</svg>

This file cannot be opened with inkscape (it just open a dialog with the message "Inkscape had an internal error and will close now"):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   inkscape:version="0.92.3 (unknown)">
    <flowRoot
       xml:space="preserve"
       id="flowRoot12255"
       style="font-style:normal;font-weight:normal;font-size:15px;line-height:748.99997711%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"><flowRegion
       id="flowRegion12257"><rect
           id="rect12259"
           width="253.54829"
           height="194.95944"
           x="204.05081"
           y="217.423" />
</flowRegion>
</svg>

Do you know why the second file cannot be opened?

Would it work with more recent versions of inkscape?

FYI here is the command line I used:

xmlstarlet edit --inplace --update "//*[@inkscape:label]/@style" --value "display:none" --insert "//*[@inkscape:label][not(@style)]" --type attr -n style -v "display:none" "myFile.svg"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.