website/content/blog/convert-djvu-to-pdf.md

46 lines
1,008 B
Markdown
Raw Normal View History

2021-08-28 02:03:42 +00:00
---
2023-02-19 02:37:22 +00:00
date: 2021-08-28 02:00:00
2021-08-28 02:03:42 +00:00
draft: false
math: false
2023-01-05 19:04:45 +00:00
medium_enabled: true
2023-02-19 02:37:22 +00:00
medium_post_id: ddf23ae64f9a
tags: []
title: Convert DJVU to PDF
2021-08-28 02:03:42 +00:00
---
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.
```bash
djvups FILENAME | ps2pdf - OUTPUT_FILE
```
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.
```bash
#!/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"
2023-02-19 02:37:22 +00:00
```