{"id":14956030,"url":"https://github.com/jpalumickas/wkhtmltopdf_runner","last_synced_at":"2025-10-24T09:30:32.892Z","repository":{"id":52303813,"uuid":"171374672","full_name":"jpalumickas/wkhtmltopdf_runner","owner":"jpalumickas","description":"Ruby wrapper for wkhtmltopdf to render PDF from HTML","archived":false,"fork":false,"pushed_at":"2025-02-05T23:27:36.000Z","size":45,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T00:22:46.524Z","etag":null,"topics":["hacktoberfest","htmltopdf","pdf","pdf-generation","rails","ruby","ruby-on-rails","wkhtmltopdf"],"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/jpalumickas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-02-19T00:03:23.000Z","updated_at":"2025-02-05T23:27:38.000Z","dependencies_parsed_at":"2024-10-10T05:25:22.737Z","dependency_job_id":null,"html_url":"https://github.com/jpalumickas/wkhtmltopdf_runner","commit_stats":{"total_commits":52,"total_committers":2,"mean_commits":26.0,"dds":"0.019230769230769273","last_synced_commit":"d6d0fcca893907a5d5bb8e97800a093269b9915f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Fwkhtmltopdf_runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Fwkhtmltopdf_runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Fwkhtmltopdf_runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpalumickas%2Fwkhtmltopdf_runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpalumickas","download_url":"https://codeload.github.com/jpalumickas/wkhtmltopdf_runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237944057,"owners_count":19391588,"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":["hacktoberfest","htmltopdf","pdf","pdf-generation","rails","ruby","ruby-on-rails","wkhtmltopdf"],"created_at":"2024-09-24T13:12:12.486Z","updated_at":"2025-10-24T09:30:27.604Z","avatar_url":"https://github.com/jpalumickas.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wkhtmltopdf Runner\n\nThis gem is a wrapper for a popular `wkhtmltopdf` library to generate PDF files from HTML.\n\n## Installation\n\nAdd this line to your application's Gemfile and then run `bundle install`:\n\n```ruby\ngem 'wkhtmltopdf_runner'\n```\n\nYou also need to have installed `wkhtmltopdf`. Easy way to do that is to add binary files to your Gemfile.\n\n```ruby\ngem 'wkhtmltopdf-binary' # or 'wkhtmltopdf-binary-edge'\n```\n\nIf you have custom path for `wkhtmltopdf` please see [Configuration](#configuration)\n\n## Usage\n\n### Write to File\n\nUse in a block which has File argument that will be returned after PDF generation as a TempFile.\n\n#### ActiveStorage in Rails\n\nThese examples show how to attach a file to a user with [ActiveStorage::Attach](https://api.rubyonrails.org/classes/ActiveStorage/Attached/One.html).\nYou can render PDF from HTML string:\n\n```rb\nstring = '\u003ch1\u003eHello user\u003c/h1\u003e'\n\nWkhtmltopdfRunner.pdf_from_string(string) do |file|\n  user.document.attach(io: file, file_name: 'document.pdf')\nend\n```\n\nYou can render PDF from HTML file:\n\n```rb\n  File.open('index.html') do |html_file|\n    WkhtmltopdfRunner.pdf_from_file(html_file) do |file|\n      user.document.attach(io: file, file_name: 'document.pdf')\n    end\n  end\n```\n\nYou can render PDF from URL:\n\n```rb\n  WkhtmltopdfRunner.pdf_from_url('https://github.com') do |file|\n    user.document.attach(io: file, file_name: 'document.pdf')\n  end\n```\n\n### Sinatra\n\nYou can send the resultant file as a download.\n\n```rb\n  WkhtmltopdfRunner.pdf_from_url('https://github.com') do |file|\n    send_file file, { filename: 'document.pdf' }\n  end\n```\n\n### Save to file\n\nYou can also just save it to a file.\n\n```rb\nWkhtmltopdfRunner.pdf_from_url('https://github.com') do |file|\n  doc = File.open('document.pdf', 'w')\n  doc.write(file.read)\n  doc.close\nend\n```\n\n### Render to String\n\nIf you will not provide block, PDF string will be returned.\n\n\u003e **Warning:** Be careful when using this method because all PDF content will\n\u003e be stored in Memory. Better to use block which will return file. See examples\n\u003e above.\n\n```rb\npdf_string = WkhtmltopdfRunner.pdf_from_url('https://github.com')\n```\n\n## Configuration\n\nIf you're using Rails, create file in `config/initializers/wkhtmltopdf_runner.rb`\n\n```rb\nWkhtmltopdfRunner.configure do |config|\n  config.debug = true # Default: false\n  config.logger = Logger.new('runner.log') # Default: STDOUT or Rails.logger in Rails\n  config.binary_path = '/path/to/wkhtmltopdf' # Default: will search automatically in PATH or Gemfile\nend\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/jpalumickas/wkhtmltopdf_runner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## Code of Conduct\n\nEveryone interacting in the WkhtmltopdfRunner project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jpalumickas/wkhtmltopdf_runner/blob/master/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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpalumickas%2Fwkhtmltopdf_runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpalumickas%2Fwkhtmltopdf_runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpalumickas%2Fwkhtmltopdf_runner/lists"}