Openning a png file in ubuntu, I can see the menu item for 'print to file'. How can I do the same on shell? PS: I prefer installing no extra package, due to lack of root access.
EDIT: the operating system is ubuntu 11.10
Openning a png file in ubuntu, I can see the menu item for 'print to file'. How can I do the same on shell? PS: I prefer installing no extra package, due to lack of root access.
EDIT: the operating system is ubuntu 11.10
convert xyz.png xyz.pdf
should do the trick.
See man convert
for more options.
As mentioned in a comment below, if you get a security error, you may need to edit the security policy file. For additional details see:
If you want to convert multiple images, e.g. png files, into one single pdf use convert with the specified pdf filename at the end
convert *.png mydoc.pdf
It will merge all png files into a sinlge mydoc.pdf file in a descendant order.
If converting each PNG file to separate PDF files is necessary:
for file in *.png; do convert ${file} ${file:0:-4}.pdf; done
This command takes all PNG files in a directory and produces PDF files with the same name.
convert
command? Might it be the case that your answer is valid only up to Imagemagick V6? V7 would need magick convert
? See: https://askubuntu.com/a/1315605/1157519 (Ah o.k. this thread is full with convert
... Then again, those are dated answers.)
– Levente
Dec 19 '22 at 23:16
$(ls *.png)
for looping over files. It's vulnerable for whitespace and unnecessarily verbose. Just use for file in *.png
, which is neither nor.
– user unknown
Dec 19 '22 at 23:54
17.png
will precede a file named2.png
). To preview the order in which they will be merged into the pdf file, you can use the commandecho *.png
. – Apr 10 '15 at 20:24attempt to perform an operation not allowed by the security policy
PDF'` – Cerin Apr 06 '23 at 21:02