The Wombelix Post - CUPShttps://dominik.wombacher.cc/2019-10-28T15:38:00+01:00Merge PDF Files on Linux2019-10-28T15:38:00+01:002019-10-28T15:38:00+01:00Dominik Wombachertag:dominik.wombacher.cc,2019-10-28:/posts/merge-pdf-files-on-linux.html<!-- SPDX-FileCopyrightText: 2023 Dominik Wombacher <dominik@wombacher.cc> -->
<!-- -->
<!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->
<p>I had to use Cups-PDF and "Print" bunch of Pages to Single PDF Files due to the fact that no Download as PDF was possible.
But how to Merge tons ... <a class="read-more" href="/posts/merge-pdf-files-on-linux.html"> [read more]</a></p><!-- SPDX-FileCopyrightText: 2023 Dominik Wombacher <dominik@wombacher.cc> -->
<!-- -->
<!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->
<p>I had to use Cups-PDF and "Print" bunch of Pages to Single PDF Files due to the fact that no Download as PDF was possible.
But how to Merge tons of files named as <strong>Pagetitle-job_id<Number></strong> on Linux via command line in a fast and easy way?</p>
<p>After some testing, <code>pdfunite</code> - included in <em>Poppler</em> and already installed on openSUSE Tumbleweed - did the job,
but the result with <code>pdftk</code> - included in <em>Ghostscript</em> - was nearly identical and worked the same way.</p>
<pre class="code text literal-block">
pdfunite $(ls -cr *.pdf) output.pdf
</pre>
<p>With <code>$()</code>, <code>ls</code> will executed and the results are added to the <code>pdfunite</code> command.</p>
<p>All PDF Files in the same Folder will be merged to a single <strong>output.pdf</strong> File.</p>
<p>The Parameter <code>-cr</code> sorts by creation time in reverse order.</p>
<p>That was necessary for me because the Job IDs were from 36 till 223, all other parameter mixed up the order and the merged PDF wasn't as expected.</p>