Skip to content

whizzes/nyomda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nyomda

A high-performance Rust-based service for converting LaTeX and HTML documents to PDF files.

Overview

Nyomda is a lightweight, containerized PDF generation service that provides a simple API for converting markup documents (LaTeX and HTML) into professionally formatted PDF files. Built with Rust for maximum performance and reliability, Nyomda is designed to be easily deployed via Docker.

Features

  • LaTeX to PDF Conversion: Full support for LaTeX documents with complex mathematical equations, tables, and formatting
  • HTML to PDF Conversion: Convert HTML documents to PDF while preserving styling and layout
  • Docker Ready: Pre-built Docker image for easy deployment
  • High Performance: Written in Rust for speed and memory efficiency
  • REST API: Simple HTTP interface for document conversion
  • Lightweight: Minimal resource footprint

Prerequisites

  • Docker (for containerized deployment)
  • OR Rust 1.70+ (for building from source)

Quick Start with Docker

The easiest way to run Nyomda is using the Docker image:

# Pull the latest image
docker pull ghcr.io/whizzes/nyomda:<VERSION>

# Run the service
docker run -p 8080:8080 ghcr.io/whizzes/nyomda:<VERSION>

The service will be available at http://localhost:9000

Building from Source

Prerequisites

  • Rust 1.70 or higher
  • Cargo (comes with Rust)
  • LaTeX distribution (e.g., TeX Live, MiKTeX)
  • wkhtmltopdf (for HTML conversion)
  • Chrome or Chromium (for HTML rendering)

Build Steps

# Clone the repository
git clone https://github.com/whizzes/nyomda.git
cd nyomda

# Build the project
cargo build --release

# Run the service
cargo run --release

API Usage

Convert LaTeX to PDF

curl -X POST http://localhost:9000/api/v0/compile \
  -H "Content-Type: application/json" \
  -d '{
    "text": "\\documentclass{article}\n\\begin{document}\nHello World!\n\\end{document}"
  }' \
  --output output.pdf

Convert HTML to PDF

curl -X POST http://localhost:9000/api/v0/print \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<html><body><h1>Hello World!</h1></body></html>"
  }' \
  --output output.pdf

Example with Environment Variables

docker run -p 9000:9000 ghcr.io/whizzes/nyomda:<VERSION>

Docker Deployment

Using Docker Compose

Create a docker-compose.yml file:

version: '3.8'

services:
  nyomda:
    image: ghcr.io/whizzes/nyomda:<VERSION>
    ports:
      - "9000:9000"
    restart: unless-stopped

LaTeX Examples

Simple Document

\documentclass{article}
\begin{document}
\title{Sample Document}
\author{Your Name}
\date{\today}
\maketitle

\section{Introduction}
This is a sample document.

\end{document}

Document with Math

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\section{Mathematical Equations}

The quadratic formula is:
$$x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$$

\end{document}

HTML Examples

Basic HTML

<!DOCTYPE html>
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; }
        h1 { color: #333; }
    </style>
</head>
<body>
    <h1>Sample Report</h1>
    <p>This is a sample HTML document converted to PDF.</p>
</body>
</html>

Styled Document

<!DOCTYPE html>
<html>
<head>
    <style>
        .header { background-color: #4CAF50; color: white; padding: 20px; }
        .content { padding: 20px; }
        table { border-collapse: collapse; width: 100%; }
        td, th { border: 1px solid #ddd; padding: 8px; }
    </style>
</head>
<body>
    <div class="header">
        <h1>Monthly Report</h1>
    </div>
    <div class="content">
        <table>
            <tr><th>Item</th><th>Value</th></tr>
            <tr><td>Revenue</td><td>$10,000</td></tr>
        </table>
    </div>
</body>
</html>

Acknowledgments

  • Built with Rust
  • LaTeX conversion powered by TeX Live
  • HTML conversion using wkhtmltopdf
  • Containerization with Docker

Roadmap

  • Support for additional input formats (Markdown, AsciiDoc)
  • Batch conversion API
  • Template system for common document types
  • S3/cloud storage integration
  • Webhook notifications for async processing
  • PDF metadata customization
  • Digital signature support

About

Nyomda (printing house in Hungarian) is a service for generating PDFs from HTML and LaTex

Topics

Resources

Stars

Watchers

Forks

Packages