Creating individual image files from presentation slides

How do you create full-screen images from each of the slides of a Google Docs presentation without too much manual work? For the previous blog post on my Munin keynote, I wanted to include some pictures from my 90-slide presentation. There is probably a point and click solution to this problem, but it is even more fun to use some command line tools to help out. These commands have been tested on Ubuntu 19.10, but should probably work on many other systems as well, as long as you have installed pdfseparate and convert.

After exporting a PDF from the Google Presentation, I made a separate PDF file of each slide using this command:

pdfseparate input.pdf output%d.pdf

This creates a bunch of PDF files with a running number. Then I ran this little for loop:

for i in *.pdf; do name=`echo $i | cut -d'.' -f1`; convert -density 200 "$i" "$name.png"; done

And voila, then I had nice PNG files of all my slides. I found that the trick is to use the “-density 200” setting (choose the density that suit your needs), since the default resolution and quality is too low.

Split PDF files easily using Ubuntu scripts

One of the fun parts of reinstalling an OS (yes, I think it is fun!), is to discover new software and new ways of doing things. As such, it works as a “digital shower”, getting rid of unnecessary stuff that has piled up.

Trying to also get rid of some physical mess, I am scanning some piles of paper documents. This leaves me with some large multi-page PDFs that I would like to split up easily. In the spirit of software carpentry I looked for a simple solution for splitting up a PDF file, and came across the command “burst” in the little terminal application pdftk. To use it on Ubuntu, you will first need to install it, using the terminal command:

sudo apt update && sudo apt install pdftk

Then this one-liner is all that is necessary to split a PDF file into a series of individual PDFs:

pdftk your-file.pdf burst

For convenience, I also made it into a small Ubuntu script:

This script can run by right-clicking on a file in the file manager:

And the end-result is a series of individual PDF files:

And then you can of course also combine the files again, either all PDFs:

pdftk *.pdf cat output newfile.pdf

or only the files you like:

pdftk file1.pdf file2.pdf cat output newfile.pdf

Shell script for compressing PDF files on Ubuntu

ubuntu-logo112Back on OSX one of my favourite small programs was called PDFCompress, which compressed a large PDF file into something more manageable. There are many ways of doing this on Ubuntu as well, but nothing really as smooth as I used to on OX.

Finally I took the time to figure out how I could make a small shell script based on ghostscript. The whole script looks like this:

#!/bin/sh
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r150 -sOutputFile="compress_$@" "$@"

and by saving it in the nautilus scripts directory:

 ~/.local/share/nautilus/scripts

It shows up when I right click on a file. For most of the files I have tried so far today (uncompressed PDF files), it compresses the files to at least 1/10th of the original size. Very useful, particularly when I only need screen resolution for files.

Screenshot from 2016-06-29 16-55-49

Reducing PDF file size

I am working on finalizing an electronic version of a large PDF file (600 page NIME proceedings), and have had some problems optimizing the PDF file. This may not be so strange, since the file is an assembly of 130 individual PDF files all made by different people and using all sorts of programs and OS.

Usually, PDFCompress works wonders when it comes to reducing PDF file sizes, but for the proceedings-file it choked at some of the fonts. Strangely enough, Acrobat Pro also encountered problems, and with no useful explanation on what went wrong.

Fortunately, OSX came to the rescue. When saving a PDF file in OSX it is possible to apply a quartz filter. And OSX had no problems saving and reducing a new PDF file of the proceedings-file. However, the built-in “reduce file size” filter reduced the images too much. But I found an explanation on how to create your own quartz filters, where it is possible to choose compression settings.

I find it strange that Acrobat Pro couldn’t do the job, but I am very happy to have found a solution.

Use Preview instead of Adobe Reader in Texmate

I just installed Adobe Reader on my new computer, only to discover that it hijacked the PDF preview window in TextMate when working on LaTeX documents. This also happened the last time I installed a new system, and I couldn’t remember what I did to change it back to using Preview as the default PDF viewer.

After googling around, I remembered that TextMate is just using the regular browser settings when it comes to displaying PDF files. For some weird reason, you have to go in the Adobe Reader preferences to change this back. Unfortunately, on my system the uncheck box for this functionality is grayed out:

adobe-reader

Finally, I just decided to delete Adobe’s PDF viewer plugin altogether, by deleting this file:

/Library/Internet Plug-Ins/AdobePDFViewer.plugin

This solved the problem, both in Textmate and in my browsers. If anyone wonders, Preview is much, much faster than Adobe Reader and I also think it displays the fonts nicer.