Compatibility with PlantUML

Bug #1754167 reported by Oliver Kopp
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Undecided
Unassigned

Bug Description

Short summary: `style="width:116px;height:131px;"` is not supported by inkscape. The SVG is rendered fine in IntelliJ, so I assume, inkscape could be improved.

How to produce such a PDF?

PlantUML file:

@startuml
Bob->Alice : hello
@enduml

Execute plantuml.jar to get the SVG:

    java -jar plantuml.jar -tsvg example.txt

Generated SVG:

```
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
     contentScriptType="application/ecmascript" contentStyleType="text/css" height="131px" preserveAspectRatio="none"
     style="width:116px;height:131px;" version="1.1" viewBox="0 0 116 131" width="116px" zoomAndPan="magnify">
  <defs>
    <filter height="300%" id="f1bh39diomyks7" width="300%" x="-1" y="-1">
      <feGaussianBlur result="blurOut" stdDeviation="2.0"/>
      <feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/>
      <feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/>
      <feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/>
    </filter>
  </defs>
  <g>
    <line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="29" x2="29" y1="39.6094"
          y2="89.9609"/>
    <line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="85" x2="85" y1="39.6094"
          y2="89.9609"/>
    <rect fill="#FEFECE" filter="url(#f1bh39diomyks7)" height="31.6094" style="stroke: #A80036; stroke-width: 1.5;"
          width="39" x="8" y="3"/>
    <text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="25" x="15"
          y="24.5332">Bob
    </text>
    <rect fill="#FEFECE" filter="url(#f1bh39diomyks7)" height="31.6094" style="stroke: #A80036; stroke-width: 1.5;"
          width="39" x="8" y="88.9609"/>
    <text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="25" x="15"
          y="110.4941">Bob
    </text>
    <rect fill="#FEFECE" filter="url(#f1bh39diomyks7)" height="31.6094" style="stroke: #A80036; stroke-width: 1.5;"
          width="44" x="61" y="3"/>
    <text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="30" x="68"
          y="24.5332">Alice
    </text>
    <rect fill="#FEFECE" filter="url(#f1bh39diomyks7)" height="31.6094" style="stroke: #A80036; stroke-width: 1.5;"
          width="44" x="61" y="88.9609"/>
    <text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="30" x="68"
          y="110.4941">Alice
    </text>
    <polygon fill="#A80036" points="73,67.6094,83,71.6094,73,75.6094,77,71.6094"
             style="stroke: #A80036; stroke-width: 1.0;"/>
    <line style="stroke: #A80036; stroke-width: 1.0;" x1="29.5" x2="79" y1="71.6094" y2="71.6094"/>
    <text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="27"
          x="36.5" y="67.1045">hello
    </text><!--
@startuml
Bob->Alice : hello
@enduml

PlantUML version 1.2017.15(Mon Jul 03 18:45:34 CEST 2017)
(GPL source distribution)
Java Runtime: Java(TM) SE Runtime Environment
JVM: Java HotSpot(TM) 64-Bit Server VM
Java Version: 1.8.0_161-b12
Operating System: Windows 10
OS Version: 10.0
Default Encoding: Cp1252
Language: de
Country: DE
-->
  </g>
</svg>
```

Now use inkscape to convert it to PDF:

    inkscape -z -D --file=example.svg --export-pdf=example.pdf

Expected result: PDF with the correct page size

Got result: PDF with huge white border and following output:

```
** (inkscape.exe:14960): WARNING **: SPIStyle::readIfUnset(): Invalid style property id: 8 value: 131px

** (inkscape.exe:14960): WARNING **: SPIStyle::readIfUnset(): Invalid style property id: 7 value: 116px
```

Revision history for this message
Oliver Kopp (kopp-dev) wrote :
Revision history for this message
sk (skramm) wrote :

Same issue when exporting to png.
Inkscape seems to ignore the drawing size when encountering this issue.
I checked, the code generated by Plantuml seems perfectly valid SVG 1.1

Revision history for this message
Patrick Storz (ede123) wrote :

The problem here does not actually seem to be the `style="width:116px;height:131px;"` - while I assume Inkscape just ignores it, the document width/height are set to the same dimensions via proper properties on the SVG root element.

What is causing the unexpected export size is the `filter="url(#f1bh39diomyks7)"` which uses a width/height of 300%.

Any reason for using "-D" switch here (which tells Inkscape to export the "whole drawing", including the invisible extens of this filter)?
When omitting the "-D" switch and exporting the "whole page" borders are as expected.

Revision history for this message
Oliver Kopp (kopp-dev) wrote :

No specific reason to use "-D" here. I just copied a command line from another inkscape call, where it used to be necessary to get the boundaries right.

Changed in inkscape:
status: New → Invalid
Revision history for this message
fuhrmanator (fuhrmanator) wrote :

I'm running Inkscape 0.92.4 on Windows 10.

Removing the "-D" doesn't solve the problem for the SVG I have from PlantUML. I don't really mind the warnings normally:

** (inkscape.exe:22424): WARNING **: 11:49:08.629: SPIStyle::readIfUnset(): Invalid style property id: 8 value: 166px

** (inkscape.exe:22424): WARNING **: 11:49:08.629: SPIStyle::readIfUnset(): Invalid style property id: 7 value: 487px

The PDF that is generated is just fine, actually. The problem is the warnings, which cause the command processor I'm using to bail out. I have tried to suppress them per preferences.xml in #bug 437366 https://bugs.launchpad.net/ubuntu/+source/inkscape/+bug/437366/comments/3 but they still appear.

I verified the path of the preferences through the GUI, but the GUI changes don't seem to modify the XML. Do the GUI and CLI share the same preferences file?

Revision history for this message
fuhrmanator (fuhrmanator) wrote :

My workaround has been to redirect stderr (2>) to nul, e.g.,

    inkscape -z -D --file=mdd.svg --export-pdf=mdd.pdf 2> nul

which is not ideal, since it won't report ANY errors.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.