Skip to main content

A macOS utility to merge letterhead with PDF documents using a drag-and-drop interface

Project description

Mac-letterhead

PyPI Version Build Status License

Mac-letterhead Logo

A professional macOS utility that applies letterhead templates to PDF and Markdown documents. Mac-letterhead creates drag-and-drop applications that automatically merge your company letterhead with documents while preserving formatting and ensuring professional presentation.

What Mac-letterhead Does

Mac-letterhead transforms your letterhead PDF into a powerful document processing tool:

For PDF Documents

  • Direct Overlay: Your letterhead is applied as an overlay to existing PDFs without reformatting the original document
  • Multiple Blend Modes: Choose from various merging strategies (darken, multiply, overlay, transparency) to suit different letterhead designs
  • Quality Preservation: All original formatting, fonts, and layout are maintained during the merge process

For Markdown Documents

  • Intelligent Layout: Analyzes your letterhead PDF to identify headers, footers, logos, and text elements
  • Smart Margin Detection: Automatically calculates the optimal printable area within your letterhead design
  • Professional Rendering: Converts Markdown to beautifully formatted PDF with proper typography, tables, code blocks, and styling
  • Adaptive Positioning: Handles left, right, and center-positioned letterheads with appropriate margin adjustments

Multi-Page Letterhead Support

  • Single Page: Applied consistently to all document pages
  • Two Pages: First page template for page 1, second template for subsequent pages
  • Three Pages: Distinct templates for first page, even pages, and odd pages

Requirements

  • macOS: Required for droplet applications and PDF processing
  • Python: 3.10 or higher
  • uv package manager: Install with pip install uv if needed

Installation

Install Mac-letterhead and create your first letterhead application:

# Quick start - create a letterhead droplet on your desktop
uvx mac-letterhead install /path/to/your/letterhead.pdf

This creates a macOS application that you can drag documents onto to apply your letterhead.

System Dependencies

For optimal Markdown rendering, install the required libraries:

brew install pango cairo fontconfig freetype harfbuzz

These libraries enable high-quality PDF generation with advanced typography support.

Usage

Creating Letterhead Applications

Basic Application Creation

# Create a letterhead droplet with default name
uvx mac-letterhead install /path/to/company-letterhead.pdf

Custom Application Name

# Specify a custom name for your letterhead application  
uvx mac-letterhead install /path/to/letterhead.pdf --name "Company Correspondence"

Advanced Markdown Styling

# Create a letterhead application with custom CSS styling
uvx mac-letterhead install /path/to/letterhead.pdf --name "Technical Reports" --css /path/to/custom-styles.css

The --css option allows you to customize the appearance of rendered Markdown documents:

  • Typography: Custom fonts, sizes, colors, and spacing
  • Layout: Table styling, code block formatting, list appearance
  • Branding: Consistent styling that complements your letterhead design
  • Responsiveness: Ensures content fits properly within the detected printable area

Using Letterhead Applications

Once created, your letterhead application appears on your desktop:

  1. For PDF Files: Drag any PDF onto the application icon - the letterhead is applied as an overlay
  2. For Markdown Files: Drag .md files onto the application - they're converted to PDF with your letterhead and proper formatting
  3. Preview Letterhead: Double-click the application to view information and preview the letterhead template

Direct Command-Line Usage

PDF Merging

# Apply letterhead to a PDF document
uvx mac-letterhead merge /path/to/letterhead.pdf "Document Title" ~/Desktop /path/to/document.pdf

# Use a specific blending strategy
uvx mac-letterhead merge /path/to/letterhead.pdf "Report" ~/Desktop /path/to/report.pdf --strategy overlay

Markdown Processing

# Convert Markdown with letterhead
uvx mac-letterhead merge-md /path/to/letterhead.pdf "Technical Guide" ~/Desktop /path/to/guide.md

# With custom CSS styling
uvx mac-letterhead merge-md /path/to/letterhead.pdf "Proposal" ~/Desktop /path/to/proposal.md --css /path/to/styles.css

Blending Strategies

Choose the optimal strategy for your letterhead design:

  • darken (Default): Ideal for light letterheads with dark text/logos - provides excellent readability
  • multiply: Creates watermark-like effects, good for subtle branding
  • overlay: Balances visibility of both document content and letterhead elements
  • transparency: Smooth blending with semi-transparent effects
  • reverse: Places letterhead elements on top of document content

Advanced Features

Custom CSS Styling

Create sophisticated document styling by providing custom CSS:

/* custom-styles.css */
h1 { color: #2c5aa0; border-bottom: 2px solid #2c5aa0; }
table { border: 1px solid #ddd; background: #f9f9f9; }
code { background: #f4f4f4; padding: 2px 4px; }

The CSS is automatically integrated with Mac-letterhead's smart margin system to ensure content fits properly within your letterhead design.

Markdown Features

Mac-letterhead provides professional Markdown rendering with:

  • Typography: Proper heading hierarchy, paragraph spacing, and font sizing
  • Tables: Clean borders, consistent padding, and professional appearance
  • Code Blocks: Syntax highlighting for multiple programming languages
  • Lists & Quotes: Proper indentation and formatting for nested content
  • Images & Links: Full support for embedded images and hyperlinks
  • Math: LaTeX-style mathematical expressions (when supported)

Use Cases

  • Corporate Communications: Apply company branding to business correspondence
  • Legal Documents: Add firm letterhead and disclaimers to contracts and legal papers
  • Financial Documents: Brand invoices, statements, and financial reports
  • Technical Documentation: Convert Markdown documentation to branded PDFs
  • Academic Papers: Add institutional letterhead to research papers and reports
  • Proposals & Reports: Create professional client deliverables from Markdown sources

Troubleshooting

Common Issues

Library Dependencies: If you see WeasyPrint warnings, the system automatically falls back to ReportLab - functionality is not affected.

File Permissions: If applications request file access, approve the permissions in System Preferences > Security & Privacy > Privacy > Files and Folders.

Margin Detection: The system automatically analyzes letterhead positioning. If margins appear incorrect, ensure your letterhead PDF contains clear visual elements (logos, text, graphics) in header/footer areas.

Log Files

  • Application logs: ~/Library/Logs/Mac-letterhead/letterhead.log
  • Droplet logs: ~/Library/Logs/Mac-letterhead/droplet.log

Contributing

We welcome contributions! Please see CONTRIBUTING.md for development setup, testing procedures, and pull request guidelines.

License

MIT License

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mac_letterhead-0.12.0.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mac_letterhead-0.12.0-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file mac_letterhead-0.12.0.tar.gz.

File metadata

  • Download URL: mac_letterhead-0.12.0.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mac_letterhead-0.12.0.tar.gz
Algorithm Hash digest
SHA256 523558ba0be638f3351c23c07f8225d556a8c3ea399c2fb2f28e81fad17a1b3c
MD5 323b6f0312d5fd56e76562c3d6e7f449
BLAKE2b-256 5e70fe896e07581d5bafef7d448ed9cfee64a211e4a9e1ea4ea7e13ceb8c78a9

See more details on using hashes here.

File details

Details for the file mac_letterhead-0.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mac_letterhead-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdb5af8b78495bac1c86a8a86c2b09f58f3aee27e55131f4bf4399a2f235de63
MD5 f0c74d8f2c019a82adf3b6452b735123
BLAKE2b-256 58cf8a5f238f234826f057626e6c2725c7dbbc8dfe677f0f77e9a0870571528c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page