Using Gimp to modify PDF files
Gimp is normally used to create or manipulate images files, but can also work with PDFs if you understand how it works and what it's limits are.
If you’ve never used Gimp—a free image editor available for GNU/Linux, OS X, Windows and other operating systems—you might be quite surprised by its capabilities
I use it for everything from Facebook posts when the available backgrounds don’t work well for what I want to say to political buttons that I design and press out using a button-making machine.
Gimp can do everything from resizing and cropping images to adding text, changing colors or distorting images in artistic ways. You can use it to draw with its pencil or paintbrush and layer additional images. It’s quite a versatile tool. Yet I only recently noticed that it can also be used to manipulate PDF files, not just the many types of image files that most people use it to create, modify or enhance.
It might not be obvious why you’d want to modify PDFs using Gimp, but it can do some interesting things. Even though PDFs normally contain a lot of text and maybe some images, there are a number of ways that you can work with them using Gimp. For example, you can:
- Turn a PDF into a series of image files (one per page)
- Delete specific pages
- Add some new pages
- White out or replace select portions of pages
- Add notes or images
- Reverse the order of the pages
- Break a PDF into separate PDFs—by chapter, for example
It’s important to understand that editing PDFs using Gimp means you are modifying page images, and this is something that you need to fully grasp before you get started.
In addition, you need to know a few tricks about how Gimp works before you try using it to manipulate PDFs.
Opening your PDF
Once you’re ready to try using Gimp to make changes to a PDF, here’s how to start:
First, open Gimp.
Next, when you go to open a PDF using Gimp, you need to decide whether to open its pages as separate images or as a group of layers, which are portions of a single image.
This choice makes a big difference. If you plan to export the modified document as a PDF, you need to open it with the “Open pages as layers” option, which is the default. Once the document is open, you should see each page displayed as a layer in Gimp’s layers panel. If you don’t, try selecting Windows -> Dockable Dialogs -> Layers and it should appear. Don’t be surprised when a 100-page PDF ends up with 100 layers. That’s the way it works.
Select your file (e.g., Win_at_Sudoku.pdf) by selecting Open… under the File menu, selecting the PDF you want to open and then clicking on Import at the bottom right. Alternately, you can go directly to the File -> Open as layers… option and choose the PDF file.
In the panel that opens, you can change the page size and select the page range or just go with the defaults, which select all pages using 700x925 pixels. Then click on “Import” at the bottom right.
In the Layers panel, you will then see a list of the layers with small images of each one and “eye” icons on the left of each layer that controls whether the layers are visible, though the active (first) page will be the one that is displayed.
To work on a single page, click on the image of that layer from the layers panel to make it the active layer and click on (sometimes referred to as “unclicking”) the eye icons for the other images so that they are no longer visible. You will then be able to draw on the selected page or add text to it. If you add text, you will be creating a new layer, but you can to use the “Merge visible layers” option to turn the two or more layers back into a single layer when you are ready. Since the other layers should not be visible at that time, they will not be affected.
Also note that if you don’t merge layers of text that you add they will end up as separate pages when you export your modified PDF.
You can remove pages in any of three ways. You can make them invisible before you save the new PDF; you can select multiple pages (and no others) and use the “merge visible pages” options to reduce them to only the first page in the list; you can simply click on them and select “delete layer”.
You can add pages to your document by adding layers and sliding them into the proper position in the document by clicking on them and then using the up and down tools shown at the bottom of the layers panel to move them into the correct location.
You can add text and images to new layers. Just remember to have no other pages visible when you merge the added layers and the associated text layers.
Saving your changes
When you are ready to export the modified file, make sure that all of the layers you want to retain are visible (eye icons displayed) and select File -> Export As… using .pdf as the file extension for your new document. As explained earlier, if you want to omit any pages, make sure they are not visible by clicking on (“unclicking”) the eye icon. Make sure you export with “layers as pages” so you don’t end up with a single page (all pages merged into one). Select these options for the export:
- Layers as pages
- Reverse the pages order
- Apply layer masks before saving
- Omit hidden layers and layers with zero opacity
Your “Layers as pages” option may also say “bottom layers first”. If so, this will change to “top layers first” once you click on the “Reverse the pages order” option.
Turning a PDF into a group of images
If you open a PDF as separate images rather than layers, you can save each page as an independent PDF or as a separate image. Gimp will create the files using whatever file extension you select. So, just use the appropriate file extension and Gimp will do what’s needed. You will, however, have to save each page separately.
Gimp can be handy for making a number of changes to PDF files, but because it works with images, it’s not the best tool for inserting or modifying a lot of text. For that, you’re much better off using a PDF editor. Please keep in mind that you should get used to this process before using it on important files or, better yet, always keep a copy of the original file so that you can start over again if you make a mistake.