Skip to content

maniartech/printeer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

166 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🖨️ Printeer

Web-to-PDF/PNG conversion done right

npm version License: ISC Node.js Version

Convert any web page to pixel-perfect PDFs or high-quality screenshots with a single command.

Quick StartCLI UsageLibrary APIConfigurationContributing


✨ Features

  • 🚀 Zero Config — Works out of the box with sensible defaults
  • 📄 PDF & PNG — Auto-detects format from file extension
  • 📱 Device Emulation — Mobile, tablet, and custom viewports
  • 🔄 Full Page Capture — Scroll and capture entire pages with lazy-loaded content
  • Batch Processing — Convert hundreds of URLs with concurrency control
  • 🔐 Authentication — Basic auth, cookies, and custom headers
  • 🩺 Built-in Diagnosticsprinteer doctor checks your environment
  • 📦 Dual Use — CLI tool and Node.js library

Quick Start

Install

# npm
npm install -g printeer

# bun
bun add -g printeer

# yarn
yarn global add printeer

Use

# Convert webpage to PDF
printeer convert https://example.com page.pdf

# Screenshot in mobile view
printeer convert https://example.com mobile.png --mobile --full-page

# Check your environment
printeer doctor

CLI Usage

Basic Conversion

# URL → PDF (auto-detected from extension)
printeer convert https://example.com output.pdf

# URL → PNG screenshot
printeer convert https://example.com screenshot.png

# Full page screenshot with mobile emulation
printeer convert https://example.com mobile.png --mobile --full-page

Device Emulation

# Mobile (iPhone-like: 375×812, 2x scale, touch enabled)
printeer convert https://example.com mobile.png --mobile --full-page

# Tablet (iPad-like: 768×1024, 2x scale, touch enabled)
printeer convert https://example.com tablet.png --tablet --full-page

# Custom viewport
printeer convert https://example.com custom.png --viewport 1440x900

PDF Options

# A4 landscape with background graphics
printeer convert https://example.com report.pdf \
  --format A4 \
  --orientation landscape \
  --print-background

# Custom margins
printeer convert https://example.com document.pdf --margins "1in"

Wait Strategies

# Wait for specific element
printeer convert https://spa-app.com dashboard.pdf \
  --wait-selector "#chart-loaded"

# Wait for network idle
printeer convert https://example.com page.pdf --wait-until networkidle0

Batch Processing

# Process multiple URLs from a file
printeer batch jobs.json --concurrency 5 --continue-on-error

jobs.json:

[
  { "url": "https://example.com", "output": "example.pdf" },
  { "url": "https://google.com", "output": "google.pdf" }
]

System Diagnostics

# Check browser, fonts, and environment
printeer doctor

# Verbose output
printeer doctor --verbose

Library API

Installation

npm install printeer

Basic Usage

import printeer from 'printeer';

// Simple conversion
await printeer('https://example.com', 'output.pdf');

// With options
await printeer('https://example.com', 'screenshot.png', null, {
  viewport: { width: 1920, height: 1080 },
  fullPage: true
});

Advanced Configuration

import printeer from 'printeer';

await printeer('https://example.com', 'report.pdf', null, {
  format: 'A4',
  printBackground: true,
  margin: { top: '1in', bottom: '1in' },
  waitUntil: 'networkidle0'
});

Custom Browser Management

import { DefaultBrowserManager } from 'printeer';

const browserManager = new DefaultBrowserManager({
  headless: true,
  args: ['--no-sandbox']
});

await browserManager.initialize();
const browser = await browserManager.getBrowser();
// Use browser...
await browserManager.cleanup();

Configuration

Printeer supports configuration files for complex setups:

.printeerrc.json:

{
  "page": {
    "format": "A4",
    "orientation": "portrait"
  },
  "viewport": {
    "width": 1920,
    "height": 1080
  },
  "wait": {
    "until": "networkidle0",
    "timeout": 30000
  }
}

Environment Variables

Variable Description
PRINTEER_BROWSER_EXECUTABLE_PATH Custom Chrome/Chromium path
PRINTEER_BROWSER_HEADLESS true / false
PRINTEER_LOG_LEVEL error, warn, info, debug

Runtime Compatibility

Printeer is built for Node.js but works across modern JavaScript runtimes:

Runtime Status Notes
Node.js 16.8+ ✅ Full Support Primary runtime, fully tested
Bun 1.0+ ✅ Supported Install via bun add printeer
Deno 2.0+ ⚠️ Experimental Use npm specifier (see below)

Node.js (Recommended)

npm install -g printeer

Bun

# Install
bun add printeer

# Note: Run post-install to download Chromium
bunx puppeteer browsers install chrome

# Use
bun run printeer convert https://example.com page.pdf

Deno

// Import using npm specifier
import printeer from "npm:printeer";

// Requires permissions: --allow-read --allow-write --allow-net --allow-run --allow-env
await printeer("https://example.com", "output.pdf");

Run with:

deno run --allow-all your-script.ts

Requirements

  • Chromium — Auto-installed with Puppeteer, or set PRINTEER_BROWSER_EXECUTABLE_PATH
  • Linux headless servers — May require xvfb or --no-sandbox flag

Troubleshooting

Run the built-in diagnostic tool:

printeer doctor --verbose

This checks:

  • ✅ Node.js version
  • ✅ Chromium installation
  • ✅ Display server (for headless environments)
  • ✅ Font availability
  • ✅ Sandbox configuration

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a PR.

# Clone the repository
git clone https://github.com/maniartech/printeer.git
cd printeer

# Install dependencies
npm install

# Build
node scripts/build.js

# Run tests
npm test

# Run the CLI in development
node scripts/run-cli.js convert https://example.com test.pdf

License

ISC © ManiarTech


DocumentationChangelogIssues

Made with ❤️ by ManiarTech

About

Prints the specified web url to PDF or Image!

Resources

Stars

Watchers

Forks

Packages

No packages published