{"id":44803630,"url":"https://github.com/arienshibani/trykkeri-api","last_synced_at":"2026-02-16T14:18:48.899Z","repository":{"id":338260374,"uuid":"1157232942","full_name":"arienshibani/trykkeri-api","owner":"arienshibani","description":"🖨️ API for turning HTML to PDF ","archived":false,"fork":false,"pushed_at":"2026-02-13T16:30:15.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-14T00:10:26.759Z","etag":null,"topics":["docker-image","grafana","html-to-pdf"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arienshibani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-13T15:32:09.000Z","updated_at":"2026-02-13T16:37:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/arienshibani/trykkeri-api","commit_stats":null,"previous_names":["arienshibani/trykkeri-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/arienshibani/trykkeri-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arienshibani%2Ftrykkeri-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arienshibani%2Ftrykkeri-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arienshibani%2Ftrykkeri-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arienshibani%2Ftrykkeri-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arienshibani","download_url":"https://codeload.github.com/arienshibani/trykkeri-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arienshibani%2Ftrykkeri-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29509796,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T09:05:14.864Z","status":"ssl_error","status_checked_at":"2026-02-16T08:55:59.364Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-image","grafana","html-to-pdf"],"created_at":"2026-02-16T14:18:48.388Z","updated_at":"2026-02-16T14:18:48.893Z","avatar_url":"https://github.com/arienshibani.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trykkeri API 🖨️\n\n[![Go 1.22](https://img.shields.io/badge/Go-1.22-00ADD8?logo=go)](https://go.dev/)\n[![OpenAPI 3.0](https://img.shields.io/badge/OpenAPI-3.0-6BA539?logo=openapi-initiative)](https://swagger.io/specification/)\n[![Docker](https://img.shields.io/badge/Docker-ready-2496ED?logo=docker)](https://www.docker.com/)\n[![Grafana](https://img.shields.io/badge/Grafana-dashboard-F46800?logo=grafana)](https://grafana.com/)\n\nREST API for turning raw HTML into PDF files, with built-in monitoring.\n\n## Features ✨\n\n- **HTML to PDF** - Either supply raw HTML to `/print`, or use the `/mirror` endpoint to fetch the HTML directly from a webpage.\n- **Grafana dashboard** - Preconfigured with a custom dashboard for monitoring usage and errors (when run with the observability stack).\n- **Scalar UI** - Interactive API docs for trying different HTML and query parameters.\n- **Tunable output** - Margins, page size, filename, DPI, orientation, background printing, grayscale etc. All using query parameters.\n\n## Usage 🚀\n\nSend a `POST` request to `/print` with your HTML as the request body.\n\n```bash\ncurl http://localhost:8080/print \\\n  --request POST \\\n  --header 'Content-Type: text/html' \\\n  --header 'Accept: application/pdf' \\\n  --data '\u003ch1 style=\"color: red; text-align: center\"\u003eHello world!\u003c/h1\u003e'\n```\n\n### Output 👇\n\n\u003cimg width=\"300\" height=\"888\" alt=\"image\" src=\"https://github.com/user-attachments/assets/d1e50820-57aa-46b0-b3cd-5d0ab4effb5b\" /\u003e\n\n## Endpoints 🔌\n\n- **`/print`** — `POST` request with HTML in the body → **PDF**.\n- **`/mirror`** — `POST` request with a URL in the body → we fetch the HTML → **PDF** \n\n### Optional query parameters 🔧\n\n| Parameter | Type | Description |\n| ----------- | ------ | ------------- |\n| `filename` | string | Suggested filename in `Content-Disposition` (default: `document.pdf`) |\n| `base_url` | string | Base URL for resolving relative links and assets in the HTML |\n| `page_size` | string | e.g. `A4`, `Letter` |\n| `portrait` | boolean | `true` = portrait, `false` = landscape |\n| `margin_top_mm` | integer | Top margin in mm |\n| `margin_right_mm` | integer | Right margin in mm |\n| `margin_bottom_mm` | integer | Bottom margin in mm |\n| `margin_left_mm` | integer | Left margin in mm |\n| `dpi` | integer | Output DPI (e.g. `300`) |\n| `print_background` | boolean | Include CSS background graphics |\n| `grayscale` | boolean | Render in grayscale |\n\nExample with options:\n\n```bash\ncurl 'http://localhost:8080/print?filename=report.pdf\u0026page_size=A4\u0026margin_top_mm=20\u0026dpi=150' \\\n  --request POST \\\n  --header 'Content-Type: text/html' \\\n  --data '\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eReport\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e'\n```\n\n## Quickstart 🏁\n\nEnsure you have the following installed\n\n- [Docker](https://www.docker.com/)\n- [Go](https://go.dev/)\n- [Justfile](https://github.com/casey/just) (optional, but recommended)\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/trykkeri/trykkeri-api.git\ncd trykkeri-api\n```\n\n### 2. Spin up the services\n\n**API only** (Go, no Docker):\n\n```bash\njust run\n# or: go run ./cmd/server\n```\n\n**Full stack** (API + Grafana, Loki, Promtail in Docker, with live reload):\n\n```bash\njust watch\n# or: docker compose --profile observability watch\n```\n\n### 3. Access the services\n\n- 🔍 **API / Scalar UI** — \u003chttp://localhost:8080\u003e (available with either `just run` or `just watch`).\n- 🪵 **Grafana dashboard** — \u003chttp://localhost:3000\u003e (only when you use `just watch`).\n\n## Configuration 🔧\n\nThe service can be configured using environment variables. When you run the stack with Docker Compose, set these in a `.env` file in the project root—the same file used for Grafana (e.g. `GRAFANA_ADMIN_USER`). See [.env.example](.env.example) for a template.\n\n| Variable | Description | Default |\n| ---------- | ------------- | ------- |\n| `PORT` | The port the service listens on | `8080` |\n| `JSON_LOGS` | Whether to log in JSON format | `false` |\n| `MAX_BODY_BYTES` | The maximum body size in bytes | `2000000` |\n| `RENDER_TIMEOUT_MS` | The timeout in milliseconds for rendering a PDF | `30000` |\n| `WKHTMLTOPDF_PATH` | The path to the wkhtmltopdf binary | `wkhtmltopdf` |\n| `ALLOW_NET` | Whether to allow network access | `false` |\n\n## Screenshots 📸\n\n### API\n\n\u003cimg width=\"1452\" height=\"1279\" alt=\"image\" src=\"https://github.com/user-attachments/assets/a6affe80-b3e3-45f6-be4e-8b7f7d6a96df\" /\u003e\n\n### Grafana\n\n\u003cimg width=\"1127\" height=\"1142\" alt=\"image\" src=\"https://github.com/user-attachments/assets/51758579-b8f2-4c86-b05b-dc1f552a9540\" /\u003e\n\n\n### Pre-built image\n\nNew image on every commit to main can be fetched from Github Container Registry.\n\n```bash\ndocker run -p 8080:8080 ghcr.io/trykkeri/trykkeri-api:latest\n```\n\nImages are published on every push to `main` and when you create a release. Use `:latest`, `:sha-\u003ccommit\u003e`, or a version tag (e.g. `:v1.0.0`) after a release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farienshibani%2Ftrykkeri-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farienshibani%2Ftrykkeri-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farienshibani%2Ftrykkeri-api/lists"}