jpg to pdf

Convert JPG to PDF with Node.js API.

Looking to transform JPG images into PDF files quickly and accurately using Node.js? This guide walks you through how to implement JPG to PDF conversion using GroupDocs.Conversion Cloud SDK, perfect for creating print-ready, archived, or uneditable image-based documents.

Why to Convert JPG to PDF?

Whether you’re generating multi-page image reports, submitting visual evidence, or merging scans into a single file, PDF is the gold standard. Here are a few key benefits:

  • Preserve layout and image quality.
  • Secure format—ideal for read-only distribution.
  • Combine multiple images into one structured document.
  • Automate conversion in cloud-native apps.

This article covers the following topics:

REST API for JPG to PDF Conversion

Our GroupDocs.Conversion Cloud SDK for Node.js is a powerful API offering the capabilities to transform a variety of source files to supported output formats. With few lines of code, you can convert JPG to PDF format.

Getting Started

To begin, you’ll need:

  1. A GroupDocs Cloud dashboard account with API credentials.
  2. A sample JPG image for conversion.
  3. Node.js environment ready with the SDK installed:
npm install groupdocs-conversion-cloud --save

JPG to PDF Conversion in Node.js

Here’s how to perform the conversion step-by-step:

Step 1: Import SDK and configure API:

const { Configuration, ConvertApi, FileApi, UploadFileRequest, ConvertSettings, ConvertDocumentRequest } = require("groupdocs-conversion-cloud");
const config = new Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
const convertApi = new ConvertApi(config);
const fileApi = new FileApi(config);

Step 2: Now upload the JPG image to the Cloud storage:

const fs = require("fs");
const uploadRequest = new UploadFileRequest("source.jpg", fs.createReadStream("source.jpg"));
await fileApi.uploadFile(uploadRequest);

Step 3: Set conversion options for (JPG → PDF):

const settings = new ConvertSettings();
settings.filePath = "source.jpg";
settings.format = "pdf";
settings.outputPath = "converted/resultant.pdf";

const request = new ConvertDocumentRequest(settings);
await convertApi.convertDocument(request);
console.log("The JPG to PDF conversion completed successfully.");

Automate JPG to PDF Conversion using cURL

The usage of cURL commands for JPG to PDF conversion is an excellent choice for users who prefer a lightweight, code-free, or automated integration. It’s ideal if you want to automate the conversion in shell scripts or CI pipelines or systems that require programmatic API calls without writing a full SDK-based implementation.

Why Use REST API / cURL?:

  • Lightweight and scriptable.
  • No SDK installation needed.
  • Great for backend processing pipelines.

Now, generate your personalized Java Web Access Token and execute the following command to perform JPG to PDF conversion.

curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"{inputFile}\",  \"Format\": \"pdf\",  \"resultantPath\": \"{myResultant}\"}"

Please replace inputFile with the name of input JPG image, resultantPath with the name of resultant PDF file and ACCESS_TOKEN with a personalized JWT access token.

  • In order to save the resultant PDF to local drive, please try using the following cURL command:
curl -v "https://api.groupdocs.cloud/v2.0/conversion" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{  \"StorageName\": \"internal\",  \"FilePath\": \"input.jpg\",  \"Format\": \"pdf\"}"

Explore JPG to PDF Online (Free Tool)

If you want to try the capabilities of REST API without coding, try using our Free JPG to PDF Converter App for instant transformation. This online App is developed on top of GroupDocs.Conversion Cloud APIs.

jpg to pdf converter

Useful Resources

Final Thoughts

GroupDocs.Conversion Cloud SDK for Node.js offers a robust, cloud-based solution for converting JPG to PDF with ease. Whether you want to archive scanned documents, create eBook-style image reports, or automate image-based workflows—this API gives you the control and reliability you need.

We highly recommend visiting the following articles to learn more about: