Editing pdf files with GIMP
Facts - Other software technologies
Thursday, 24 July 2014 09:22

GIMP (version 2.8) can be used to edit images. Sometimes I have to use the brush or the pencil in GIMP to get rid of some details in the picture I want to edit. I don't use GIMP very often so when I start it usually I have to learn again some pitfalls.

For instance I often select the pencil or the brush and try to wipe out some of the diagram. To my surprise nothing happens. What I keep forgetting is that GIMP uses layers. So if you want to edit a pdf with multiple pages each page is a layer in GIMP. The problem then is that GIMP does not always seem to select the visible layer. Instead it may select the last layer for editing. So when you try to brush or paint you may be editing an invisible page in your pdf instead of the current page that is visible. To select the right page/layer for editing I recommend to use the Layer Toolbox. Use Ctrl-L to get this toolbox and then select the layer you want to edit.

The next step was exporting the layers to a multi-page pdf again. This can be done with ImageMagick. I have tried a GIMP plugin as well but could not get it working. Fortunately using ImageMagick is simple enough. If you have cygwin you probably have it already. Exporting layers to a multi-page pdf can be done with the following steps:

  1. The layers must be saved in reverse order. So reverse the layer order using the Menu: Layer, Stack, Reverse Layer Order
  2. Save the image as an MNG animation using Export from the File Menu.
  3. Open a command prompt and execute the ImageMagick convert command:
    convert editedpdf.mng editedpdf.pdf