
JPG is the most widely used image file format for storing compressed images. PDF, on the other hand, permits documents to be shared in a read-only format without compromising their style or layout. We may occasionally need to combine numerous JPG photos into a PDF document. In this article, we will learn how to merge JPG images into a PDF document using C#.
The following topics shall be covered in this article:
- C# API to Merge JPG Images into PDF
- Convert JPG to PDF in C#
- Append JPG Image in PDF using C#
- Merge Multiple JPG Images into PDF using C#
C# API to Merge JPG Images into PDF
For merging two or more JPG images into a PDF document, we will follow a two-step procedure. Firstly, we will be using Aspose.Imaging for .NET to convert JPG to PDF, and then we will merge them into a PDF document using GroupDocs.Merger for .NET API. Please either download the DLLs for the APIs or install them using NuGet.
PM> Install-Package Aspose.Imaging
PM> Install-Package GroupDocs.Merger
Convert JPG to PDF in C#
We can convert any JPG image into a PDF document by following the steps given below:
- Load a JPG image using the Image.Load() method.
- Finally, call the Image.Save() method to save the image as PDF. It takes output file path as an argument.
The following code sample shows how to convert a JPG to a PDF using C#.

Convert JPG to PDF in C#.
Append JPG Image in PDF using C#
We can append a JPG image into an existing PDF document by following the steps given below:
- Load a JPG image using the Image.Load() method.
- Convert loaded image to a PDF and save in FileStream using the Image.Save() method.
- Load an existing PDF using the Merger class.
- Call the Merger.Join() method to join the JPG converted PDF with the loaded PDF.
- Finally, call the Merger.Save() method to save the merged PDF. It takes output file path as an argument.
The following code sample shows how to append a JPG image into an existing PDF document using C#.

Append JPG Image in PDF using C#.
Merge Multiple JPG Images into PDF using C#
We can merge multiple JPG images into a PDF document by following the steps given below:
- Read all JPG image files from a directory one by one.
- Load a JPG image using the Image.Load() method.
- Convert the first image to PDF and save the file on a local disk. Otherwise, convert and save in FileStream.
- Load previously saved PDF using the Merger class.
- Call the Merger.Join() method to join the JPG converted PDF with the loaded PDF.
- Finally, call the Merger.Save() method to save the merged PDF. It takes output file path as an argument.
The following code sample shows how to merge multiple JPG images into a PDF document using C#.

Merge Multiple JPG Images into PDF using C#.
Get a Free License
Please try the API without evaluation limitations by requesting a free temporary license.
Conclusion
In this article, we have learned how to:
- save JPG image as a PDF document in C#;
- insert an image in a PDF document programmatically;
- combine multiple images in a PDF document.
Besides, you can learn more about Aspose.Imaging for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.