I bought a flashcard set in PDF format, and I want to import it into Anki. Is there a way to make Anki automatically create cards where the first page of the PDF is the front of the first card, the second page is the back of the first card, the third page is the front of the second card, the fourth page is the back of the second card, and so on?
There isn’t a way to make Anki do the conversion from PDF to Anki notes. It should be possible to write a script to process the PDF into an appropriately structured .txt file which can then be imported into Anki to make Anki notes.
If you know / are willing to learn some python coding, then it can be done.
This should get you started
The .txt export/import format is fairly simple: each column on a row corresponds to a note field. If you have two note fields, Front and Back, then txt import file would look like this (using tab char as a separator):
#separator:tab
#html:true
note1frontcontent note1backcontent
note2frontcontent note2backcontent
....
etc.
Then the script would do something like
from pypdf import PdfReader
csv_file = open('anki_cards_import.txt', 'w')
# Add header info that Anki will read
csv_file.write("#separator:tab\n#html:true\n")
# creating a pdf reader object
reader = PdfReader('your_purchased_flashcards.pdf')
page_count = len(reader.pages)
# assuming the total page_count is even, we want to process the pages in pairs
for i in range(0, page_count, 2):
# creating a page object
page1 = reader.pages[i]
page2 = reader.pages[i+1]
# extracting text from first and second page
page1content = page1.extract_text()
page2content = page2.extract_text()
# write contents to a new line in the csv
csv_file.write(f"{page1content}\t{page2content}\n")
csv_file.close()
Hey there,
Yes, you can use 2anki.net for that as of today! I’ve seen this question pop up several times on the forum, so I couldn’t resist hacking something together and replying.
Just upload your PDF, and it’ll generate PNG images for the front and back of your cards as basic notes. I chose PNG because it ensures pixel-perfect accuracy, which is great for keeping everything looking exactly like the original.
If PNGs don’t work for you, you can copy the code here and tweak the approach yourself:
GitHub Code.
Hope that helps! Let us know how it goes