
I really enjoy using xournal++ for my math course. It allows me to take handwritten notes and annotate my lecture files. While our teacher does a really good job at properly formatting those documents with LaTeX, it always has been hard for me to maintain a straight line on a plain sheet of paper. Unfortunately there is no feature of xournalpp I know of, which would allow me to overlay a grid on top of a pdf file. So I had to come up with something on my own:
#!/bin/bash
grid=$(cat $HOME/docs/grid.svg)
rm -rf /tmp/pdfgrid
mkdir -p $_
mv "$1" $_
cd $_
pdf2svg "$1" %02d.svg all
for page in *.svg; do
sed -i -e '/<\/svg>/d' $page
echo "$grid" >> $page
echo "</svg>" >> $page
done
rsvg-convert -f pdf -o out.pdf *.svg
cd -
mv /tmp/pdfgrid/out.pdf "$1"
I use pdf2svg to slice an entire pdf into an svg file per page. For every page, I append a grid which is just a path with strokes and an opacity. At the end, I use rsvg-convert to assemble the pdf from the svg files again and voilĂ , all the pages have a grid now!