{"id":35103419,"url":"https://github.com/ian-cowley/tinypdf-csharp","last_synced_at":"2026-04-01T19:18:34.477Z","repository":{"id":330195953,"uuid":"1121816384","full_name":"ian-cowley/tinypdf-csharp","owner":"ian-cowley","description":"A minimal PDF creation library for .NET 10, ported from the original tinypdf by Lulzx.","archived":false,"fork":false,"pushed_at":"2025-12-28T09:38:19.000Z","size":114,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T00:58:06.641Z","etag":null,"topics":["benchmarked","charts","csharp","dependency-free","dotnet","dotnet10","high-performance","lightweight","markdown","markdown-to-pdf","minimal","nuget","pdf","pdf-creator","pdf-generation","pdf-generator","pdf-library","port","tinypdf","vector-graphics"],"latest_commit_sha":null,"homepage":"","language":"C#","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/ian-cowley.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","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":"2025-12-23T15:49:28.000Z","updated_at":"2026-02-22T13:51:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ian-cowley/tinypdf-csharp","commit_stats":null,"previous_names":["ian-cowley/tinypdf-csharp"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ian-cowley/tinypdf-csharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-cowley%2Ftinypdf-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-cowley%2Ftinypdf-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-cowley%2Ftinypdf-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-cowley%2Ftinypdf-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ian-cowley","download_url":"https://codeload.github.com/ian-cowley/tinypdf-csharp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ian-cowley%2Ftinypdf-csharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"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":["benchmarked","charts","csharp","dependency-free","dotnet","dotnet10","high-performance","lightweight","markdown","markdown-to-pdf","minimal","nuget","pdf","pdf-creator","pdf-generation","pdf-generator","pdf-library","port","tinypdf","vector-graphics"],"created_at":"2025-12-27T17:33:04.020Z","updated_at":"2026-04-01T19:18:34.467Z","avatar_url":"https://github.com/ian-cowley.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TinyPdf C#\r\n[![NuGet version](https://img.shields.io/nuget/v/TinyPdf.svg)](https://www.nuget.org/packages/TinyPdf/)\r\nA minimal PDF creation library for .NET 10, ported from the original [tinypdf](https://github.com/Lulzx/tinypdf) by Lulzx.\r\n\r\n## Features\r\n- 1027 lines of code\r\n- Zero external dependencies\r\n- Text rendering (`Helvetica`, `Times`, `Courier`) with alignment support\r\n- Clickable links with optional underlining\r\n- Shapes (Rectangles, Lines, Circles, Wedges)\r\n- JPEG images\r\n- Optional Flate (deflate) compression for PDF streams\r\n- Markdown to PDF conversion\r\n- Multiple pages with custom sizes\r\n\r\n## Supported framework\r\nThis project targets `.NET 10`.\r\n\r\n## Installation\r\nInstall the package via the .NET CLI:\r\n\r\n```bash\r\ndotnet add package TinyPdf\r\n```\r\n\r\nAlternatively, you can add the `TinyPdf.csproj` to your solution and reference it from your project:\r\n\r\n```bash\r\ndotnet add reference ../src/TinyPdf/TinyPdf.csproj\r\n```\r\n\r\n## Usage\r\n\r\n### Simple PDF\r\n```csharp\r\nusing TinyPdf;\r\n\r\nvar builder = TinyPdfCreate.Create();\r\n// disable compression if you need uncompressed streams\r\n// builder.Compress = false;\r\n\r\nbuilder.Page(ctx =\u003e {\r\n    ctx.Text(\"Hello World\", 50, 700, 24);\r\n    ctx.Rect(50, 650, 100, 20, \"#FF0000\");\r\n});\r\n\r\nbyte[] pdf = builder.Build();\r\nFile.WriteAllBytes(\"output.pdf\", pdf);\r\n```\r\n\r\n### Markdown to PDF\r\n```csharp\r\nusing TinyPdf;\r\n\r\n// disable compression via options\r\nvar options = new TinyPdfCreate.MarkdownOptions(Compress: false);\r\nstring md = \"# Header\\n\\nThis is a paragraph.\\n\\n- List item\";\r\nbyte[] pdf = TinyPdfCreate.Markdown(md, options);\r\nFile.WriteAllBytes(\"markdown.pdf\", pdf);\r\n```\r\n\r\n### Advanced Page Options\r\n```csharp\r\nbuilder.Page(842, 595, ctx =\u003e { // A4 Landscape\r\n    ctx.Line(0, 0, 842, 595, \"#0000FF\", 2);\r\n});\r\n```\r\n\r\n### Charts and Shapes\r\n```csharp\r\nbuilder.Page(ctx =\u003e {\r\n    // ctx.Circle(cx, cy, radius, fill, stroke, lineWidth)\r\n    ctx.Circle(100, 700, 50, \"#3498db\");\r\n\r\n    // ctx.Wedge(cx, cy, radius, startAngle, endAngle, fill, stroke, lineWidth)\r\n    ctx.Wedge(300, 700, 50, 0, 90, \"#e74c3c\", \"#000000\", 2);\r\n});\r\n```\r\n\r\n### Clickable Links\r\n```csharp\r\nbuilder.Page(ctx =\u003e {\r\n    ctx.Text(\"Visit our website\", 50, 700, 12);\r\n    // Link(url, x, y, width, height, options)\r\n    ctx.Link(\"https://github.com/ian-cowley/tinypdf-csharp\", 50, 700, 100, 12, new TinyPdfCreate.LinkOptions(Underline: \"#2563eb\"));\r\n});\r\n```\r\n\r\n## Running tests\r\nFrom the repository root run:\r\n\r\n```bash\r\ndotnet test\r\n```\r\n\r\n## Benchmarks\r\nTo run the high-concurrency performance tests (1000 iterations per example):\r\n```bash\r\ndotnet run --project benchmarks/PerformanceTests/PerformanceTests.csproj\r\n```\r\n\r\nAlternatively, to run the BenchmarkDotNet suite:\r\n```bash\r\ndotnet run -p benchmarks/TinyPdf.Benchmarks\r\n```\r\n\r\n## Performance Results\r\nThe following results were obtained by generating 1000 PDFs for each example in parallel:\r\n\r\n| Example | Iterations | Total Time (ms) | Avg Time (ms) | Complexity |\r\n|---------|------------|-----------------|---------------|------------|\r\n| Invoice | 1000 | 270.48 | 0.2705 | Methods: ~320 |\r\n| Letter | 1000 | 146.33 | 0.1463 | Markdown: ~60 lines |\r\n| PieChart | 1000 | 40.10 | 0.0401 | Methods: ~20 |\r\n| Receipt | 1000 | 35.31 | 0.0353 | Methods: ~18 |\r\n| Report | 1000 | 44.86 | 0.0449 | Methods: ~56 |\r\n| Resume | 1000 | 99.03 | 0.0990 | Markdown: ~100 lines |\r\n\r\n## Publishing (Maintainers)\r\nTo release a new version to NuGet and GitHub:\r\n1. Open PowerShell in the repository root.\r\n2. Run: `./release.ps1`\r\n3. Follow the prompts for the commit message.\r\n\r\nThe script will automatically increment the patch version, commit, push, and create a GitHub tag, which triggers the CI/CD workflow.\r\n\r\n## Notes\r\nThis C# port preserves the core logic of the original TypeScript library (font width tables and PDF object serialization) so generated PDFs are compatible in structure. The library is intentionally small and dependency-free to keep it easy to embed in small projects.\r\n\r\nBy default output streams are compressed (FlateDecode) — set `builder.Compress = false` or pass `new TinyPdfCreate.MarkdownOptions(Compress: false)` to `TinyPdfCreate.Markdown` to disable compression.\r\n\r\nSecurity: do not commit secrets or sensitive configuration to this repository. Use `dotnet user-secrets` or environment variables for local development.\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fian-cowley%2Ftinypdf-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fian-cowley%2Ftinypdf-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fian-cowley%2Ftinypdf-csharp/lists"}