The conversion of JPG images to PDF is a common requirement when dealing with document archiving or printing. The PDF provides better compatibility, professional formatting, and easier file handling comparing to JPEG images. In this article, you will learn how to convert JPG to PDF in C# using the Aspose.PDF Cloud SDK for .NET — a powerful and scalable REST API for document automation.

API for JPG to PDF Conversion

By using Aspose.PDF Cloud SDK for .NET, you can easily transform JPG image to well-structured PDF documents. It ensures high-quality output and offers full control over page layout, image alignment, resolution, and more — all without needing third-party tools or Microsoft Office installation.

Key Features of API:

  • Supports conversion of JPG and other image formats (PNG, BMP, etc.) to PDF
  • Set page size, margins, image alignment, and scaling
  • Works entirely via REST API and is platform-independent
  • Secure, cloud-based architecture with OAuth 2.0 support

Install Aspose.PDF Cloud SDK for .NET:

Use NuGet to install the SDK into your .NET application:

Install-Package Aspose.PDF-Cloud

Sign up at the Aspose Cloud Dashboard to get your Client ID and Client Secret.

Convert JPG to PDF in C# with .NET SDK

Below is a simple example of converting a JPG file to PDF using C# and the Aspose.PDF Cloud SDK:

  • Firstly, create an instance of Configuration where we pass client credentials.
  • Secondly, initialize an object of PdfApi while passing Configuration object.
  • Thirdly, upload in input JPG image to cloud storage using UploadFileRequest.
  • Now, create an object of PostInsertImageRequest where we define resultant PDF properties.
  • Finally, call the PostInsertImage(…) API to perform the JPG to PDF conversion.
JPEG to PDF online

Image:- JPG to PDF conversion preview.

Convert JPEG to PDF Using cURL

You can also perform the conversion using cURL and REST API calls.

  1. Get Access Token:
curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"
  1. Create a blank PDF:
curl -v -X PUT "https://api.aspose.cloud/v3.0/pdf/input.pdf" \
-H  "accept: application/json" \
-H  "authorization: Bearer {accessToken}"
  1. Insert JPEG into PDF:
curl -v "https://api.aspose.cloud/v3.0/pdf/{sourceFile}/pages/1/images?llx=1&lly=1&urx=680&ury=850&imageFilePath={sourceImage}&storage=basic" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {YOUR_ACCESS_TOKEN}" \
-H "Content-Type: multipart/form-data"

Replace {ACCESS_TOKEN} and sourceImage with your actual token and image path in cloud storage.

Try JPG to PDF Online (No Code Required)

If you prefer a quick visual conversion? Try our free JPG to PDF Online Converter to test the process instantly without any coding.

jpg to pdf

Free JPEG to PDF Converter App.

Conclusion

With Aspose.PDF Cloud SDK for .NET, converting JPG to PDF is straightforward, reliable, and scalable for any .NET application. Whether through C# or RESTful API, you can automate image-to-PDF workflows with precision and speed. Use it for document automation, secure image sharing, or high-quality archiving.

We highly recommend visiting the following blog posts for information on: