0

I am designing a card game. I made a card template in Inkscape and then wrote a Python script to copy the template and make a new SVG file for each card, filling in the title and so on from a CSV file.

What I would like to do with the resulting SVGs is put them in a 3x3 grid on a single page so I can print them on normal paper. I would also like them to be a particular size (specified in the original Inkscape SVG). Note that I have more than one page's worth of cards.

I think normally I could just put them in a wrapper SVG and convert that to PDF, but Inkscape puts id attributes on all elements, which I expect would cause issues.

How can I put these SVGs on a page in a 3x3 grid?

polm23
  • 14,456
  • 7
  • 35
  • 59

1 Answers1

2

Managed to find a solution, though there's room for improvement.

First I convert all the SVGs to PDFs using Inkscape in batch mode. For that I create a file like this:

for ii in cards/*.svg; do
    echo "$ii --export-pdf=$ii.pdf" >> inkscape-commands
done
cd cards
DISPLAY= inkscape --shell < ../inkscape-commands

Then I use the pdfnup command from the texlive-core package (on my distro anyway) to do page layout:

pdfnup --nup 3x3 --paper a4paper --scale 0.90 --no-landscape *pdf

This works, but there's one thing I don't understand and wish was better. The original SVG files should be exactly the right size for cards, but if I use --scale 1.0 then they're too big. If someone can give another answer that allows me to specify the width of the cards in units rather than a percent I'll vote that up.

polm23
  • 14,456
  • 7
  • 35
  • 59
  • Thanks, it work great. got the same result with `pdfjam --nup 3x3 --a4paper --outfile test.pdf *.pdf` – Touk Mar 01 '22 at 17:39