# Convert Image to PDF and PDF to Image (`akash9078/image-pdf-converter`) Actor

Convert images (JPG, PNG, BMP, and more) into high-quality PDFs, or extract images from PDF files in seconds. Image–PDF Converter Pro delivers fast, reliable, and professional results for all your document and image conversion needs.

- **URL**: https://apify.com/akash9078/image-pdf-converter.md
- **Developed by:** [Akash Kumar Naik](https://apify.com/akash9078) (community)
- **Categories:** Automation, Developer tools, Other
- **Stats:** 52 total users, 5 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Image and PDF Converter

**Transform images to PDFs and PDFs to images with professional quality.** This Apify Actor provides bidirectional conversion between images (JPEG, PNG, BMP) and PDF documents, featuring high-resolution output, optional watermarking, and flexible page-merging. Perfect for document archiving, content creation, OCR pipelines, and cross-platform workflows.

### Table of Contents

- [Key Features](#key-features)
- [How It Works](#how-it-works)
- [Input Parameters](#input-parameters)
- [Output Format](#output-format)
- [Quick Start](#quick-start)
- [Pricing](#pricing)
- [Examples](#examples)
- [Troubleshooting](#troubleshooting)
- [Support](#support)

***

### Key Features

- **Bidirectional Conversion** — Convert images → PDF and PDF → images in a single Actor
- **Auto-Detection** — Automatically detects file type and picks the right conversion direction
- **High-Resolution Output** — Configurable scale factor (default 3×) for crisp, OCR-ready images
- **Quality Control** — Adjust compression quality (1–100) to balance file size vs. fidelity
- **Custom Watermarking** — Add text watermarks with configurable opacity, font size, color, and position
- **Merge Mode** — Combine all PDF pages into one composite image for previews or social sharing
- **Cloud Storage Support** — Process files directly from Google Drive, Dropbox, or any public URL
- **Pay-Per-Event Pricing** — Only pay for what you convert; no flat subscription fees

***

### How It Works

1. Provide a direct URL to your image or PDF file
2. Choose a conversion direction (`auto`, `imageToPdf`, or `pdfToImages`)
3. Optionally configure quality, watermark, and merge settings
4. The Actor downloads the file, converts it, stores the result in the Apify Key-Value Store, and pushes a dataset record with the output URL

***

### Input Parameters

| Field | Type | Required | Default | Description |
|:------|:-----|:--------:|:-------:|:------------|
| `url` | `String` | ✅ | — | Direct URL to the image or PDF file (supports Google Drive, Dropbox, and public URLs) |
| `conversionDirection` | `String` | | `"auto"` | `auto` detects file type automatically; or force `imageToPdf` / `pdfToImages` |
| `quality` | `Integer` | | `100` | Output quality 1–100 (higher = better quality, larger file) |
| `mergeOutput` | `Boolean` | | `false` | When converting PDF → images, merge all pages into a single image file |

#### Example Input

```json
{
    "url": "https://www.africau.edu/images/default/sample.pdf",
    "conversionDirection": "auto",
    "quality": 90,
    "mergeOutput": false
}
```

#### Watermarked Image-to-PDF Example

```json
{
    "url": "https://example.com/photo.jpg",
    "conversionDirection": "imageToPdf",
    "quality": 95,
    "watermark": {
        "text": "© 2025 My Company",
        "opacity": 0.4,
        "fontSize": 28,
        "color": "gray",
        "position": "bottom-right"
    }
}
```

***

### Output Format

Results are stored in the **Apify Dataset** and the converted files are saved in the **Key-Value Store**.

#### Successful Record (Image → PDF)

```json
{
    "inputUrl": "https://example.com/photo.jpg",
    "fileName": "photo.jpg",
    "conversionType": "imageToPdf",
    "outputUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/result_1234567890.pdf",
    "outputKey": "result_1234567890.pdf"
}
```

#### Successful Record (PDF → Images, one record per page)

```json
{
    "inputUrl": "https://example.com/document.pdf",
    "fileName": "document.pdf",
    "conversionType": "pdfToImages",
    "outputUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/result_page_1_1234567890.png",
    "outputKey": "result_page_1_1234567890.png",
    "page": 1
}
```

#### Error Record

```json
{
    "inputUrl": "https://example.com/broken.pdf",
    "status": "error",
    "errorCode": "CONVERSION_ERROR",
    "message": "Failed to process file: HTTP error! status: 403"
}
```

***

### Quick Start

1. Open the **Image and PDF Converter** Actor on [Apify Console](https://console.apify.com)
2. Click **"Try for free"**
3. Paste your file URL into the `url` field
4. Set `conversionDirection` to `auto` (or choose explicitly)
5. Click **"Start"** and monitor the run
6. Download your converted file from the **Output** tab or via the dataset record URL

***

### Pricing

This Actor uses **Pay-Per-Event (PPE)** pricing — you are only charged for what you actually use:

| Event | Event Name | Price |
|:------|:-----------|------:|
| Actor start (synthetic, auto-charged by Apify) | `apify-actor-start` | **$0.00005** per start |
| File converted (image → PDF or PDF → images) | `converted-file` | **$0.005** per file |
| PDF page extracted (PDF → images, per page) | `extracted-page` | **$0.005** per page |

> The `apify-actor-start` event is automatically charged by Apify and covers the first 5 seconds of compute cost. You do **not** need to charge it manually in your code.

#### Cost Examples

| Task | Cost Breakdown | Total |
|:-----|:---------------|------:|
| Convert 1 image to PDF | $0.00005 (start) + $0.005 (file) | **~$0.005** |
| Convert a 10-page PDF to images | $0.00005 (start) + $0.005 (file) + 10 × $0.005 (pages) | **~$0.055** |
| Convert 100 images to PDFs | $0.00005 (start) + 100 × $0.005 (files) | **~$0.50** |

#### Spending Limits

Users can set a **maximum spend per run** in the Apify Console. The Actor respects this limit — if the budget is reached mid-run, it stops gracefully and outputs whatever has been converted so far.

> **Free tier:** New Apify accounts include free platform credits. Check [Apify Pricing](https://apify.com/pricing) for current free tier limits.

***

### Examples

#### Convert PDF to High-Resolution Images (for OCR)

```json
{
    "url": "https://example.com/document.pdf",
    "conversionDirection": "pdfToImages",
    "quality": 100
}
```

Produces one dataset record per page with a direct image URL — ideal for feeding into OCR or AI vision models.

#### Merge All PDF Pages into One Image

```json
{
    "url": "https://example.com/multi-page.pdf",
    "conversionDirection": "pdfToImages",
    "mergeOutput": true,
    "quality": 90
}
```

All pages are stacked vertically into a single PNG — great for document previews or social media thumbnails.

#### Convert Image to Watermarked PDF

```json
{
    "url": "https://example.com/photo.png",
    "conversionDirection": "imageToPdf",
    "quality": 95,
    "watermark": {
        "text": "CONFIDENTIAL",
        "opacity": 0.6,
        "fontSize": 30,
        "color": "red",
        "position": "center"
    }
}
```

***

### Troubleshooting

#### "File is corrupted or empty"

- Ensure the URL is publicly accessible (no login required)
- Check that the file is not password-protected or empty

#### "Unsupported file format"

- Supported image formats: **JPEG, PNG, BMP**
- Supported document format: **PDF**
- Verify the file extension matches the actual content type

#### "HTTP error! status: 403 / 404"

- The URL may require authentication or the file has been moved/deleted
- For Google Drive: make sure sharing is set to **"Anyone with the link"**

#### Low image quality for OCR

- The default scale factor (3×) already produces ~216 DPI equivalent output
- For very fine text, try passing `"scale": 4.0` via the `pdfOptions` field

#### Performance Tips

- Use `mergeOutput: false` (default) for large PDFs to avoid memory spikes
- Higher quality settings increase processing time and output file size
- Watermarking adds minimal overhead

***

### Support

- **Issues & Feature Requests:** Use the [Issues tab](https://console.apify.com/actors/issues) on the Actor page
- **Community:** Join the [Apify Discord](https://discord.gg/apify) to connect with other developers
- **Documentation:** [Apify Docs](https://docs.apify.com/) for platform guidance

# Actor input Schema

## `url` (type: `string`):

Direct URL to an image (JPEG, PNG, BMP) or PDF file. Supports Google Drive, Dropbox, and other shared links.

## `conversionDirection` (type: `string`):

Auto-detect based on file type, or force a specific conversion direction.

## `quality` (type: `integer`):

Output quality for JPEG images (1-100). Higher values mean better quality but larger file size.

## `watermark` (type: `string`):

Text to add as a watermark on each page (optional). Leave empty for no watermark.

## `pageSize` (type: `string`):

Page size when converting images to PDF.

## `orientation` (type: `string`):

Page orientation when converting images to PDF.

## `resolution` (type: `integer`):

Output resolution when converting PDF to images (72-600 DPI). Higher values mean sharper images.

## `mergeOutput` (type: `boolean`):

When converting PDF to images, merge all pages into a single image output.

## Actor input object example

```json
{
  "url": "https://images.unsplash.com/photo-1776377231754-d36928e6ee4d?q=80&w=1170",
  "conversionDirection": "auto",
  "quality": 90,
  "watermark": "",
  "pageSize": "A4",
  "orientation": "portrait",
  "resolution": 150,
  "mergeOutput": false
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset containing all conversion results

## `outputFiles` (type: `string`):

Key-value store containing converted files

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "url": "https://images.unsplash.com/photo-1776377231754-d36928e6ee4d?q=80&w=1170",
    "conversionDirection": "auto",
    "quality": 90,
    "watermark": "",
    "pageSize": "A4",
    "orientation": "portrait",
    "resolution": 150,
    "mergeOutput": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("akash9078/image-pdf-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "url": "https://images.unsplash.com/photo-1776377231754-d36928e6ee4d?q=80&w=1170",
    "conversionDirection": "auto",
    "quality": 90,
    "watermark": "",
    "pageSize": "A4",
    "orientation": "portrait",
    "resolution": 150,
    "mergeOutput": False,
}

# Run the Actor and wait for it to finish
run = client.actor("akash9078/image-pdf-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "url": "https://images.unsplash.com/photo-1776377231754-d36928e6ee4d?q=80&w=1170",
  "conversionDirection": "auto",
  "quality": 90,
  "watermark": "",
  "pageSize": "A4",
  "orientation": "portrait",
  "resolution": 150,
  "mergeOutput": false
}' |
apify call akash9078/image-pdf-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,akash9078/image-pdf-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/8lzsro6PYXG2dfvQX/builds/IfCs1Ms5ggH6JJX3o/openapi.json
