DEV Community

Brandon Rozek
Brandon Rozek

Posted on • Originally published at brandonrozek.com on

Convert DJVU to PDF

I’ve recently come across the DJVU file format before and needed to convert it to a PDF. The most reliable way I’ve found to do it is via the following command.

djvups FILENAME | ps2pdf - OUTPUT_FILE

Enter fullscreen mode Exit fullscreen mode

Where FILENAME first gets converted to the PS file format which then gets converted to a PDF with the name OUTPUT_FILE. To make things easier, I wrote a little script that does this process automatically while preserving the filename.

#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

show_usage() {
    echo "Usage: djvu2pdf [FILENAME]"
    exit 1
}

if ["$#" -ne 1]; then
    show_usage
fi

if ! command -v djvups > /dev/null ; then
    echo "djvups not found. Exiting..."
    exit 1
fi

if ! command -v ps2pdf > /dev/null ; then
    echo "ps2pdf not found. Exiting..."
    exit 1
fi

djvups "$1" | ps2pdf - "${1%.*}.pdf"

Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay