Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Combine pdfs

I remember needing to combine PDFs in the past, even on GNU/Linux, but I forgot how I did it back then. The first search result for query combine pdfs linux I found said to use ImageMagick! I keep that around for all sorts of tasks already, so:

convert file1.pdf file2.pdf mergedfile.pdf

But the quality was terrible. I didn't want to bother with dealing with quality settings in ImageMagick, when I remembered there was something out there that would work. It was farther down in that first result: just use pdftk.

pdftk file1.pdf file2.pdf cat output mergedfile.pdf

I'm not sure why this is so hard for the Internet.

Bonus

Also, LibreOffice draw struggles with pdfs that have fonts that are not on your system. You can achieve limited success by using mutool extract from package mupdf-tools. Unfortunately for me, the font name used didn't match up with the ttf font name properties because of the whole "FontName-Bold" stuff. So I still had to manually munge stuff, and apparently some of the embedded glyphs were not included so it took some playing around with manually changing a random letter "V" into the non-bold version to get it to appear. That was frustrating. And I had gotten so far as to use ttx filename.ttf from package fonttols but didn't get any farther in that experiment.

Comments