Answers

11 min read

Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com

Neil Bothwick has just been upgraded with a PCIe slot in his arm.

Q A sign of the times

I have a number of PDF forms that I need to complete and sign. The completing part is not a problem– Okular handles that. My issue is that the forms’ fields only accept text input, and typing my name in the field is not acceptable; I need an actual signature. I know I could print out each form, sign it manually, then scan it back to a PDF, but that is a lot of time and a not insignificant number of trees lost for the number I have to deal with each month. Is there a way I can add a scanned image of my signature to the field of each? I’d prefer a command-line option so I can batch process the PDFs.

A You can indeed do this. You need three programs: LibreOffice and Ghostscript, which are installed by default with most distros, and PDFtk. You may not have PDFtk, but it will be in your distro’s repositories. The first step is to create a PDF with your signature, and the simplest way to do this effectively is to import the scanned image into a blank page in LibreOffice Writer, place it at the bottomleft, then export that page as a PDF. Call it sig.pdf. The next step is to use Ghostscript to turn that into another PDF with the signature in the position you need. You could do this in LibreOffice, but it would involve a lot of trial and error, trying to get the position exactly right, and would not be easily reproducible. So use gs from Ghostscript, like this:

$ gs -o offset-sig.pdf -sDEVICE=pdfwrite -c “<< /PageOffset [172 156] >> setpagedevice” -f sig.pdf

The offsets are in points, 1/72nd of an inch, so you could determine the offset with a ruler or use trial and error. Honestly, we found the latter approach easier. Then you use PDFtk’s stamp function to overlay the signature on the form: $ pdftk form.pdf stamp offset-sig.pdf output form-signed.pdf

View the resulting file and, if the signature is not correctly placed, run gs again with tweaked offsets. If all the forms have the same layout, once you have the offset, you can apply the signature to each one with a shell loop:

$ for f in form*.pdf; do pdftk $f stamp offset-sig.pdf output ${f/. pdf/-signed.pdf} done

Q Video nastiness

I use YouTube-dl to get movies from YouTube and have noticed a few people think it’s clever to put the movie in one quarter of the window with a wavy background in the other three quarters. Not clever in my not so humble opinion!

Using LibreOffice to create a PDF with only your signature is the first step in signing other PDFs.

Is there a Linux program that can get rid of that useless background and leave the movie I wanted? I can think of a longwinded solution: use Lives to produce all the frames, then use a combination of GIMP and ImageMagick to