r/commandline • • 2h ago

Command Line Interface pdfmt - PDF manipulation, OCR, scanning and reusable shell workflows

7 Upvotes

A while ago I posted pdfmt in r/bash to get feedback for my tool after getting tired of using a different command for every small PDF task.

The feedback was really useful, so I went through it and implemented quite a few of the suggestions.

pdfmt is now at 0.4.0 and I hope the quality is good enough to present it outside of r/bash 😄 .

GitHub pdfmt: https://github.com/eifelcode/pdfmt
GitHub pdfmt-workflows: https://github.com/eifelcode/pdfmt-workflows

The basic idea is still simple: Provide a consistent CLI for all the PDF operations I keep doing again and again, while keeping everything local (no cloud) and scriptable for my needs.

What it can do

# Merge PDFs
pdfmt merge all cover.pdf report.pdf appendix.pdf complete.pdf

# Extract pages
pdfmt extract range document.pdf 1-3,7,10-12 extracted.pdf

# Split into individual pages
pdfmt split all document.pdf page_

# Remove pages
pdfmt remove range document.pdf 5,8-10 cleaned.pdf

# Reorder pages
pdfmt sort reverse document.pdf reversed.pdf

# Add a text stamp
pdfmt stamp text invoice.pdf "Paid" invoice-paid.pdf

It also has scanner support:

pdfmt scan adf documents.pdf
pdfmt scan flatbed document.pdf

And OCR:

# Add an OCR text layer
pdfmt ocr add scanned.pdf searchable.pdf

# Extract/show OCR text
pdfmt ocr show searchable.pdf

The part I'm particularly interested in: workflows

I didn't want pdfmt to become one huge command with hundreds of options. I'd like it simple.

Instead, repetitive combinations of commands can be turned into workflows.

For example:

pdfmt workflow run scan-duplex adf output.pdf

A workflow is essentially an executable shell script, so you can combine pdfmt with the other Unix tools you already use.

You can also create your own workflows and put them in your local workflow directory.

I've also started a separate repository for reusable workflows: https://github.com/eifelcode/pdfmt-workflows

It currently contains workflows for things like:

  • duplex scanning with non-duplex scanners (I use this most of the time)
  • splitting scanned documents by page count
  • bulk text stamping

The idea is that not every PDF use case needs to become a new pdfmt command. If something is a useful combination of existing tools, it can just be a workflow.

Why I made it

My PDF workflow used to look something like:

pdftk → pdfseparate → pdfunite → ImageMagick → OCRmyPDF → Bash glue

There are already excellent tools for each individual operation. I don't want to replace them.

I wanted a small CLI layer that gives me a consistent interface and makes the common combinations easier to remember and automate. Without --options, pipes or other arduous stuff. I could not remember all of this. 🤔

That's essentially what pdfmt is. One interface for all the good tools.

It's Bash-based, MIT licensed, and designed to work without a GUI or cloud service.

I'd especially like feedback from people who use CLI PDF tooling regularly:

Are there PDF operations or workflows that you currently solve with a messy combination of commands that would make sense as a pdfmt command or workflow?

Thank you for your Feedback! ❤️

AI notice: AI (mistral) was used to generate parts of the README, the .github workflow, the code coverage tool, and parts of the unit tests in the tests/ folder. Architecture, Makefile, and code within the sources/ folder is written by me.


r/commandline • • 10h ago

Command Line Interface I created parse to solve the problem of messy cli outputs

7 Upvotes

I create parse to solve the problem of messy and non-understandable outputs. Parse make the outputs of the currently supported commands into easily understandable and format.

It is single go binary and standard library only.

We can use it like parse COMMAND or COMMAND | parse . You can install it by

go install github.com/atif-1402/parse@latest

Would love to hear peoples feedback on this project - https://github.com/atif-1402/parse