PDF logoSay you are working on a text document, e.g. in LibreOffice, and you would like to insert a PDF-document. Just inserting or importing it will not work. The easiest way to get a decent result is this:

  • convert the PDF-document to an image file, e.g. PNG;
  • insert that file as an image into your text document.

Linux has some clean and lean command-line tools to help you.

TIP: have a look at Master PDF Editor.

Install tools

First make sure you have the poppler-utils package installed, which is available from the main Ubuntu repositories. If you prefer a more recent version, you could add the Scribus PPA to your repositories. To add the PPA and install the package open a terminal and type:

sudo add-apt-repository ppa:scribus/ppa
sudo apt-get update
sudo apt-get install poppler-utils

The poppler-utils will add a number of commandline tools. Have a look at ‘Installed Files’ in the Synaptic package manager to find out.

The one we need in this case is pdftoppm. This wee thingy enables you to convert a PDF file to a monochrome PBM, a grayscale PGM, or a colour PNG/JPEG/TIFF file. The default resolution is 150 DPI, but that can be adapted to taste. To explore all options open a terminal and type:

pdftoppm --help

OR:

man pdftoppm

Convert a PDF

To convert a PDF file to an image – I prefer PNG – open a terminal, go to the directory where you stored the PDF file and type:

pdftoppm -png [filename].pdf [prefix/filename]

To use another resolution type:

pdftoppm -r 300 -png [filename].pdf [prefix/filename]

That’s it. Save the image file to where you want it, and insert it into your LibreOffice document. You can handle it as any image.

And the other way around, making a PDF out of an image, is equally simple. You might want to if you scanned a document and thus produced a JPG, PNG or TIFF file. Just open a new document in LibreOffice, insert the image file and then export the file as PDF, either clicking the ‘Export Directly as PDF’ button from the standard toolbar, or from the File > Export as PDF… menu. The last option allows you to tweak the settings.

PDF to Image
Getagd op: