Categories
General

Converting a PNG to a PDF

Why I wanted to do this: I got an IRS PDF form from someone. Many of the fields on the form were fillable, but obviously it couldn’t be signed – and the date field also wasn’t fillable. So, I could have just printed it out, completed it, then mailed it, but this is 2010 fergawdsakes! I know that Adobe thoughtfully sells just the tool for the job, but that’s no fun at all.

I knew I could import the PDF into Gimp (converting it into a bitmap) and edit it there, dropping in my signature and whatnot. Next I needed to turn the bitmap back into a PDF. Gimp doesn’t make PDFs, so I saved the bitmap as a high-res PNG and went looking for something to convert a PNG into a PDF.

ImageMagick should have immediately occurred to me, but I needed Google to connect the dots. Here’s the command I figured out after some trial-and-error:

convert -page Letter -density 28.3 input.png output.pdf

Note that the 28.3 part was specific to the resolution of my PNG. Using other values, when I checked the PDF’s properties the dimensions weren’t 8.5×11 – so I just tried numbers until I got close enough. I’d imagine there’s an automated way to do the calculation, but for just one PDF trial-and-error worked fine for me.

Avatar photo

By isaac

I like cats. he/him