{"id":27140366,"url":"https://github.com/bselleslagh/pypaperflow","last_synced_at":"2026-05-01T04:31:29.312Z","repository":{"id":285250724,"uuid":"956807483","full_name":"bselleslagh/PyPaperFlow","owner":"bselleslagh","description":"A FastAPI-based service that converts HTML content or URLs to PDF documents using Playwright.","archived":false,"fork":false,"pushed_at":"2025-03-31T13:00:02.000Z","size":998,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T22:04:30.035Z","etag":null,"topics":["fastapi","html2pdf","pdf-generation","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bselleslagh.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}},"created_at":"2025-03-28T22:34:53.000Z","updated_at":"2025-04-07T14:05:07.000Z","dependencies_parsed_at":"2025-06-02T11:51:07.959Z","dependency_job_id":null,"html_url":"https://github.com/bselleslagh/PyPaperFlow","commit_stats":null,"previous_names":["bselleslagh/pypaperflow"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bselleslagh/PyPaperFlow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bselleslagh%2FPyPaperFlow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bselleslagh%2FPyPaperFlow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bselleslagh%2FPyPaperFlow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bselleslagh%2FPyPaperFlow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bselleslagh","download_url":"https://codeload.github.com/bselleslagh/PyPaperFlow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bselleslagh%2FPyPaperFlow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32485297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fastapi","html2pdf","pdf-generation","python"],"created_at":"2025-04-08T05:51:54.977Z","updated_at":"2026-05-01T04:31:29.278Z","avatar_url":"https://github.com/bselleslagh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyPaperFlow Service\n\nA FastAPI-based service that converts URLs, HTML and Word content to PDF documents.\n\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n![GitHub License](https://img.shields.io/github/license/bselleslagh/PyPaperFlow)\n![GitHub Release](https://img.shields.io/github/v/release/bselleslagh/PyPaperFlow)\n![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/BenSelleslagh)\n\n## Features\n\n- Convert HTML content to PDF\n- Convert URLs to PDF\n- Convert Word documents to PDF\n- A4 format with customizable margins\n- Background graphics and colors support\n- Asynchronous processing\n- Base64 encoded output\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/bselleslagh/PyPaperFlow.git\ncd PyPaperFlow\n```\n\n2. Install dependencies using UV:\n```bash\nuv venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\nuv pip install -e .\n```\n\n3. Install Playwright browsers:\n```bash\nplaywright install\n```\n\n4. Set up pre-commit hooks:\n```bash\n# Install the pre-commit hooks\nuv run pre-commit install\n\n# Run pre-commit on all files (optional)\nuv run pre-commit run --all-files\n```\n\n## Docker Installation\n\n```bash\ndocker build -t pypaperflow .\ndocker run -p 8000:8000 pypaperflow\n```\n\n## Usage\n\nThe service exposes three endpoints:\n\n### Root Endpoint\n\n```http\nGET /\n```\n\nReturns a welcome message confirming the service is running.\n\n### Convert HTML/URL to PDF Endpoint\n\n```http\nPOST /convert-html\n```\n\nRequest body:\n```json\n{\n    \"content\": \"string\",\n    \"type\": \"html\" | \"url\"\n}\n```\n\n- `content`: HTML string or URL to convert\n- `type`: Either \"html\" for HTML content or \"url\" for web pages (default: \"html\")\n\nResponse:\n```json\n{\n    \"pdf\": \"base64_encoded_string\",\n    \"message\": \"PDF generated successfully\"\n}\n```\n\n### Convert Word to PDF Endpoint\n\n```http\nPOST /convert-word\n```\n\nRequest body:\n```json\n{\n    \"content\": \"string\"  // base64 encoded Word document\n}\n```\n\nResponse:\n```json\n{\n    \"pdf\": \"base64_encoded_string\",\n    \"message\": \"Word document converted to PDF successfully\"\n}\n```\n\n## Example\n\n```python\nimport requests\nimport base64\n\n# Convert HTML to PDF\nurl = \"http://localhost:8000/convert-html\"\npayload = {\n    \"content\": \"\u003ch1\u003eHello World\u003c/h1\u003e\",\n    \"type\": \"html\"\n}\nresponse = requests.post(url, json=payload)\npdf_data = response.json()[\"pdf\"]\n\n# Convert Word to PDF\nwith open(\"document.docx\", \"rb\") as word_file:\n    word_base64 = base64.b64encode(word_file.read()).decode(\"utf-8\")\n\npayload = {\n    \"content\": word_base64\n}\nresponse = requests.post(\"http://localhost:8000/convert-word\", json=payload)\npdf_data = response.json()[\"pdf\"]\n```\n\n## Requirements\n\n- Python ≥ 3.13\n- FastAPI\n- Playwright\n- See `pyproject.toml` for full dependencies\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Author\n\nBen Selleslagh ([@BenSelleslagh](https://twitter.com/BenSelleslagh))\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbselleslagh%2Fpypaperflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbselleslagh%2Fpypaperflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbselleslagh%2Fpypaperflow/lists"}