How to convert JPG to PDF

PDF documents are used for just about anything these days, and are usually considered to be a very professional way to send important data such as contracts or terms for businesses and other formal entities. If you have a JPG image – perhaps the scan of a signed document, for example – you can convert this to a PDF document, which would be a more formal file extension to use for such a matter. In this tutorial, you will learn how to convert a JPG image to a PDF document on a Linux system via command line and GUI.

In this tutorial you will learn:

  • How to convert JPG to PDF via GUI
  • How to convert JPG to PDF via command line
How to convert JPG to PDF
How to convert JPG to PDF
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software ImageMagick, LibreOffice
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to convert JPG to PDF (command line)




The ImageMagick software suite makes conversion from JPG to PDF a breeze on the command line. It is free and easy to install from the official software repository on any Linux distro, and you may find that it comes in handy for lots of other image manipulation tasks down the road.

You can use the appropriate command below to install ImageMagick with your system’s package manager.

To install ImageMagick on Ubuntu, Debian, and Linux Mint:

$ sudo apt install imagemagick

To install ImageMagick on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install imagemagick

To install ImageMagick on Arch Linux and Manjaro:

$ sudo pacman -S imagemagick

After ImageMagick has been installed, check out the command examples below to see how to convert JPG to PDF with the convert Linux command.

  1. To convert a single JPG image to PDF format, try the following convert command syntax:
    $ convert image.jpg -auto-orient document.pdf
    

    The previous command will convert an image with the name image.jpg to a PDF document named document.pdf.

    NOTE
    The -auto-orient option will read the EXIF metadata (if present) of your JPG image to figure out how to orient the image before making it into a PDF document. This option is not strictly necessary, but is recommended so the images do not turn out rotated incorrectly.
  2. If you have multiple JPG images that you want to place into a single PDF document, you can use a wildcard character in your command to select all the images:


    $ convert *.jpg -auto-orient document.pdf 
    
  3. Or to convert the other way (PDF to JPG):
    $ convert document.pdf image.jpg
    

How to convert JPG to PDF (GUI)

One of the easiest ways to convert a JPG to PDF from the desktop environment would be with LibreOffice, a common suite of software that is often installed by default or can easily be installed with the system package manager. Follow the step by step instructions below to convert one or more JPG images to PDF with LibreOffice:

  1. Start by opening LibreOffice. More specifically, the LibreOffice Writer application.
    Opening LibreOffice Writer from the system application launcher
    Opening LibreOffice Writer from the system application launcher
  2. Now that you are loaded into a new, blank document, access the Insert > Image option from the top menu bar.
    Accessing the image insertion menu in LibreOffice
    Accessing the image insertion menu in LibreOffice
  3. Select one or more JPG images from the file browser, then click ‘Open.’
    Inserting an image into a LibreOffice Writer document
    Inserting an image into a LibreOffice Writer document
  4. With our image now inserted into the LibreOffice document, go to the File > Export As > Export As PDF option at the top.
    Access the 'Export As PDF' option in LibreOffice Writer
    Access the ‘Export As PDF’ option in LibreOffice Writer
  5. On the next menu, you can configure all of your pertinent PDF settings. Perhaps the most relevant are the JPG compression options, which allow you to decide how much quality versus size you want to retain in your final document. When done, click on ‘Export’ and pick a location on your computer to save the document.
    The PDF Options menu that shows before exporting a PDF
    The PDF Options menu that shows before exporting a PDF


Closing Thoughts

In this tutorial, we saw how to convert a JPG image into a PDF document on a Linux system. There are numerous ways to perform this task, with ImageMagick making the process easy via the command line, and LibreOffice being the go to method for the GUI method. Whether this is just a one off circumstance where you need to convert a JPG image, or you need to bulk convert to PDF on a regular basis, both tools make the process painless and easy for Linux users.



Comments and Discussions
Linux Forum