Skip to content

Ben8t/TheNewPrinter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

The New Printer

Reading on paper just feels better. It's slow. It's embedded in the physical. It allows raw notes. As a huge reader of blogs and newsletters mainly distributed on the Internet, I created New Printer to simply transform blog posts into printable PDFs.

I am now printing the blog posts I really want to read on paper and putting them in a nice binder.

New Printer is a lightweight CLI tool that converts web articles into print-ready PDFs using pandoc's robust document conversion pipeline - bringing the classic magazine aesthetic to digital content.

Features

  • Simple & Fast: Minimal dependencies, maximum performance
  • Beautiful Output: Professional typography with LaTeX backend
  • Two-Column Format: Classic magazine-style layout
  • Multiple Templates: Article and magazine styles
  • Smart Extraction: Trafilatura with readability fallback
  • Image Processing: Automatic optimization for print
  • Batch Processing: Convert multiple articles at once

Quick Start

One-time Use (No Installation)

# Convert a single article
uvx new-printer convert https://example.com/article

# With custom options
uvx new-printer convert https://example.com/article \
  --font-size 11pt \
  --template magazine \
  --output article.pdf

Installation

Prerequisites

Required:

  • Python 3.8+
  • Pandoc 3.0+
  • LaTeX distribution (TeX Live recommended)

Optional:

  • uv (recommended for installation)

Install with uv (Recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install new-printer as a tool
uv tool install new-printer

# Or run without installing
uvx new-printer --help

Install with pip

pip install new-printer

System Dependencies

macOS:

brew install pandoc
brew install --cask mactex  # Or mactex-no-gui for smaller install

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install pandoc texlive-latex-recommended texlive-latex-extra

Windows:

πŸ“– Usage

Command Line Interface

Basic Conversion

# Convert article with defaults (2 columns, 11pt font)
new-printer convert https://longform.aeon.co/essays/future-of-work

# Specify output file
new-printer convert https://example.com/article --output my-article.pdf

Formatting Options

# Magazine style
new-printer convert https://example.com/article \
  --template magazine \
  --font-size 10pt

# Custom font size
new-printer convert https://example.com/article \
  --template article \
  --font-size 12pt

Batch Processing

# Create a file with URLs
echo "https://site1.com/article1" > urls.txt
echo "https://site2.com/article2" >> urls.txt

# Convert all articles
new-printer batch urls.txt --output-dir ./articles

Available Templates

  • article: Clean, readable layout (default)
  • magazine: New Yorker-style multi-column format

All templates use a 2-column layout for optimal readability.

Configuration

Create a configuration file to set your preferred defaults:

# Copy the template
cp new_printer/templates/config.yaml ~/.new-printer.yml

# Edit with your preferences
editor ~/.new-printer.yml

Example configuration:

default:
  font_size: "11pt"
  template: "magazine"
  output_dir: "~/Documents/Articles"
  include_images: true

πŸ—οΈ Architecture

Web Article β†’ Content Extraction β†’ Markdown β†’ Pandoc β†’ LaTeX β†’ PDF
              (Trafilatura)                   (Filters)  (Templates)

Core Components

  • Extractors: Trafilatura (primary) + Readability (fallback)
  • Processors: Markdown conversion, image optimization
  • Templates: Custom LaTeX templates with multi-column support
  • CLI: Click-based interface with rich output

πŸ”§ Development

Setup Development Environment

# Clone the repository
git clone https://github.com/yourusername/new-printer.git
cd new-printer

# Install development dependencies
pip install -r requirements.txt

# Install in development mode
pip install -e .

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=new_printer

Code Quality

# Format code
black new_printer tests

# Lint code
flake8 new_printer tests

# Type checking
mypy new_printer

πŸ“ Examples

Article Extraction

from new_printer.extractors.trafilatura_extractor import TrafilaturaExtractor

extractor = TrafilaturaExtractor()
article = extractor.extract("https://example.com/article")
print(f"Title: {article.title}")
print(f"Author: {article.author}")

PDF Generation

from new_printer.processors.pandoc_runner import PandocRunner

runner = PandocRunner()
pdf_path = runner.convert_to_pdf(article, {
    "template": "magazine",
    "output": "article.pdf"
})

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Pandoc for excellent document conversion
  • Trafilatura for reliable content extraction
  • LaTeX for beautiful typography
  • Inspired by classic magazine and newspaper layouts

πŸ”— Links


The New Printer - Because sometimes the best way to read online is offline.

About

The New Printer - Because sometimes the best way to read online is offline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published