{"id":48915562,"url":"https://github.com/electionbuddy/weasy_rb","last_synced_at":"2026-04-17T02:32:07.295Z","repository":{"id":307563269,"uuid":"1029985485","full_name":"electionbuddy/weasy_rb","owner":"electionbuddy","description":"A simple Ruby wrapper for WeasyPrint HTML to PDF converter","archived":false,"fork":false,"pushed_at":"2025-07-31T23:46:34.000Z","size":18,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-06T11:27:41.953Z","etag":null,"topics":["html-to-pdf","python","ruby","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/electionbuddy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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-07-31T22:45:52.000Z","updated_at":"2025-11-30T15:41:54.000Z","dependencies_parsed_at":"2025-07-31T23:59:44.224Z","dependency_job_id":"e7923730-5321-4c34-9336-6db1a9cca792","html_url":"https://github.com/electionbuddy/weasy_rb","commit_stats":null,"previous_names":["electionbuddy/weasy_rb"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/electionbuddy/weasy_rb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electionbuddy%2Fweasy_rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electionbuddy%2Fweasy_rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electionbuddy%2Fweasy_rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electionbuddy%2Fweasy_rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electionbuddy","download_url":"https://codeload.github.com/electionbuddy/weasy_rb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electionbuddy%2Fweasy_rb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31912373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"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":["html-to-pdf","python","ruby","wrapper"],"created_at":"2026-04-17T02:32:06.543Z","updated_at":"2026-04-17T02:32:07.241Z","avatar_url":"https://github.com/electionbuddy.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WeasyRb\n\nA dead simple Ruby wrapper for [WeasyPrint](https://github.com/Kozea/WeasyPrint), the Python library that converts HTML documents to PDF files. WeasyRb provides a clean and Ruby-idiomatic interface to WeasyPrint while handling the complexities of process execution and error handling.\n\n## Features\n\n- **Simple API**: Convert HTML to PDF with a single method call\n- **Clean Architecture**: Follows SOLID principles and Clean Code practices\n- **Error Handling**: Comprehensive error handling with meaningful error messages\n- **Flexible Options**: Support for WeasyPrint's various configuration options\n- **Process Safety**: Uses Open3 for safe subprocess execution\n\n## Prerequisites\n\nWeasyPrint must be installed on your system. You can install it via pip:\n\n```bash\npip install weasyprint\n```\n\nFor more installation options, see the [WeasyPrint documentation](https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"weasy_rb\"\n```\n\nAnd then execute:\n\n```bash\nbundle install\n```\n\nOr install it yourself as:\n\n```bash\ngem install weasy_rb\n```\n\n## Usage\n\n### Basic Usage\n\n```ruby\nrequire \"weasy_rb\"\n\nhtml_content = \"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eHello, PDF!\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e\"\noutput_path = \"/tmp/output.pdf\"\n\n# Convert HTML to PDF\nWeasyRb.html_to_pdf(html_content, output_path)\n```\n\n### With Options\n\n```ruby\nrequire \"weasy_rb\"\n\nhtml_content = File.read(\"document.html\")\noutput_path = \"output.pdf\"\n\noptions = {\n  base_url: \"file:///path/to/assets/\",\n  format: \"A4\",\n  media_type: \"print\",\n  stylesheets: [\"style.css\"],\n  encoding: \"utf-8\"\n}\n\nWeasyRb.html_to_pdf(html_content, output_path, options)\n```\n\n### Available Options\n\n- `base_url`: Base URL for resolving relative URLs in the HTML\n- `format`: Page format (A4, Letter, etc.)\n- `media_type`: CSS media type (\"print\" or \"screen\")\n- `stylesheets`: Array of stylesheet paths to include\n- `encoding`: Character encoding for the HTML content\n- `verbose`: Enable verbose output for debugging\n\n### Docker Examples\n\nTry the included examples to see WeasyRb in action:\n\n```bash\n# Run the basic example\ndocker-compose run --rm weasy_rb ruby examples/basic_example.rb\n\n# Run the decorated demo (with subtle emoji support)\ndocker-compose run --rm weasy_rb ruby examples/decorated_demo.rb\n\n# Interactive exploration\ndocker-compose run --rm console\n```\n\n## Error Handling\n\nWeasyRb provides specific error classes for different failure scenarios:\n\n```ruby\nbegin\n  WeasyRb.html_to_pdf(html_content, output_path)\nrescue WeasyRb::CommandError =\u003e e\n  # WeasyPrint is not installed or command execution failed\n  puts \"Command error: #{e.message}\"\nrescue WeasyRb::ConversionError =\u003e e\n  # PDF conversion failed\n  puts \"Conversion error: #{e.message}\"\nrescue ArgumentError =\u003e e\n  # Invalid input parameters\n  puts \"Invalid input: #{e.message}\"\nend\n```\n\n## Development\n\n### Local Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n### Docker Development (Recommended)\n\nFor the easiest development experience, use Docker which includes all dependencies:\n\n```bash\n# Build and run tests\nmake build-and-test\n\n# Interactive development shell\nmake dev\n\n# Ruby console with gem loaded\nmake console\n\n# Run tests\nmake test\n\n# Run linter\nmake lint\n```\n\nSee [DOCKER.md](DOCKER.md) for detailed Docker development instructions.\n\n### Publishing\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Rynaro/weasy_rb.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectionbuddy%2Fweasy_rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felectionbuddy%2Fweasy_rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectionbuddy%2Fweasy_rb/lists"}