mutool is a command-line PDF toolkit

MuPDF

Open-source PDF toolkit MuPDF has been under development in one form or another since 2002, and over the years it’s built up a host of document viewing, conversion and extraction features.

The package doesn’t get the attention it deserves on Windows -- probably because the key tools are console-based -- but if you don’t mind spending time at the command line, it’s certainly worth a look.

Advertisement

As with many similar applications, running mutool at the command line displays its core commands: draw, run, clean, extract, info, pages, poster, show, create and merge.

Entering mutool followed by one of those commands, like mutool draw, displays more specific information.

This can simpler than you’d expect. Here’s a good starter example.

mutool extract test.pdf 3-5

This extracts all PDF resources -- images, fonts etc -- from pages 3-5 of the file test.pdf, and saves them to the current folder.

Moving on to the "Draw" command gives you the ability to render PDFs in another format. Options include rotations, resolution, color settings, gamma correction, page width and height controls, the password (if the source is password-protected), and many different output formats: PNG, SVG, HTML, PS, TXT and more.

Here’s an example of how that might be used.

mutool draw -o p%d.png -r 300 test.pdf

This command takes test.pdf as its input, converts each page to PNG with a resolution of 300dpi, saving the image with the file naming scheme we’ve described (p1.png, p2.png).

If you need to merge some files, try a command like this.

mutool merge -o out.pdf file1.pdf file2.pdf file3.pdf

That’s looks simple -- create a file out.pdf, then append all the following pdfs -- but there are further options you can apply to, say, clean content streams or linearize the output PDF.

This is just the start, and there’s much more to explore. To take one unusual example, a "poster" command splits large pages into custom-sized tiles, not something you could easily do in other ways.

Getting the more complex commands working can take a while, and the help isn’t always very helpful. For instance, enter "mutool draw" and you’ll be given a basic usage of "mudraw [options] file [pages]", but the "mudraw" dates from when the command was a separate executable, and if you try to use it you’ll get nowhere. You must start the command with "mutool draw", instead.

Fortunately, mutool has so much functionality that we can forgive its occasional quirks, and if you’re comfortable at the command line and need to automate these kind of PDF-handling tasks, it should save you a lot of time.

MuPDF is available for Windows.

Comments are closed.

© 1998-2022 BetaNews, Inc. All Rights Reserved. Privacy Policy - Cookie Policy.