# ChatGPT to PDF — Convert Conversations to PDF (`moving_beacon-owner1/chatgpt-to-pdf`) Actor

Special handling for ChatGPT share pages (`/share/...`) adds turn detection, role labels (You/ChatGPT), and styled formatting. Other pages use a clean A4 layout with cover, headers, and page numbers. JS-heavy sites are rendered —auto-enabled for ChatGPT links, optional for others.

- **URL**: https://apify.com/moving\_beacon-owner1/chatgpt-to-pdf.md
- **Developed by:** [Jamshaid Arif](https://apify.com/moving_beacon-owner1) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $100.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## url2pdf — Apify Actor

Convert any URL (or local HTML) into a polished, HD-quality PDF.

- Special handling for **ChatGPT share pages** (`https://chatgpt.com/share/...`) — turns are detected, role-tagged (You / ChatGPT), styled, and laid out with proper typography, code blocks, and tables.
- Generic web pages fall back to a clean readable layout (cover page, A4, page numbers, running header).
- JS-rendered / SPA pages are loaded through **headless Chromium** (Playwright). ChatGPT URLs auto-trigger this; other sites can be forced via the input toggle.
- Typography is **fully self-contained**: KaTeX + Inter / Source Serif 4 / JetBrains Mono are baked into the Docker image at build time, so each run is offline and deterministic.

### Getting a ChatGPT share link

The actor takes a **public share URL**, not a private chat URL. Your private chat URL (`https://chatgpt.com/c/...`) won't work — the actor isn't logged in as you. You need to publish the conversation as a share link first; this takes about five seconds.

#### From the ChatGPT web app (desktop)

1. Go to <https://chatgpt.com> and open the conversation you want to export.
2. In the top-right corner of the chat, click the **share icon** (an arrow pointing up out of a box, next to your avatar).
3. A "Share public link to chat" dialog opens. Decide what should appear:
   - **Your name** — toggle on/off as you prefer.
   - **Anonymize** — replaces your name with "Anonymous" in the shared copy.
4. Click **Create link** (or **Update link** if one already exists).
5. Click **Copy link**. The URL looks like `https://chatgpt.com/share/abc12345-6789-...`.
6. Paste it into the actor's `urls` field and run.

> Heads up: the share link is a **frozen snapshot** taken at the moment you click *Create link*. New messages sent in the conversation afterwards are **not** included. If you keep chatting and want the new turns in your PDF, click the share icon again and choose **Update link**.

#### From the ChatGPT mobile app (iOS / Android)

1. Open the conversation.
2. Tap the **⋯** (three dots) menu in the top-right.
3. Tap **Share**.
4. Tap **Create link**, then **Copy Link**.
5. Paste it into the actor input.

#### Privacy notes

- Anyone with the share link can view the conversation — treat it like a public Google Doc.
- You can revoke a share link at any time: profile menu → **Settings** → **Data controls** → **Shared links** → trash icon next to the link. Once revoked, the link 404s and the actor will record an error row for it.
- If your conversation contains images, custom GPT system prompts, file attachments, or memories, those typically **don't** show up in the share view — only the visible text turns. The PDF will reflect what the share page actually contains.

### Input

| Field              | Type      | Default       | Notes                                                                      |
| ------------------ | --------- | ------------- | -------------------------------------------------------------------------- |
| `urls`             | `array`   | *(required)*  | List of URLs. Accepts `["https://..."]` or `[{"url": "..."}]`.             |
| `forceBrowser`     | `boolean` | `false`       | Render every URL with headless Chromium. Auto-on for known SPA hosts.      |
| `filenameTemplate` | `string`  | `"{title}"`   | KV-store key template. Placeholders: `{title}`, `{domain}`. Sanitized.     |

Example input:

```json
{
  "urls": [
    { "url": "https://chatgpt.com/share/abc-123" },
    { "url": "https://en.wikipedia.org/wiki/PDF" }
  ],
  "forceBrowser": false,
  "filenameTemplate": "{title}_{domain}"
}
````

### Output

Each PDF is saved to the run's **default key-value store**, and a metadata row is pushed to the **default dataset**:

```json
{
  "url":     "https://chatgpt.com/share/abc-123",
  "title":   "How transformers work",
  "kind":    "chatgpt",
  "key":     "How_transformers_work.pdf",
  "sizeKb":  412,
  "pdfUrl":  "https://api.apify.com/v2/key-value-stores/<id>/records/How_transformers_work.pdf"
}
```

# Actor input Schema

## `urls` (type: `array`):

List of URLs. Both regular pages and ChatGPT share URLs (https://chatgpt.com/share/...) are supported.

## `forceBrowser` (type: `boolean`):

Render every URL with headless Chromium (Playwright). Enable this if a page needs JavaScript to display its content. ChatGPT URLs use the browser automatically.

## `filenameTemplate` (type: `string`):

Used when saving each PDF to the key-value store. Placeholders: {title}, {domain}. Non-alphanumeric characters are replaced with underscores. Example: "{title}\_{domain}".

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://chatgpt.com/share/abc-example"
    }
  ],
  "forceBrowser": false,
  "filenameTemplate": "{title}"
}
```

# 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 = {
    "urls": [
        {
            "url": "https://chatgpt.com/share/abc-example"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("moving_beacon-owner1/chatgpt-to-pdf").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 = { "urls": [{ "url": "https://chatgpt.com/share/abc-example" }] }

# Run the Actor and wait for it to finish
run = client.actor("moving_beacon-owner1/chatgpt-to-pdf").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "urls": [
    {
      "url": "https://chatgpt.com/share/abc-example"
    }
  ]
}' |
apify call moving_beacon-owner1/chatgpt-to-pdf --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=moving_beacon-owner1/chatgpt-to-pdf",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "ChatGPT to PDF — Convert Conversations to PDF",
        "description": "Special handling for ChatGPT share pages (`/share/...`) adds turn detection, role labels (You/ChatGPT), and styled formatting. Other pages use a clean A4 layout with cover, headers, and page numbers. JS-heavy sites are rendered —auto-enabled for ChatGPT links, optional for others.",
        "version": "0.0",
        "x-build-id": "lmXTCO7emqadD4JjN"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/moving_beacon-owner1~chatgpt-to-pdf/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-moving_beacon-owner1-chatgpt-to-pdf",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/moving_beacon-owner1~chatgpt-to-pdf/runs": {
            "post": {
                "operationId": "runs-sync-moving_beacon-owner1-chatgpt-to-pdf",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/moving_beacon-owner1~chatgpt-to-pdf/run-sync": {
            "post": {
                "operationId": "run-sync-moving_beacon-owner1-chatgpt-to-pdf",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "urls"
                ],
                "properties": {
                    "urls": {
                        "title": "URLs to convert",
                        "type": "array",
                        "description": "List of URLs. Both regular pages and ChatGPT share URLs (https://chatgpt.com/share/...) are supported.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "forceBrowser": {
                        "title": "Force headless browser",
                        "type": "boolean",
                        "description": "Render every URL with headless Chromium (Playwright). Enable this if a page needs JavaScript to display its content. ChatGPT URLs use the browser automatically.",
                        "default": false
                    },
                    "filenameTemplate": {
                        "title": "Filename template",
                        "type": "string",
                        "description": "Used when saving each PDF to the key-value store. Placeholders: {title}, {domain}. Non-alphanumeric characters are replaced with underscores. Example: \"{title}_{domain}\".",
                        "default": "{title}"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
