Mac hosting guide

Create Scheduled PDF Reports on a Hosted Mac

Render the page with wkhtmltopdf from a launchd job, then check that the file exists, is large enough and starts with %PDF-. The Intel Mac VM ($25 a month) is enough for most reports.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Install wkhtmltopdf with Homebrew, render the report URL on a launchd schedule, and validate each file before it goes to anyone: it must exist, exceed a minimum size and start with %PDF-. Figment's Intel Mac VM ($25 a month) is enough for most HTML-to-PDF reports.

Scheduled PDF reports fail in two predictable ways. The HTML renders before JavaScript data arrives, or the file exists but is empty, truncated, or an HTML error page saved with a .pdf suffix. The pipeline below catches both.

Which tool should I use to make the PDF?

wkhtmltopdf is the most predictable choice for scheduled jobs. It is headless, takes a URL or file, has a configurable JavaScript delay and gives deterministic output.

ToolInstallBest for
wkhtmltopdfbrew install wkhtmltopdfURL or HTML file to PDF with JavaScript support
macOS Shortcuts (shortcuts run)Built inNo-code multi-step flows; see Apple's Shortcuts CLI guide
Headless Chrome (--print-to-pdf)brew install --cask google-chromeModern CSS, strict JS timing control
cupsfilterBuilt inConverting already-printable formats

The upstream wkhtmltopdf project is archived, so pin a known-good Homebrew version and check the wkhtmltopdf option reference. The default --javascript-delay is 200 ms, which is almost always too short for data-driven pages.

How do I generate a report and check it?

Save this as ~/bin/generate-report.sh and run chmod +x on it. It checks every PDF four ways before treating it as valid.

#!/usr/bin/env bash
set -euo pipefail

REPORT_URL="${1:?Usage: generate-report.sh <url> <output.pdf>}"
OUTPUT_PDF="${2:?}"
LOG="${HOME}/Library/Logs/pdf-reports.log"
MIN_BYTES=10000   # Tune to the smallest valid report you have ever produced.

ts() { date -u +%FT%TZ; }

# 1. Render
if ! wkhtmltopdf \
      --page-size A4 \
      --javascript-delay 3000 \
      --title "Scheduled Report $(date +%F)" \
      --footer-center "Page [page] of [topage]" \
      --footer-font-size 9 \
      "$REPORT_URL" "$OUTPUT_PDF" >> "$LOG" 2>&1; then
  echo "$(ts) FAIL render" >> "$LOG"; exit 1
fi

# 2. File present
[[ -f "$OUTPUT_PDF" ]] || { echo "$(ts) FAIL missing" >> "$LOG"; exit 1; }

# 3. Minimum size
BYTES=$(wc -c < "$OUTPUT_PDF" | tr -d ' ')
(( BYTES >= MIN_BYTES )) || { echo "$(ts) FAIL small ${BYTES}" >> "$LOG"; exit 1; }

# 4. PDF magic header (catches HTML error pages saved as .pdf)
[[ "$(head -c 5 "$OUTPUT_PDF")" == "%PDF-" ]] \
  || { echo "$(ts) FAIL header" >> "$LOG"; exit 1; }

echo "$(ts) OK ${OUTPUT_PDF} ${BYTES}" >> "$LOG"
CheckWhat it catches
Exit codeNetwork failure, renderer crash
File presentSilent failure before any write
Minimum bytesEmpty page, whitespace-only output, truncation
%PDF- headerLogin page, 403 or 404, or proxy error written as .pdf

This is an untested example. Run it once by hand against your real URL before scheduling it.

How long should the JavaScript delay be?

Open the report URL in a browser, open DevTools, go to Network, reload, and note when the last XHR or fetch completes. Set --javascript-delay to that time plus a 500 ms buffer. Run the script by hand and open the PDF. If a chart is missing, increase the delay. Dashboards backed by APIs usually settle between 2,000 and 4,000 ms.

How do I schedule it with launchd?

Place this at ~/Library/LaunchAgents/com.example.pdf-report.plist and load it with launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.pdf-report.plist.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key><string>com.example.pdf-report</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/bash</string>
    <string>/Users/agent/bin/generate-report.sh</string>
    <string>https://your-dashboard.example.com/weekly</string>
    <string>/Users/agent/reports/weekly-$(date +%F).pdf</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Weekday</key><integer>1</integer>
    <key>Hour</key><integer>7</integer>
    <key>Minute</key><integer>0</integer>
  </dict>
  <key>StandardOutPath</key><string>/Users/agent/Library/Logs/pdf-reports.log</string>
  <key>StandardErrorPath</key><string>/Users/agent/Library/Logs/pdf-reports-error.log</string>
</dict>
</plist>

launchd treats StartCalendarInterval keys as calendar wildcards, so a missing key means "any". For the exact behaviour of Weekday, Day and catch-up runs when the machine is asleep, read man launchd.plist on your Mac. Shell expressions such as $(date +%F) are not expanded inside a plist, so compute the filename inside the script instead.

What should I check after the first scheduled run?

  • tail -n 50 ~/Library/Logs/pdf-reports.log should show OK lines with stable byte counts.
  • If the byte count drifts down, the source page likely changed. Adjust MIN_BYTES only after you understand why.
  • If the job needs a VPN or an authenticated cookie, make the script fail fast when the cookie jar is missing rather than rendering a login page.
  • If launchctl list | grep pdf-report shows a non-zero exit, read pdf-reports-error.log before reloading the agent.

What does this cost to run?

Homebrew and wkhtmltopdf are free. On the Intel Mac VM, the cost is the plan itself.

  • Storage: one PDF of about 200 KB, 30 a day, kept 90 days, is about 540 MB. The VM has 80GB including the OS.
  • Egress to S3 or email: a 200 KB file, 30 a day for 30 days, is about 180 MB a month.
  • Upgrade trigger: if top during a render shows sustained CPU above 80% and the job regularly misses its window, move to a larger plan.

Any charting library, data API or email provider you call has its own licence and quota. Confirm those separately.

How much CPU and memory do scheduled PDF reports need?

Rendering a dashboard to PDF is bound by CPU and memory during layout, so the Intel Mac VM ($25 a month, $2 a day; 4 shared vCPUs, 4GB RAM, 80GB SSD) is enough for most reports. Move to the Dedicated M4 Pro ($349 a month; 48GB RAM) for heavy JavaScript dashboards, large datasets or many concurrent renders. The Apple Silicon Mac VM ($39 a month, $6 a day; 4GB RAM) suits reports that need Apple silicon. VM vCPUs are shared, not reserved cores. See Figment Mac Hosting.

Related guides:

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan