{"id":13877887,"url":"https://github.com/phlex-ruby/phlex-pdf","last_synced_at":"2025-06-20T22:33:29.039Z","repository":{"id":224128982,"uuid":"762513442","full_name":"phlex-ruby/phlex-pdf","owner":"phlex-ruby","description":"Phlex ergonomics for building PDFs","archived":false,"fork":false,"pushed_at":"2024-03-01T09:57:25.000Z","size":36,"stargazers_count":36,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-09T20:41:12.041Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/phlex-ruby.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2024-02-23T23:53:01.000Z","updated_at":"2025-05-30T15:08:16.000Z","dependencies_parsed_at":"2024-02-28T06:24:52.277Z","dependency_job_id":null,"html_url":"https://github.com/phlex-ruby/phlex-pdf","commit_stats":null,"previous_names":["phlex-ruby/phlex-pdf"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/phlex-ruby/phlex-pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlex-ruby%2Fphlex-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlex-ruby%2Fphlex-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlex-ruby%2Fphlex-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlex-ruby%2Fphlex-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phlex-ruby","download_url":"https://codeload.github.com/phlex-ruby/phlex-pdf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlex-ruby%2Fphlex-pdf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261029390,"owners_count":23099745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-06T08:01:34.052Z","updated_at":"2025-06-20T22:33:28.958Z","avatar_url":"https://github.com/phlex-ruby.png","language":"Ruby","readme":"# Phlex::PDF\n\nPhlex PDF lets you compose PDF files with components in pure Ruby. It's a thin layer that sits on the shoulder of giants, [Prawn](https://github.com/prawnpdf/prawn), that encourages a component-first approach to building PDF documents.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add phlex-pdf\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install phlex-pdf\n\n## Usage\n\n`Phlex::PDF` is a thin wrapper around `Prawn::View`, so you'll want to become familiar with [PrawnPDF](http://prawnpdf.org/), particularly the [PrawnPDF Manual](https://prawnpdf.org/manual.pdf).\n\n```ruby\nrequire \"phlex/pdf\"\n\n# Base component. You'll put methods here that are shared across all components.\nclass PDFComponent \u003c Phlex::PDF\nend\n\n# Page has a `before_template` method that created a new page. Without a page\n# nothing will render and an error would occur.\nclass PDFPage \u003c PDFComponent\n  # Creates a new page\n  def before_template = create_new_page\n\n  def after_template\n    text \"Page #{document.page_number}\"\n  end\nend\n\n# Example component inherits from PDFComponent. Note that it does NOT create any\n# new pages.\nclass BoxComponent \u003c PDFComponent\n  def view_template\n    text \"I'm a box\"\n    yield\n  end\nend\n\n# The final PDF that's rendered should be a subclass of PDFPage. Components\n# can be rendered within a PDFPage.\nclass MyPage \u003c PDFPage\n  def initialize(title:)\n    @title = title\n  end\n\n  def view_template\n    text @title\n\n    render BoxComponent.new do\n      text \"Look! I'm a box inside a box!\"\n    end\n  end\nend\n\n# Render the PDF to a string.\nMyPage.new(title: \"This is a PDF!\").to_pdf\n```\n\n### Rails integration\n\nTo stream PDFs from Rails controllers, the `send_pdf` helper that wraps `send_data` and renders the PDF is available.\n\n```ruby\nclass MyController \u003c ApplicationController\n  include Phlex::PDF::Rails::Helpers\n\n  def show\n    send_pdf MyPage.new(title: \"This is a PDF!\")\n  end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\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/phlex-ruby/phlex-pdf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/phlex-ruby/phlex-pdf/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Phlex::PDF project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/phlex-ruby/phlex-pdf/blob/main/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlex-ruby%2Fphlex-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphlex-ruby%2Fphlex-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlex-ruby%2Fphlex-pdf/lists"}