pdf-snippet.nvim is a Neovim plugin that lets you grab pages from PDFs and drop them straight into your notes as images -- complete with an annotation and Markdown link back to the source.
It's perfect for lecture notes, research annotations, or any workflow where you want quick, visual snippets from your PDFs without breaking your writing flow.
- Select a PDF with Telescope
- Enter a page number (with optional label)
- Converts the page to an image via a bundled Python script
- Inserts a Markdown image link at your cursor
- Each image is named and annotated with the source PDF and page number
-
Python >= 3.10
-
Libraries:
pip install -r python/requirements.txt
(or manually:
pip install pdf2image pillow) -
System Dependency: Poppler (provides
pdftopp/pdftocairo)- Ubuntu:
sudo apt install poppler-utils - Arch:
sudo pacman -S poppler - macOS:
brew install poppler - Windows: download Poppler binaries and add them to your
PATH
- Ubuntu:
Using lazy.nvim:
{
"xunoaib/pdf-snippet.nvim",
dependencies = { "nvim-telescope/telescope.nvim" },
config = function()
-- Small helper for defining project directories
local function project(base)
return {
root = base, -- Project root
pdfs = base .. "/pdfs", -- PDF input directory
outdir = base .. "/extractions", -- PNG output directory
}
end
require("pdf_snippet").setup({
enable_default_keymaps = true,
projects = {
-- Add as many projects as you want
course1 = project("~/edu/course1"),
course2 = project("~/edu/course2"),
},
})
end,
}-
Run manually with:
:InsertPdfSnippet -
If
enable_default_keymaps = true, use:<leader>ps -
Or define your own mapping:
vim.keymap.set("n", "<leader>ps", "<cmd>InsertPdfSnippet<cr>", { desc = "Insert PDF Snippet" })
The conversion logic lives in python/extract.py.
Edit this file to change options like the Markdown link format, DPI, scale factor, fonts, or annotation style.