How to make pretty flashcards

from granule-decks or from arbitrary wordlists

Granule is a tool for learning vocabulary. It can be downloaded from Granule on Sourceforge. You can create virtual flash cards, memorize them and test yourself.

However, learning the words is a time consuming task and you may not want to learn in front of a computer screen. Idle time, for example during a train ride or in the bathtub or while you wait in your dentists waiting room, can effectively be used for training. Learning whereever you are requires a dead-tree (that is paper) version of your wordlist on flashcards. This article shows you how to create flashcards from Granule deckfiles or from other lists using only free software. The applications and instructions work on Windows (OK, that's not free software) and Linux.

Some background

Skip this section, if you are not interested in background information. I wanted to be able to create pretty flash cards for quite some time and considered several approaches. My requirements were the following:

  • Produce high-quality output
  • Support non-latin characters (asian fonts or cyrillic)
  • Cross platform, to support legacy operating systems (e.g. Windows).
  • Interpreted, to allow rapid development and allow easy extension without hassling with compilers and build environments.

My first attempt was a Python script, that should create generic Postscript. I found a project on Sourceforge for creating Postscript from C. For this project I wrote a Python-wrapper which I still support. This worked quite well, but it did not support unicode. Adding this functionality proved to be difficult and I had to dive into raw character encoding. One day I succeeded in producing a postscript file that included Japanese kanji symbols, but when they did not print I gave up on this.

My next idea was to create scalable vector graphics (SVG). Advantage: Native text, no binary necessary. Inkscape, my favorite drawing application, supports unicode nicely, the file format is an open standard. Disadvantage: The format supports (not sure about this) only single page documents. Because I wanted to print fronts and backs of my flash cards on a duplex capable printer, this would cause some problems. It would have been necessary to create separate files for front and back and then concatenate them afterwards. Nonetheless, the basic approach is sound.

Then I found out that an Openoffice installation can be remote controlled with Python using the so called Python-Uno-Bridge. Openoffice fulfills all my requirements: It's available for many platforms, the Python interpreter is on-board, and unicode is supported as well as multipage documents.

I studied the examples on the API pages and wrote the following script that does the wanted.

How to make the flashcards


  • You need a working Openoffice installation. I tested this guide with Openoffice 1.9.104 under Linux and Openoffice 1.1.5 and 2.0 under Windows.
  • For Openoffice 1 you need make_flashcards-zip file. For Openoffice 2 you only need the script itself. Download it to your favourite directory. I'll assume c:\temp under windows and your home directory under Linux.
  • You need some vocabulary lists, either granule dkf-files or a plain text wordlist with two or three columns that are separated with tabs. If you have none then you can use the small list below for testing purposes.


Stop all running Openoffice instances and the quickstarter if loaded. Go to the commandline (Windows: Start->Run->cmd) and change to to your installation directory. (Don't know where to find it? Select any OOo-icon with right mouseclick and have a look at the properties.)

for Openoffice 1

From the program subdirectory you need to run pkgchk.exe (Windows) or pkgchk (Linux) with the zip file as argument, e.g.

C:\Programme\ooo1.1.5\program\pkgchk.exe c:\temp\

for Openoffice 2

Copy the Python-script to your scripts directory:

D:\Programme\ 2.0\share\Scripts\python

if you don't have write-access to this directory you can copy the file to your user specific directory, which you can find somewhere near

C:\Documents and Settings\stefan\Application Data\OpenOffice.org2\user\Scripts\python

the python subdirectory probably does not exist. Simply create it.

That's all.

How to run the script

Openoffice 1

Now fire up Openoffice 1 and check for the existence of a new entry in the Extras->Add-ons Submenu. It's called Make Flashcards

If it's not there, something went wrong. Go to the commandline and repeat the installation.

Openoffice 2

Start Openoffice 2 Writer and go to Extra->Macros->Macros Administration->Python. Double click " Macros". Double click MakeFlashcards. Click createFlashcards.


Next, open a wordlist (when in doubt, choose UTF-8 as encoding format), like the one presented here and run the script.


Eins	One	The first
Zwei	Two	The second
Drei	Three	The third
Vier	Four	the fourth

If everything went well, a new document appears. Print it on heavy paper or cardboard, cut out the cards and have fun. OK, you won't have fun we these four words, so let's go on.

If this works, we download one of the dkf-examples from the Granule-websites example page and run that, e.g. Travels.dkf. Note: This script will not work with Travels.dkf directly, because the deck file is too big. The script is limited to document sizes less than 65500 characters. You have to part your lists, if you really have that many words in one file!

You may march on on your own now. Please report your success or failure to the author of this page, so that I can improve or clarify this how-to.

You can hack the Python-script to adapt the size of the individual flashcards to fit your needs. There are constants defined that you may alter: WIDTH (how many columns), HEIGHT (how many rows), BOX_HEIGHT (height of the cards, defaults to 30mm). If you decrease the height of the table make sure that only one table fits on one page or you will get front and back on the same page. To change these variables unzip the zip file, modify and zip again. Don't forget to reinstall the package afterwards. Pkgchk will complain that the package already exists. Simply delete the old archive file. The location of the old archive is printed on screen during the failed installation. OO.o2 users simply modify the script in the script directory. You don't even have to restart OOo2.

A more practical example: Japanese Kanji

Now I will walk you through a more elaborate example. After you have finished that one, you will be able to create flashcards from any arbitrary source.

Point your webbrowser to A new frame pops up on the left, containing one thousand Japanese kanji characters with Romaji and meaning. Select about, say, 40 lines - you can select all (Ctrl-A) if you're brave-, copy them to the clipboard and insert them in a freshly opened Openoffice-Writer document. Next we have to get rid of some of the formatting:

  • To remove the numbers at the front, use "search and replace", mark "regular expressions" and use "#[:digit:]*\) -" (without the quotes) as search pattern and press "replace all". This will remove all occurrences of "#Number) -".
  • Next remove "|| info..." in the same way, you must disable "regular expressions" here.
  • the field separators "||" need more attention. The conversion script uses the TAB character for dividing the columns. That's why we replace "\|\|" with "\t" now. "Regular expressions" must be active here, the backslash "\" protects the pipe-symbol "|" from being interpreted as regular expression.

Now run the macro with your new file

Openoffice comes up with a multipage document, that you can print on a duplex printer (or do manual duplexing: printing the odd pages first, turning the paper, then printing the even pages. This needs careful attention with respect to the page order.

Notes: Sometimes I got a strange character in the very first field. I erased this manually. Down below you find hyperlinks where you can download vocabulary lists for Japanese that are ready to run with make_flashcards.

Another example: Tables

I am not at least interested in birds or the french language, this example was chosen for illustration purposes only. ;-)

Go to List of birds in the Geneva region. (as far as I can tell).

Copy the full page to the clipboard (Ctrl-A, Ctrl-C) and paste it to a Openoffice-Writer document

Remove everything except the big table.

Enter the table and select "Text<->Table" from the Extras-Menu. The Tab is predefined as field selector, as we wish.

Again save this as unicode-encoded text file (wordlist02.txt) and re-run the script. You may also delete the third column, if you are not interested in its information.

Yet another example: Multiline Lists

Some wordlists are built using the following pattern:

Question: What's the capital of Germany?
Answer: Berlin. Earlier it was Bonn.

To reformat this for usage with our macro proceed as follows:

Paste your list into Openoffice-Writer. I'll use a vocabulary list as example.

This file has the following structure:

Kanji character on line 1, kana on line 2 and German translation on line 3. Then follows an empty line.

The empty line is our separator for our questions. Remove the title. Search for "$" and replace with "\t" (remember to tick regular expressions). Surprisingly that's all. You may want to remove the bullet symbol, too. Copy it to the clipboard and paste it into the search field. Replace it with the empty string. Save everything as unicode-encoded text file and run the macro. The TAB at the tail of each line does no harm.


I hope you have fun with Openoffice and Python, just as I had writing this. Please share your experiences with me, so that I can improve this page and the accompanied scripts.

stefan AT tokonoma DOT de


Many, many online-dictionaries

Saito/Silberstein as e-text

Huge number of flashcard files, originally for a program obviously called JWPce, but our macro can use them, the ones I tried are encoded in unicode.

I was recently pointed to a new flashcard project for openoffice, called Opencards. Give it a try.

File last modified: 13:30:22 23-Nov-2009