iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📚
Merging a PNG Cover Image into a PDF File
Overview
A memo for myself. This is because the text content and cover image of a novel distributed on BOOTH were provided separately.
How to do it efficiently
First, convert the cover (PNG image) into a single-page PDF using ImageMagick. After that, since it is just a matter of merging multiple PDFs, you can use qpdf to merge them.
# Make sure to install ImageMagick beforehand
$ convert cover.png cover.pdf
# Similarly, install qpdf
$ qpdf --empty --pages cover.pdf text.pdf -- combined.pdf
For now, this accomplishes the goal.
Conclusion
If you do not specify the cover size options, the sizes of the text and cover might be inconsistent.
I didn't know how to fix this with qpdf (or rather, is it even possible?).
I managed to fix it by printing the merged PDF to PDF again using Windows print functionality, so that's fine.
That's all.
Discussion