DEV Community

Cover image for How to replicate a PDF template into multiple pages
Rohan Villoth
Rohan Villoth

Posted on

2 2

How to replicate a PDF template into multiple pages

I've been using poppler for command line operations on PDFs, like split, merge, conversions, etc., as part of my workflow. My usual use-case is merging PDFs generated from SVGs, like described here in my article on creating multipage PDF documents from SVGs. Using commands for stuff like this can improve efficiency and productivity, whereas most GUI based methods would've made this process more time consuming and repetitive. So, when I found my significant other manually duplicating inner pages for her Amazon KDP notebook template, I set out to find a command to automate it.

Surprisingly, I couldn't find a built-in method on any CLI tool to do this directly. So, I used my Google-Fu and got this two liner working:

for i in {1..120}; do cp template.pdf template-$i.pdf; done
pdfunite template-*.pdf merged.pdf
Enter fullscreen mode Exit fullscreen mode

The first command creates 120 copies of the template. Adjust the number as per your need. The second one then merges all these copies as pages into one PDF file. Make sure you have poppler-utils installed for pdfunite command to work. Windows users need to use a bash compatible shell like PowerShell or a Linux distro through WSL.

Credits & Sources

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay