apyhub
Back
▣ INGESTION KIT · OUTPUT KIT

Convert HTML, Markdown & URL to PDF API

What it does

The Convert HTML, Markdown & URL to PDF API is a webpage screenshot to PDF API. It saves a web page, HTML or Markdown as a PDF that looks exactly like the screen. Send one of url, html or markdown, and get back a PDF that holds a Chromium screenshot of the page.

Set the viewport with width and height (defaults 1280 by 720). Turn on full_page to put the whole scrollable page into the PDF. image_format sets the screenshot inside the PDF: png keeps text sharp, jpeg gives a smaller file.

For live pages, wait_until and wait_for_selector hold the capture until content loads. custom_css and scripts can hide cookie banners first. cookies, extra_headers and auth_type reach pages behind a login. response_mode returns the PDF as a file by default. It can also return base64, JSON with size and time, or a temporary download link.

Teams use it to keep visual records of web pages and to save dashboards and receipts for audits. It also sends page snapshots to people who expect a PDF.

A webpage screenshot to PDF API stores the page as one image, so its text cannot be selected or searched. For a PDF with searchable text and page layout options, use the Convert HTML & Markdown to PDF API instead.

To brand the result, the PDF Watermark API stamps text or a logo on it. The Merge Files to PDF API combines several captures into one file.

AI agents can call it through ApyHub MCP.

POST
Capture screenshot then convert to PDF
https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-pdf/screenshot/pdf

QUICKSTART

GUIDE

Quickstart

Render a page to a PDF from a URL with the default viewport settings.

curl -X POST "https://api.eu.apyhub.com/sarvasoft/convert-html-md-url-to-pdf/screenshot/pdf" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://apyhub.com"
  }'

What you'll get back

Returns a JSON object in one of the shapes declared by response_mode:

  • response_mode=base64: a JSON object with filename and pdf_base64
  • response_mode=json: a JSON object with filename, size, created_at, and pdf_base64
  • response_mode=url: a JSON object with file_url, expires_at, and expires_in_seconds

Example for the url shape:

{
  "filename": "screenshot.pdf",
  "size": 770,
  "created_at": "2026-01-15T10:30:00Z",
  "pdf_base64": "JVBERi0xLjcKJb/3ov4KMSAwIG9iago8PCAvVHlwZSAvT2JqU3RtIC9MZW5ndGggMjI5..."
}
TRY ITLIVE · 10 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
body*

About this endpoint

What it does

Takes a screenshot of a web page, raw HTML or Markdown in Chromium and returns it as a PDF. The PDF holds the page as one image, so it looks exactly as it did on screen.

Request Body

ParameterTypeDescription
urlStringRequired if html and markdown are not set. Public web page to capture as a PDF. Must be http or https. Max length 2083 characters. Provide exactly one of url, html or markdown.
htmlStringRequired if url and markdown are not set. Raw HTML to render and capture. Max length 500000 characters.
markdownStringRequired if url and html are not set. Markdown to convert to HTML, render and capture. Max length 500000 characters.
image_formatStringFormat of the screenshot placed inside the PDF. jpeg gives a smaller file, png keeps sharper text. Allowed values: png, jpeg. Default: png.
response_modeStringHow the PDF is returned. Allowed values: binary, base64, json, url. Default: binary.
filenameStringName of the PDF file. Max length 255 characters.
widthIntegerViewport width in pixels. Range: 100 to 10000. Default: 1280.
heightIntegerViewport height in pixels. Range: 100 to 10000. Default: 720.
full_pageBooleanCapture the full scrollable page into the PDF, not only the viewport. Default: false.
custom_cssStringCSS injected into the page before capture. Max length 200000 characters.
style_urlStringPublic URL of a CSS file to load before capture. Max length 2048 characters.
script_urlStringPublic URL of a JavaScript file to load before capture. Max length 2048 characters.
scriptsString ArrayInline scripts or script URLs to run before capture.
execute_javascriptBooleanRun the page's JavaScript before capture. Default: true.
wait_untilENUMWhen the page counts as loaded. Allowed values: load, domcontentloaded, networkidle, networkidle0, networkidle2. Default: networkidle.
wait_for_selectorStringCSS selector to wait for before capture. Max length 256 characters.
wait_for_functionStringJavaScript expression to wait for until it is true. Max length 200000 characters.
wait_for_timeoutIntegerHow long to wait for the selector or function, in milliseconds. Range: 0 to 300000.
timeoutIntegerLoad and capture timeout in milliseconds. Range: 1000 to 180000. Default: 30000.
auth_typeENUMLogin used when loading url. Allowed values: none, basic, bearer. Default: none.
auth_credentialsStringLogin value for auth_type: username:password for basic, the token for bearer. Max length 2048 characters.
extra_headersObjectExtra HTTP headers sent when loading url.
cookiesObject ArrayCookies set in the browser before loading the page.

Response

Returns the PDF in the shape set by response_mode. In json mode, returns a JSON object with the file and its metadata.

ParameterTypeDescription
filenameStringName of the PDF file.
sizeIntegerSize of the PDF in bytes.
created_atStringUTC timestamp when the PDF was created.
pdf_base64StringBase64-encoded PDF holding the screenshot.

Notes

  • Provide exactly one of url, html or markdown.
  • The PDF contains the page as an image. Text in it cannot be selected or searched.
  • binary returns the PDF file itself, not JSON. base64 returns only filename and pdf_base64. url returns file_url, expires_at and expires_in_seconds. The link needs no authentication and stops working after it expires.
  • The request body must be under 5 MB. Larger bodies return 413.
  • A capture that runs past timeout returns 504.
  • url, style_url, script_url and scripts must be public addresses.
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.