Skip to content

cwgaldino/inkslide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inkslide

Slide presentation from Inkscape svg files using python. It was tested on Ubuntu 20.04 with Inkscape 1.0 and 0.9.3. However, it should work fine on windows and mac (let me know).

Update 15-April-2021: I started working on an Inkscape extension based on this repository, but it is gonna take a while since I am still learning about developing extensions. Let me know if you wish to help me with that.

https://github.com/cwgaldino/inkslide/blob/master/figs/fig_1.png?sanitize=true

https://github.com/cwgaldino/inkslide/blob/master/figs/fig_2.png?sanitize=true

https://github.com/cwgaldino/inkslide/blob/master/figs/fig_3.png?sanitize=true

Please, report issues and enhancement ideas on GitHub. The script is in a early stage of development so every comment helps.

Dependencies

The svg parser script relies on

  1. beautifulsoup4
  2. lxml

They can be installed via pip:

pip install beautifulsoup4
pip install lxml

Additionally, the scripts uses the Inkscape internal pdf converter to convert svg files to pdf. In case it fails, it falls back to python libraries to do te conversion

  1. svglib
  2. reportlab

They can be installed via pip:

pip install svglib
pip install reportlab

Therefore, these aren't really necessary at first. Only if you don't to use Inkscape converter or if it fails.

Finally, the slide construction needs a pdf merger PdfFileMerger that can also be installed via pip:

pip install PyPDF2

Installation and usage

There two ways to use (install) this python module.

  1. You can download (clone) the repository and use it as a python module (see python scripts in the tutorial folder).

or

  1. You can download (clone) the repository and put the file inkslide.py in your $HOME/bin folder and use it as a command.

    Usage: inkslide.py [OPTION] FILE

    Create slide from Inkscape file.

    -h, --help

    display this help and exit

    -i

    use instructions file as input

Tutorials and examples

Tutorial file 0 will give you examples how to use the svg file parser class, which is useful if you want to do your own tinkering with Inkscape svg files.

Tutorial files 1 and 2 will give examples on how to create presentations from Inkscape files by importing inkslide.py as a module. Note that one can generate a presentation from a instructions file or embedded the instructions directly into the Inkscape file. In the later, a instructions file will be generated automatically. In addition to that, one can also use inkslide.py as a command. For instance, presentations in the Examples folder were created by calling inkslide.py from the terminal.

Embedded instructions

Instructions can be embedded directly into the Inkscape file. In this case, a instruction file will be generated automatically. The possible settings are (these must be written in the Inkscape file as text --- see example 3):

  1. inkslide.save at: <path-to-save-slide>

    filepath to save slide. If more than one is provided, the last one is used. If not provided, slides will be saved at current directory as slides.pdf.

  2. converter: <converter>

    method for converting svg file to pdf.

    1. inkscape1.0
      Uses Inkscape 1.0 internal pdf converter.
    2. inkscape0.9
      Uses Inkscape 0.9.x internal pdf converter.
    3. svglib
      Uses python package svglib (use pip install svglib). If None, it will try to use Inkscape internal converter from the same Inkscape version in the file.
  3. inkslide.slide number: <True, False, all>

    It replaces the text:

    ##.slidenumber
    

    by the slide number. There are three different slide numbering modes:

    1. All or all
      All layers are counted as different slides.
    2. True or true
      Layers marked with * or ! do not count as a new slide.
    3. False or false
      No slide numbering.

Each layer can have a personal instruction that must be written at the begging of the layer label. The layer instructions are:

  1. #
    Hide layer (layer does not became a slide)
  2. @ or b:
    Layer is used as a background for subsequent layers until another background layer is set.
  3. $ or o:
    Layer is used as a overlayer for subsequent layers until another overlayer layer is set.
  4. *
    Previous layer (or layer sequence) is added as background to the current layer to form one slide.
  5. -
    Last slide but the last layer is copied and used is as background to the current layer to form one slide. Multiple layers can be deleted by using multiple -.
  6. +
    Add current layer to the previous one (merging layers).
  7. =<layer>, <layer2>, <layer3>
    Copy layer. Current layer is disregarded and <layer> is copied (use =, ==, ===, ... to avoid having two layers with the same name). Note that, = can copy layers that are hidden (#).
  8. goto:<path-to-another-inkscape-file>
    Defines the filepath of Inkscape file of subsequent layers. Presentation can be split in multiple files.

Instructions file

A instructions file is a simple txt file where each line can be a command or a list of layers separated by comma , that will form a slide. Possible special tags, commands, and instructions are:

  1. # <comments>

    Lines starting with # are ignored.

  2. save at: <path-to-save-slide>

    filepath to save slide. If more than one is provided, the last one is used. If not provided, slides will be saved at current directory as slides.pdf.

  3. file: <path-to-svg-file>

    Filepath of svg file of subsequent layers.

  4. converter: <converter>

    method for converting svg file to pdf.

    1. inkscape1.0
      Uses Inkscape 1.0 internal pdf converter.
    2. inkscape0.9
      Uses Inkscape 0.9.x internal pdf converter.
    3. svglib
      Uses python package svglib (use pip install svglib). If None, it will try to use Inkscape internal converter from the same Inkscape version in the file.
  5. bkg: <layer-to-be-used-as-background>

    Layer to put underneath subsequent slides. This bkg is used until another bkg is assigned.

  6. over: <layer-to-be-used-as-overlay>

    Layer to put over subsequent slides

  7. slide number: <True, False, all>

    It replaces the text:

    ##.slidenumber
    

    by the slide number. There are three different slide numbering modes:

    1. All or all
      All layers are counted as different slides.
    2. True or true
      Layers marked with * or ! do not count as a new slide.
    3. False or false
      No slide numbering.
  8. * or !

    use * or ! in front of any label to do not count that line as a slide

About

Slide presentation from inkscape

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages