{"id":13879962,"url":"https://github.com/cortiz/prawn-rails","last_synced_at":"2025-05-15T04:02:35.053Z","repository":{"id":2524066,"uuid":"3500323","full_name":"cortiz/prawn-rails","owner":"cortiz","description":"Prawn Handler for Rails. Handles and registers pdf formats.","archived":false,"fork":false,"pushed_at":"2025-01-18T01:01:37.000Z","size":290,"stargazers_count":150,"open_issues_count":2,"forks_count":38,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-10T10:09:51.541Z","etag":null,"topics":["handler","html","pdf","pdf-report","prawn-rails","ruby"],"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/cortiz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2012-02-21T03:15:37.000Z","updated_at":"2025-02-04T10:34:35.000Z","dependencies_parsed_at":"2023-07-05T17:00:25.924Z","dependency_job_id":"c370fc84-2ae3-462f-8baa-0b265cbe5f7a","html_url":"https://github.com/cortiz/prawn-rails","commit_stats":{"total_commits":94,"total_committers":20,"mean_commits":4.7,"dds":0.7446808510638299,"last_synced_commit":"08d0ea26d4711a6e56c94a148fc217ca395ae3a5"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortiz%2Fprawn-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortiz%2Fprawn-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortiz%2Fprawn-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cortiz%2Fprawn-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cortiz","download_url":"https://codeload.github.com/cortiz/prawn-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270640,"owners_count":22042858,"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":["handler","html","pdf","pdf-report","prawn-rails","ruby"],"created_at":"2024-08-06T08:02:40.949Z","updated_at":"2025-05-15T04:02:34.964Z","avatar_url":"https://github.com/cortiz.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Prawn-Rails\n\u003ca href=\"https://badge.fury.io/rb/prawn-rails\" target=\"_blank\"\u003e\u003cimg height=\"21\" style='border:0px;height:21px;' border='0' src=\"https://badge.fury.io/rb/prawn-rails.svg\" alt=\"Gem Version\"\u003e\u003c/a\u003e\n\u003ca href='https://github.com/cortiz/prawn-rails/actions' target='_blank'\u003e\u003cimg src=\"https://github.com/cortiz/prawn-rails/actions/workflows/test.yml/badge.svg?branch=master\" style=\"max-width:100%;\" height='21' style='border:0px;height:21px;' border='0' alt=\"CI Status\"\u003e\u003c/a\u003e\n\u003ca href='https://rubygems.org/gems/prawn-rails' target='_blank'\u003e\u003cimg height='21' style='border:0px;height:21px;' src='https://img.shields.io/gem/dt/prawn-rails?color=brightgreen\u0026label=Rubygems%20Downloads' border='0' alt='RubyGems Downloads' /\u003e\u003c/a\u003e\n\n\n# Install\n```ruby\ngem 'prawn-rails'\n```\n\nNote: `prawn` and `prawn-table` are dependencies of `prawn-rails` so there is no need to mention it in the projects Gemfile unless you want to use a specific version of either of those libraries.\n\n# Usage\nCreate a view with `pdf` as format and `prawn` as handler so filename should look like `example.pdf.prawn`.\n\nIt provides a helper called `prawn_document` which builds a PrawnRails::Document with default options. You can override any options as you please. Example:\n\n```ruby\nprawn_document do |pdf|\n  pdf.text \"Hello World\"\nend\n```\n\nNo need to call `pdf.render`, it is called by `prawn_document`.\n\nYou can customize the name of the generated PDF and the file's delivery format with the `:filename` and `:disposition` keys:\n\n```ruby\nprawn_document(filename: \"my-file.pdf\", disposition: \"attachment\") do |pdf|\n  pdf.text \"Direct download incoming!\"\nend\n```\n\nYou can also override the content disposition using the [`Content-Disposition` HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#As_a_response_header_for_the_main_body). If you've already set this, `prawn-rails` will *not* override it. Here's an example of setting the header directly:\n\n```ruby\ndef download\n  respond_to do |format|\n    format.pdf do\n      headers[\"Content-Disposition\"] = \"attachment; filename=\\\"charts-#{Time.now.to_i}.pdf\\\"\"\n    end\n  end\nend\n```\n\nYou can also override the file's name from the controller via `@filename`:\n\n```ruby\ndef show\n  @filename = \"my_report.pdf\"\nend\n```\n\nIf no options are given, the file's name will match to your browser's default and the delivery format will default to `inline`.\n\n# Default configuration\n\nAdd a `prawn-rails.rb` config to your Rails app under `config/initializers` like this:\n\n```ruby\nPrawnRails.config do |config|\n  # Prawn::Document options\n  config.page_layout = :portrait\n  config.page_size   = \"A4\"\n  config.skip_page_creation = false\n\n  # PrawnRails options\n  config.additional_fonts = {\n    \"some-custom-font\" =\u003e {\n       normal: Rails.root.join('app/assets/fonts/print/some-custom-font.ttf'),\n       italic: Rails.root.join('app/assets/fonts/print/some-custom-font-italic.ttf'),\n       bold: Rails.root.join('app/assets/fonts/print/some-custom-font-bold.ttf'),\n       bold_italic: Rails.root.join('app/assets/fonts/print/some-custom-font-bold-italic.ttf'),\n     },\n  }\n  config.default_font_name = \"some-custom-font\"\nend\n```\n\nPlease note that these are the defaults.\n\nFor a list of all available options: [http://www.rubydoc.info/gems/prawn/Prawn%2FDocument:initialize](http://www.rubydoc.info/gems/prawn/Prawn%2FDocument:initialize).\n\nFor a list of all metadata the the `:info` option supports, please see [https://github.com/prawnpdf/prawn/blob/master/manual/document_and_page_options/metadata.rb](https://github.com/prawnpdf/prawn/blob/master/manual/document_and_page_options/metadata.rb).\n\nIf `skip_page_creation` is set to true then you have to create the first page yourself. Example:\n\n```ruby\npdf.start_new_page\n# OR\npdf.start_new_page size: \"A4\", page_layout: :portrait\n```\n\n# Examples\n\n#### Hello World\n\n```ruby\n# hello.pdf.prawn\n\nprawn_document do |pdf|\n  pdf.text 'Hello World!'\nend\n```\n\n#### Using Active Record\n\n```ruby\n# myproducts.pdf.prawn\n\nprawn_document do |pdf|\n  pdf.text 'Current Products are:'\n  pdf.move_down 20\n  pdf.table @products.collect{|p| [p.name,p.price]}\nend\n```\n\n#### Using Custom options\n\n```ruby\n# landscape.pdf.prawn\n\nprawn_document(page_layout: :landscape) do |pdf|\n  pdf.text 'Landscape Page!'\nend\n```\n\n#### Without using the prawn_document helper\n\n```ruby\ndoc = PrawnRails::Document.new(page_layout: :landscape)\n\ndoc.text \"Page 1\"\ndoc.start_new_page\ndoc.text \"Page 2\"\n\npdf_str = doc.render\n```\n\n\n# Credits\n\nMaintained by Weston Ganger - @westonganger\n\nCreated by Carlos Ortiz - @cortiz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcortiz%2Fprawn-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcortiz%2Fprawn-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcortiz%2Fprawn-rails/lists"}