Install pdfcpu on Ubuntu 24.04

Install pdfcpu on Ubuntu 24.04

The pdfcpu is a command line tool and library written in Go programming language that allows users to process and manipulate PDF files. It provides a variety of functions for handling PDF documents. This tutorial explains how to install pdfcpu on Ubuntu 24.04.

Install pdfcpu

Get the most recent version of pdfcpu from its GitHub repository and assign it to a variable:

PDFCPU_VERSION=$(curl -s "https://api.github.com/repos/pdfcpu/pdfcpu/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')

Download the tar.gz file using the version obtained earlier:

wget -qO pdfcpu.tar.xz https://github.com/pdfcpu/pdfcpu/releases/latest/download/pdfcpu_${PDFCPU_VERSION}_Linux_x86_64.tar.xz

Create temporary directory and extract a tar.gz file:

mkdir pdfcpu-temp
tar xf pdfcpu.tar.xz --strip-components=1 -C pdfcpu-temp

Move executable to /usr/local/bin directory:

sudo mv pdfcpu-temp/pdfcpu /usr/local/bin

This command allows us to check the pdfcpu version:

pdfcpu version

Remove the redundant archive and directory:

rm -rf pdfcpu.tar.xz pdfcpu-temp

Testing pdfcpu

Download sample PDF file for testing:

wget -qO test.pdf https://raw.githubusercontent.com/py-pdf/sample-files/master/003-pdflatex-image/pdflatex-image.pdf

The pdfcpu command supports various operations. For example, the following command can be used for extracting images from a PDF:

pdfcpu extract -m image test.pdf .

Images are saved to the current directory.

Uninstall pdfcpu

To remove pdfcpu, delete the associated file:

sudo rm -rf /usr/local/bin/pdfcpu

We can also remove pdfcpu configuration directory:

rm -rf ~/.config/pdfcpu

Leave a Comment

Cancel reply

Your email address will not be published.