logoalt Hacker News

Beijingeryesterday at 5:20 AM3 repliesview on HN

#!/bin/bash

# Convert images to PDF

img2pdf *.jpg -o images.pdf

# Merge PDFs

pdfunite file1.pdf file2.pdf images.pdf merged.pdf

# Compress

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \ -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed.pdf merged.pdf

# Remove unwanted pages (e.g., page 3)

pdftk compressed.pdf cat 1-2 4-end output final.pdf

# Add page numbers

pdfjam final.pdf --outfile final_numbered.pdf --pagecommand '{}' --landscape


Replies

philjohnsonyesterday at 5:23 AM

I'll be adding compression support for BreezePDF, so this can be done in a click

show 1 reply
denfromufayesterday at 5:24 AM

This is very cool, are all these command-line tools open-source?

show 1 reply
2Gkashmiriyesterday at 5:26 AM

You know what. I will share my script in the morning.

I used scantailor go scan a book. That gave out tif files.

So I built a script to convert them to jpg, then merge into PDF. Then OCR and add the text layer on PDF. Then compress.

I know this for a niche automation..... web OTOH where normies reside and are scared by terminal, it wont work.

Been using pdftk for years now but im only person who can use it in my office.