Tip of the day: batch PDF conversion with LibreOffice
Someone asked me today why they couldn't write on the DOCX document they received from a student using the pen in their Onyx Note Pro reader. The answer, of course, is that while the Onyx can read those files, it can't annotate them: that only works with PDFs.
Next question then, is of course: do I really need to open each file separately and save them as PDF? That's going to take forever, I have 30 students per class!
Fear not, shell scripting and headless mode flies in to the rescue!
As it turns out, one of the Libreoffice parameters allow you to run batch operations on files. By calling:
libreoffice --headless --convert-to pdf *.docx
LibreOffice will happily convert all the *.docx
files in the current
directory to PDF. But because navigating the commandline can be hard,
I figured I could push this a tiny little bit further and wrote the
following script:
#!/bin/sh
exec libreoffice --headless --convert-to pdf "$@"
Drop this in ~/.local/share/nautilus/scripts/libreoffice-pdf
, mark
it executable, and voilà! You can batch-convert basically any text
file (or anything supported by LibreOffice, really) into PDF.
Now I wonder if this would be a useful addition to the Debian package, anyone?
unoconv, sure, why not. Someone also suggested lloconv. There's also Pandoc that could probably do this as well.
The thing is none of those have file manager integration. Plus, it's extra software to install. I want the simplest possible instructions, targeting novice Linux users, which means as little (commandline, in particular) work as possible. Installing new packages is therefore superfluous.
By the way, I suspect the above instructions I made do reuse existing Libreoffice instances if they are already running. I might be wrong, but it seems faster with than without...
Without LibreOffice running:
With LibreOffice running:
So thanks everyone for the recommendations, those are very useful tools! But I think LibreOffice's builtin commandline is fine for this purpose for now.