Free

Free coded apps to suit all. No sign up, no email, usable offline, updates when I can, feedback welcome. Send feedback

Workflows

Using PDF by Zaweba from the command line

Inspect a PDF, render a page to PNG or extract text without opening a window, using ZawebaPDF.exe options, passwords and clear exit codes.

Using PDF by Zaweba from the command line

Not every PDF job needs a window. Pulling the text out of a hundred invoices, making a preview picture of the first page of each report, or checking a folder of files for problems are jobs for a script. PDF by Zaweba can be run from the command line for exactly these, using the same engine that powers the app.

The commands

There are three main jobs. --inspect file.pdf reports on a file, telling you about the document. Add --json and the report comes out as JSON, which is easy for another program or script to read.

--render file.pdf --page 3 --dpi 150 --out page.png draws a page as a picture. You choose the page, the resolution in dots per inch and the output file. A low dpi makes quick thumbnails; a higher one makes images good enough for print or close inspection.

--extract-text file.pdf pulls out the text. Add --pages 1-3,7 to take only some pages, and --out text.txt to write it to a file rather than to the screen.

For protected documents, --password supplies the password. And --cli-help lists all the options, which is the place to start if you forget one.

All of these run through ZawebaPDF.exe, the program itself, so there is nothing extra to install.

Exit codes

Scripts need to know whether a command worked. ZawebaPDF.exe returns 0 when the job is done, 1 when it failed, 2 when the arguments were wrong and 3 when a password is needed or the one given was wrong. Check the code after each run and a script can handle problems properly. For example, it can set aside files that need a password, rather than treating every failure the same way.

Jobs you can automate

Text extraction is the most common. Run it over a folder of PDFs and you have plain text files ready to search, index or feed to another program. Using --pages, you can pull just the first page of each, where the invoice number and date usually are.

Rendering makes previews. A script can render page 1 of every PDF in a folder to a PNG, giving you a set of thumbnails for a catalogue, a website or a quick visual check of a batch of exports.

Inspecting with --json is useful for checks. A script can read the report and flag files that don't meet some rule you care about, before they are sent anywhere.

Tips for scripting

Quote file paths that contain spaces, as you would with any command on Windows.

Handle exit code 3 on its own. Files that need a password are common in batches from banks and accounts systems, and treating them as a separate pile saves confusion.

Try each command on one file before running it over a folder, and look at the output to check it is what you need.

Keep passwords out of scripts you share. If you pass one with --password, think about where that script is stored and who can read it.

Why it is there

The same fast engine that opens a large PDF in a blink in the app does the work here, offline, on your own PC. For anyone who handles PDFs in bulk, the command line turns PDF by Zaweba from a viewer and editor into a tool that can quietly do repetitive jobs in the background.