Import pdf slides + text notes into Anki.
Convert:
to:
-
Use
pip
to install it on your system:pip install git+https://github.com/musically-ut/anki-slides-import
-
Write your notes slide by slide in a plain text file.
-
Obtain the slides in pdf format.
-
Run
slides2anki <notes.txt> <slides.pdf> <output.deck.name>
.- Currently, you need to add
-U "~/Library/Application Support/Anki2/User 1/"
(or-U "~/Documents/Anki/User 1"
) to explicitly provide you user profile folder. - If you cloned this repository, then replace
slides2anki
with./slides_import.py
while in the repository root.
- Currently, you need to add
-
Open Anki and import the
<output.deck.name>
as a CSV file.
The deck should be ready to use.
The test/example_notes_q_and_a.txt
file provides examples of how to use slide modifiers to alter the behaviour of Anki card generation and slide insertion. The available slide modifiers come in two varieties that allow for various forms of either slide insertion or slide cropping respectively, and are listed as follows:
Q:
- Include the succeeding text as a standalone question without a slide (default behaviour without slide modifiers).Q_S:
- Include the succeeding text as a question followed by the current slide.S_Q:
- Include the current slide followed by the succeeding text as a question.A:
- Include the succeeding text as a standalone answer without a slide.A_S:
- Include the succeeding text as an answer followed by the current slide.S_A:
- Include the current slide followed by the succeeding text as an answer.
This is probably the most convenient way to crop slides. Four of the above slide insertion modifiers, Q_S:
, S_Q:
, A_S:
and S_A:
, can be amended by including codes in square brackets before the colon, like t
for "top", that would crop the top half of the slide, e.g. Q_S[t]:
. The full list of possible alphabetical cropping codes are as follows:
a
orw
- 'All' of the slide, or the 'whole' of the slide (Numerical:[[0:100], [0:100]]
).t
orth
- 'Top' or 'top half' of the slide (Numerical:[[0:100], [0:50]]
).vmh
- 'Vertical middle half' of the slide (Numerical:[[0:100], [25:75]]
).b
orbh
- 'Bottom' or 'bottom half' of the slide (Numerical:[[0:100], [50:100]]
).l
orlh
- 'Left' or 'left half' of the slide (Numerical:[[0:50], [0:100]]
).mh
orhmh
- 'Middle half' or 'horizontal middle half' of the slide (Numerical[[25:75], [0:100]]
).r
orrh
- 'Right' or 'right half' of the slide (Numerical:[[50:100], [0:100]]
).m
orc
ormq
orcq
- 'Middle' or 'centre' or 'middle quarter' or 'centre quarter' of the slide (Numerical:[[25:75], [25:75]]
).tl
ortlq
- 'Top-left' or 'top-left quarter' of the slide (Numerical:[[0:50], [0:50]]
).tr
ortrq
- 'Top-right' or 'top-right quarter' of the slide (Numerical:[[50:100], [0:50]]
).bl
orblq
- 'Bottom-left' or 'bottom-left quarter' of the slide (Numerical:[[0:50], [50:100]]
).br
orbrq
- 'Bottom-right' or 'bottom-right quarter' of the slide (Numerical:[[50:100], [50:100]]
).tt
- 'Top third' of the slide (Numerical:[[0:100], [0:33]]
).vmt
- 'Vertical middle third' of the slide (Numerical:[[0:100], [33:66]]
).bt
- 'Bottom third' of the slide (Numerical:[[0:100], [66:100]]
).lt
- 'Left third' of the slide (Numerical:[[0:33], [0:100]]
).mt
orhmt
- 'Middle third' or 'horizontal middle third' of the slide (Numerical:[[33:66], [0:100]]
).rt
- 'Right third' of the slide (Numerical:[[66:100], [0:100]]
).
Alternatively, for finer control, the cropping values may be specified numerically as percentages, by amending the slide insertion codes with [[wmin:wmax], [hmin:hmax]]
(or [[wmin-wmax], [hmin-hmax]]
) codes before the colon, e.g. A_S[[25:5], [0:100]]:
(or A_S[[25-5], [0-100]]:
).
You may have to install ImageMagick for your system separately.
If you want to develop this tool, you can set up the dependencies required by the files by running the following:
pip install -r requirements.txt
The reason this is not available as an addon for Anki is because only 32 bit binaries are distributed for Anki and that makes it impossible to use 64-bit ImageMagick libraries. Also, it is tricky to install the 32 bit libraries for ImageMagick using the standard tools (at least on Mac with homebrew
).
If I release an addon, then it will run if one checks-out and runs Anki from source (./runanki
from the terminal). The version from source will use and update the database used by the system-wide Anki version. However, if one is willing to go through the trouble of doing that, then one might as well use this tool from the command line.
Use slides2anki -h
to see advanced help on command line options.
I made this with two use cases in mind:
- Some concepts are easier to understand in images and extracting images from pdfs to put in cards is cumbersome.
- This will allow one to take notes slide by slide in class and then directly import them into Anki.
- Allow markdown in the slide notes
- @barryridge for major changes to parsing of notes file.