77

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

126

convert xyz.png xyz.pdf should do the trick.

See man convert for more options.

| improve this answer | |
  • 16
    +1 - additionally you can use wildcards: convert *.png file.pdf – Geppettvs D'Constanzo Jun 30 '12 at 18:49
  • does this require extra packages? – Richard Jun 30 '12 at 19:27
  • 3
    Yes it requires the ImageMagick package, although it was there by default on my Ubuntu 12.04 – abhshkdz Jun 30 '12 at 19:29
  • 5
    Be careful if you use wildcards, files might not appear in the desired order, especially if filenames contain numbers (for example, a file named 17.png will precede a file named 2.png). To preview the order in which they will be merged into the pdf file, you can use the command echo *.png. – user396895 Apr 10 '15 at 20:24
  • 2
    convert-im6.q16: not authorized `h1.pdf' @ error/constitute.c/WriteImage/1037. – e-info128 Mar 12 at 22:13
16

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.

| improve this answer | |
  • 2
    convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408. – mathtick May 14 at 9:19
  • It seems more like a problem of a security policy of the environment you are working on. Sorry, I cannot say too much about that error. – EliuX May 15 at 1:54
  • Batch conversion of png to pdf has details on the 'convert-im6.q16' issue. – artless noise Oct 9 at 19:00
0

In 18.04 LTS, open image using ImageViewer; then print to file as a PDF.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.