1. Overview

Portable Document Format (PDF) was created to be an accurate representation of a source document across platforms and devices. However, it’s a read-only format, not an editable format. As a result, writing annotations on a PDF file usually requires special tools.

In this tutorial, we’ll look at some open-source Linux programs that we can use to write annotations over a PDF, highlight existing text, or insert images. We’ll use each of them to edit the same sample PDF file.

Linux Mint 21 will be our testing environment. So we’ll need to adapt the installation instructions if we’re using a non-Ubuntu based distribution.

2. Okular

Okular is a KDE document viewer with support for a variety of document formats. It’s also fully functional in desktop environments other than KDE. Installation is straightforward:

$ sudo apt install okular

It offers a toolbar for adding annotations to PDF files, such as highlighting, underlining, squiggles, strikethrough, free text, inline notes, popup notes, drawing, and a variety of predefined messages (approved, confidential, draft, etc.). The official documentation describes all these options in detail. We can activate this toolbar in the Tools menu:

Okular Annotation toolbarLet’s look at an example of some possible annotations:

Okular examples of annotationsWe can save the annotated document either in PDF format or in Okular’s native format, which has the .okular extension. In the first case, Okular embeds the annotations in the PDF. In the second case, it saves the original document and the metadata, i.e., the annotations, separately within the .okular file, which is nothing more than a zip archive:

$ file example.okular 
example.okular: Zip archive data, at least v2.0 to extract, compression method=deflate
$ unzip -l example.okular
Archive:  example.okular
  Length      Date    Time    Name
---------  ---------- -----   ----
      219  2023-05-18 20:55   content.xml
   390582  2023-05-18 20:55   example.pdf
      107  2023-05-18 20:55   metadata.xml
---------                     -------
   390908                     3 files

Whether we use PDF or Okular’s format, we’ll be able to edit, add, or delete our annotations later.

3. Xournal++

Xournal++ allows us to take notes, sketch, and annotate PDF documents. Let’s install it:

$ sudo apt install xournalpp

We can import a PDF file and add our comments, highlights, drawings, and other annotations on top of it, as in the following example:

Xournal++ PDF AnnotationsWe can then export the annotated PDF as a new PDF file, but there is no way to edit our annotations in the resulting PDF. If we want to edit our annotations, we need to save the document in the native Xournal++ format, which has a .xopp extension and must be saved along with the original PDF. We can find more information in the official Xournal++ documentation on PDFs.

4. Evince

Evince is GNOME’s default document viewer. If we use another graphical environment, we can still install it:

$ sudo apt install evince

It supports only basic annotations, as in the following example:

Evince PDF AnnotationsWe can save the annotated PDF as a new PDF and remove our annotations later.

5. PDFrankenstein

PDFrankenstein allows us to add annotations to PDF files using Inkscape, a powerful vector graphics editor. It works as follows:

  • PDFrankenstein converts each PDF page to SVG, the native vector format of Inkscape
  • We can choose which page to open with Inkscape
  • We can add any Inkscape object on top of the page, but we can’t edit the original page content, which appears as a non-editable layer
  • After saving and closing the page, we return to PDFrankenstein
  • PDFrankenstein allows us to delete our annotations or to continue adding them to any page
  • Finally, we can save the annotated PDF as a new PDF, independent from the original one

Let’s install the latest version and its dependencies:

$ sudo apt install inkscape poppler-utils qpdf
$ wget https://github.com/oxplot/pdfrankenstein/releases/download/v0.9.3/pdfrankenstein_0.9.3_linux_amd64.deb
$ sudo dpkg -i ./pdfrankenstein_0.9.3_linux_amd64.deb

This installation doesn’t automatically create a program icon or association with PDF files, so we have to create them manually according to our graphical environment.

Let’s open our example file and try to insert a text annotation and a shape on the first page. Maybe because of a bug, PDFrankenstein 0.93 starts minimized:

PDFrankestein example of usageIf we just want to add annotations or other graphical objects on top of the original PDF, then PDFrankenstein is a reasonable solution. In the next section, we’ll explore the possibility of full PDF editing instead.

6. Full PDF Editing

Tools aimed at complete editing of a PDF allow both annotation and any other editing. However, we must keep in mind that such tools may compromise the original layout of the PDF under various conditions, the first of which is the lack of fonts embedded in the PDF on our machine.

First, let’s take a look at the fonts embedded in our sample PDF using pdffonts:

$ pdffonts example.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
AAAAAA+Economica-Regular             CID TrueType      Identity-H       yes yes yes      4  0
BAAAAA+Economica-Bold                CID TrueType      Identity-H       yes yes yes      5  0
CAAAAA+OpenSans-Bold                 CID TrueType      Identity-H       yes yes yes      6  0
DAAAAA+OpenSans-Regular              CID TrueType      Identity-H       yes yes yes      7  0

On our test machine, we have the OpenSans font but not Economica. Fortunately, in some cases, we can work around the missing fonts problem, as we’ll see.

6.1. Inkscape

There are some major advantages with PDFrankenstein over the use of Inkscape alone. First, Inkscape doesn’t support editing multi-page PDFs, only single pages. Second, the following is the result of opening the file directly in Inkspace using the standard PDF import options:

Inkscape wrong fonts when importing PDFThis is a missing font problem that we can work around by converting the text to vector objects using the Poppler/Cairo import option:

Inkscape PDF import with missing fontsAfter importing, we need to right-click anywhere on the page and select the Ungroup option:

Inkscape PDF Import - UngroupFinally, we can do whatever we want with any object. In this example, we enlarge a character:

Inkscape editing of a character as vectorial objectHowever, if our goal is just annotations, PDFrankestein is definitely more convenient.

6.2. LibreOffice Draw

LibreOffice Draw supports multi-page PDF editing and is preinstalled in our testing distribution as well as other distributions. It’s fairly intuitive to use.

There are no import options for converting text to vectors, but it works quite well, even with the lack of fonts. In the following example, we’ve modified the title and added a smiley face over the central image:

LibreOffice Draw PDF editingLibreOffice Draw allows us to insert objects, such as charts, tables, or formulas, from other LibreOffice applications. We can save what we’ve changed as a new PDF or export to other formats such as SVG, PNG, JPG or HTML.

6.3. Scribus

Scribus is a cross-platform desktop publishing program for creating professional-looking documents such as magazines, books, flyers, brochures, and more. It also includes vector drawing tools, support for many file formats, and the ability to render LaTex and other markup languages.

When installing via apt, we can select all packages with the final wildcard after scribus or omit it to install only the strictly necessary dependencies:

$ sudo apt install scribus*

Scribus fully supports multi-page PDFs and has a text-to-vector import option to work around the missing fonts issue:

Scribus PDF import settingsScribus allows us to insert PDF forms and annotations using the default toolbar, which has icons for text annotations, link annotations, 3D annotations, form fields, and buttons. In the animation below, we’ve added a PDF link annotation to the title area, making it a clickable area, and a text annotation that renders as a popup annotation:

Scribus - Inserting PDF annotations

Scribus can do many other things with PDFs, such as embedding Javascript code to enable dynamic behaviors and interactions. It’s also great for creating PDF presentations with transitions and interactivity.

7. Conclusion

In this article, we’ve seen some free and open-source Linux solutions that can easily handle multi-page PDFs, edit them, or simply add annotations.

We’ve learned how to use tools like Okular, Xournal++, Evince, PDFrankenstein, Inkscape, LibreOffice Draw, and Scribus to add comments, highlights, and drawings to PDF files.

These Linux solutions offer a lot of flexibility and control over PDF documents, but we’ve found that sometimes special arrangements are needed if we don’t have the same fonts embedded in the PDF on our machine.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.