PDF to JPG API

Convert PDF Pages to High-Quality JPG Images Programmatically.

hero banner

Code Examples in Popular Languages

Integrate our PDF to JPG API easily into your apps with comprehensive code examples in popular languages to get started quickly.

CURL Request
curl --location 'https://theonlineconverter.com/api/v1/document-converter' \
--header 'Content-Type: application/json' \
--header 'x-api-key: enter_your_api_key' \
--form 'from="pdf"' \
--form 'to="jpg"' \
--form 'file=@"/D:/data/Document/pdf/other.pdf"'
JavaScript Fetch
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("x-api-key", "enter_your_api_key");

const formdata = new FormData();
formdata.append("from", "pdf");
formdata.append("to", "jpg");
formdata.append("file", fileInput.files[0], "/D:/data/Document/pdf/other.pdf");

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: formdata,
  redirect: "follow"
};

fetch("https://theonlineconverter.com/api/v1/document-converter", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
Ruby Net::HTTP
import requests
import json

url = "https://theonlineconverter.com/api/v1/document-converter"

payload = {'from': 'pdf',
'to': 'jpg'}
files=[
  ('file',('other.pdf',open('/D:/data/Document/pdf/other.pdf','rb'),'application/pdf'))
]
headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'enter_your_api_key'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
Python Requests
import requests
import json

url = "https://theonlineconverter.com/api/v1/document-converter"

payload = {'from': 'pdf',
'to': 'jpg'}
files=[
  ('file',('other.pdf',open('/D:/data/Document/pdf/other.pdf','rb'),'application/pdf'))
]
headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'enter_your_api_key'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)
PHP Guzzle
<?php
$client = new Client();
$headers = [
  'Content-Type' => 'application/json',
  'x-api-key' => 'enter_your_api_key'
];
$options = [
  'multipart' => [
    [
      'name' => 'from',
      'contents' => 'pdf'
    ],
    [
      'name' => 'to',
      'contents' => 'jpg'
    ],
    [
      'name' => 'file',
      'contents' => Utils::tryFopen('/D:/data/Document/pdf/other.pdf', 'r'),
      'filename' => '/D:/data/Document/pdf/other.pdf',
      'headers'  => [
        'Content-Type' => '<Content-type header>'
      ]
    ]
]];
$request = new Request('POST', 'https://theonlineconverter.com/api/v1/document-converter', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
Java HttpURLConnection
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("from","pdf")
  .addFormDataPart("to","jpg")
  .addFormDataPart("file","/D:/data/Document/pdf/other.pdf",
    RequestBody.create(MediaType.parse("application/octet-stream"),
    new File("/D:/data/Document/pdf/other.pdf")))
  .build();
Request request = new Request.Builder()
  .url("https://theonlineconverter.com/api/v1/document-converter")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("x-api-key", "enter_your_api_key")
  .build();
Response response = client.newCall(request).execute();
Go net/http
package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "os"
  "path/filepath"
  "net/http"
  "io"
)

func main() {

  url := "https://theonlineconverter.com/api/v1/document-converter"
  method := "POST"

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  _ = writer.WriteField("from", "pdf")
  _ = writer.WriteField("to", "jpg")
  file, errFile3 := os.Open("/D:/data/Document/pdf/other.pdf")
  defer file.Close()
  part3,
         errFile3 := writer.CreateFormFile("file",filepath.Base("/D:/data/Document/pdf/other.pdf"))
  _, errFile3 = io.Copy(part3, file)
  if errFile3 != nil {
    fmt.Println(errFile3)
    return
  }
  err := writer.Close()
  if err != nil {
    fmt.Println(err)
    return
  }


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("x-api-key", "enter_your_api_key")

  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
C# HttpClient
var options = new RestClientOptions("https://theonlineconverter.com")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("/api/v1/document-converter", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-api-key", "enter_your_api_key");
request.AlwaysMultipartFormData = true;
request.AddParameter("from", "pdf");
request.AddParameter("to", "jpg");
request.AddFile("file", "/D:/data/Document/pdf/other.pdf");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);

Key Features & Capabilities

Our API is equipped with powerful features for high-quality and flexible PDF to JPG conversions.

Simple User Interface

High-Quality Rasterization

Convert PDF pages into crisp, clear JPG images. Control the output resolution by setting the DPI (Dots Per Inch) to meet your quality requirements.

Simple Data Format

Selective Page Conversion

Optimize your workflow by converting all pages of a PDF or specifying individual pages and ranges to be converted into images.

Time

Adjustable Image Quality

Balance file size and image clarity by setting the JPG compression quality level, perfect for optimizing images for web use.

Secure Data

Handles Any PDF Type

Seamlessly convert pages from both native and scanned (image-based) PDFs into JPG images with consistent, high-fidelity results.

Universal Access

Fast & Scalable Performance

Engineered for speed, our API can quickly process and convert large PDFs, scaling to handle high-volume requests for generating thumbnails or previews on the fly.

Freedom

Secure & Confidential

All files are processed over encrypted connections. We guarantee document confidentiality with a strict data privacy policy and do not store your files.

Frequently Asked Questions

Find answers to common questions about our PDF to JPG API to help you integrate and use the service effectively.

You can set the DPI (Dots Per Inch) value in your API request. A higher DPI, such as 300, will result in a higher resolution and better quality image, while a lower DPI, like 72 or 96, is suitable for screen previews.

Yes. The `pages` parameter allows you to specify any page or range. To convert only the first page, you would simply set it to "1".

The API will return a downloadable ZIP file containing all the generated JPG images, typically named sequentially (e.g., page_1.jpg, page_2.jpg). Alternatively, you can request a JSON response with individual download links.

Absolutely. The API rasterizes the entire page, so it works perfectly for both scanned PDFs that are image-based and native PDFs with text and vector graphics.

DPI determines the resolution (the number of pixels in the image). Image Quality is a JPG compression setting (0-100) that affects the file size and visual artifacts; higher quality means a larger file size.

Our API is designed to handle large PDF files. Specific size and page count limits are based on your subscription plan and can be found in our documentation.

Yes. Security is a top priority. All file transfers are encrypted, and your files are permanently deleted from our servers immediately after the conversion is completed.