How to add a cover to a pdf file from an image and from a bash command line?

Viewed 268

Given an image and a pdf file, say image.png and a file.pdf, I need to add the image as the first page of the pdf file, in order it has the same dimensions as the other pages, and in order to be recognized by any thumbnailer.

If I do :

size = `pdfinfo file.pdf | grep "Page size:" | awk '{print $3 "x" $5}'`
convert image.png -resize $size image.pdf && pdftk image.pdf file.pdf cat output tmp.pdf && mv tmp.pdf file.pdf

or instead of pdftk:

pdfunite image.pdf file.pdf tmp.pdf

The first page is created with the right size, but no thumbnail is created by the file manager as it is for other pdf files.

0 Answers
Related