janoliver / inkslides

A rewrite of the inkscapeslide script to create PDF presentations out of inkscape SVG files.
MIT License
26 stars 7 forks source link

Cloned objects are not rendered if on a separate slide to the original #6

Closed protist closed 6 years ago

protist commented 6 years ago

I'm using the latest version of inkslides in Arch Linux.

Steps to reproduce:

  1. Create an object in Inkscape.
  2. Clone it (Edit > Clone > Create Clone).
  3. Move the clone to a new layer.
  4. Run inkslides.

Expected: All clones should be displayed.

Observed: The clone on the new layer is not rendered. N.B. clones on the same layer as the original are rendered as expected.

Here is a minimal document showing this issue. The original object is on Layer 1. The clone on Layer 1 is rendered, but the clone on Layer 2 is not. (I'm using the "hacked" inkslides from #5 so all layers are top-level.)

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

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="210mm"
   height="297mm"
   viewBox="0 0 210 297"
   version="1.1"
   id="svg8"
   inkscape:version="0.92.2 2405546, 2018-03-11"
   sodipodi:docname="drawing.svg">
  <defs
     id="defs2" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="0.7"
     inkscape:cx="255.65955"
     inkscape:cy="574.76499"
     inkscape:document-units="mm"
     inkscape:current-layer="layer2"
     showgrid="false" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <rect
       style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;vector-effect:none;fill:#8f8f8f;fill-opacity:0.31102373;fill-rule:nonzero;stroke:none;stroke-width:1.85199988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
       id="rect815"
       width="32.505951"
       height="20.410715"
       x="48.75893"
       y="75.505951"
       rx="1.0000006"
       ry="1.0000006" />
    <use
       x="0"
       y="0"
       xlink:href="#rect815"
       id="use840"
       transform="translate(48.002976)"
       width="100%"
       height="100%" />
  </g>
  <g
     inkscape:groupmode="layer"
     id="layer2"
     inkscape:label="Layer 2">
    <use
       x="0"
       y="0"
       xlink:href="#rect815"
       id="use817"
       transform="translate(22.129646,74.799388)"
       width="100%"
       height="100%" />
  </g>
</svg>
janoliver commented 6 years ago

The problem here is, that inkslides deletes everything that is not shown on a slide before generating a PDF out of it. This is done so the PDF sizes are small (I think... :) )

I didn't even know the clone function until now, but obviously that needs to be fixed. Either I replace the clones with a copy of the original (probably not trivial) or I don't delete hidden layers (probably size issues...). I'm going to run some tests and see.

janoliver commented 6 years ago

It is fixed now, I am only deleting all other layers when the current layer has no cloned elements in it. This seems okay.

protist commented 6 years ago

Thank you! This works perfectly too!