Inkscape.org
Beginners' Questions Create a new page with python
  1. #1
    strayrongve strayrongve @strayrongve

    Im using python to draw simple graphics. However, as I would like to print the graphics as A4 pages with my printer, Im looking for a way to automatically generate new pages from a python script. Has anyone done this before and can help me?  I have tried using the inkex library without any luck. 

     

  2. #2
    inklinea inklinea @inklinea⛰️

    There is an example ( a zipped extension attached to my post ) here. https://inkscape.org/it/forums/questions/how-to-put-each-imageobject-into-a-separate-page-and-image-fit-the-page/

    One change I would make is to add the offset to the 2nd page to avoid overlapping.

  3. #3
    strayrongve strayrongve @strayrongve

    Thank you so much for your help ! I'll consider modifying it :)  My last step is to figure out how to run this directly from python as a plugin/import. 

  4. #4
    inklinea inklinea @inklinea⛰️

    Something like:

    Create a new venv in python

    Activate that venv, and use pip to install Inkex.

  5. #5
    inklinea inklinea @inklinea⛰️

    Something like:

    Create a new venv in python

    Activate that venv, and use pip to install Inkex.

  6. #6
    strayrongve strayrongve @strayrongve
    *

    Yes, Im able to run python, but I need to be able to run the script from another python script with inputs etc.  

    Now I'm importing the script (using import xx as abc). I need to be able to give a svg filename as input to the extension script (and some additional parameters) and then get the changed file as output. 

     

  7. #7
    inklinea inklinea @inklinea⛰️
    🙏*

    It's not really an extension if you don't use the main Inkscape program :)

    If you want to completely avoid the Inkscape main program and just use inkex in python.

    You can load svgs using the load function.

    This script ( inkex standalone ) shows how to load svg files from a folder:

    https://inkscape.org/forums/beyond/trim-whitespace-from-svg-command-line/