Howto: Saving an XCF with Layers to a PDF with Pages

I’m surprised that there isn’t an easier way to go from a Gimp file (.xcf) to a PDF.  Sure, you can always “print to pdf” if you are working with a single layer image, but what if you have a multi-layer image that you want to turn into a PDF with multiple pages (each page being a layer from the image)?

Here is one way that I’ve found to accomplish this.  I’m using Ubuntu so any install stuff will be specific to that distribution, but the software I’m using should work on any Linux distro.

First, you’ll need Gimp.  I’m assuming that’s already installed.

Gimp won’t save a multi-layer image to a .ps, .tif, or .pdf by itself, though, so you need to install a script called “Save Layers as Individual Files” (this script can be downloaded for Gimp 2.4 or newer from Panotools) .

Once you download this script it needs to be put in your Gimp scripts directory.

unzip -d ~/.gimp-2.6/scripts Save-layers-tiff-24.zip

Your scripts directory may be named something else if you are using another version of Gimp (other than 2.6). Once the script is in that directory, it will appear in the Script-Fu > Utils menu within Gimp (and can be applied to any open image).

Next, you need to install imagemagick.  If you don’t already have it installed, it’s as easy (on Ubuntu) as:

sudo aptitude install imagemagick

Once that is installed, you’ll be able to use the mogrify program which comes with ImageMagick. From within the directory that contains all your TIF files, type:

mogrify -format pdf *.tif

This will generate PDFs for each of your TIF files. You can then merge all the PDFs files into one using a program called PDFTK. To install that, just type:

sudo aptitude install pdftk

Running that program is as easy as typing:

pdftk filename*.pdf cat output singlename.pdf

The filename*.pdf argument will catch all the individually named files created by the mogrify program (filename1.pdf, filename2.pdf, filename3.pdf, filename4.pdf, etc.)

And, that’s it! You can open your new singlename.pdf file and have all those XCF layers now represented by individual pages within the PDF. This is the easiest way that I’ve found to accomplish this task, but if you know of a better/easier way I’d love to hear it!

July 1, 2009 • Tags: , , • Posted in: Linux

3 Responses to “Howto: Saving an XCF with Layers to a PDF with Pages”

  1. pat - September 16, 2009

    Or you simply save the multi-layered file as GIF animation and convert it to pdf with Imagemagick. Does only make sense if you can live with the low quality (in my case it didn’t matter, since I used it for scanned documents).

  2. ksclarke - September 16, 2009

    Thanks! I could have lived with low quality for what I was doing. I’ll give that a try next time.

  3. Luisma - January 14, 2010

    I've read your article. It's very inetresting and what I was searching. But, I think I can improve your method. Once you have instaled the gimp plugin and you make the tiff files, you ca open all the imagen with GTHUMB, and print it all with it. The result has a better quality I think and is easier.

Leave a Reply