{"id":23284215,"url":"https://github.com/agilecreativity/html2pdf","last_synced_at":"2025-10-17T08:22:37.132Z","repository":{"id":16346280,"uuid":"19096194","full_name":"agilecreativity/html2pdf","owner":"agilecreativity","description":"Batch convert htmls to pdfs","archived":false,"fork":false,"pushed_at":"2018-03-15T03:18:57.000Z","size":117,"stargazers_count":3,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T16:06:52.777Z","etag":null,"topics":["conversion","html2pdf","ruby","utility-library","wkhtmltopdf"],"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/agilecreativity.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}},"created_at":"2014-04-24T04:54:28.000Z","updated_at":"2019-07-30T09:36:13.000Z","dependencies_parsed_at":"2022-09-21T05:30:57.101Z","dependency_job_id":null,"html_url":"https://github.com/agilecreativity/html2pdf","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/agilecreativity/html2pdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fhtml2pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fhtml2pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fhtml2pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fhtml2pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agilecreativity","download_url":"https://codeload.github.com/agilecreativity/html2pdf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilecreativity%2Fhtml2pdf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265314415,"owners_count":23745263,"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":["conversion","html2pdf","ruby","utility-library","wkhtmltopdf"],"created_at":"2024-12-20T01:38:43.755Z","updated_at":"2025-10-17T08:22:32.098Z","avatar_url":"https://github.com/agilecreativity.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## html2pdf\n\n[![Gem Version](https://badge.fury.io/rb/html2pdf.svg)][gem]\n[![Dependency Status](https://gemnasium.com/agilecreativity/html2pdf.png)][gemnasium]\n[![Code Climate](https://codeclimate.com/github/agilecreativity/html2pdf.png)][codeclimate]\n\n[gemnasium]: https://gemnasium.com/agilecreativity/html2pdf\n[codeclimate]: https://codeclimate.com/github/agilecreativity/html2pdf\n[gem]: http://badge.fury.io/rb/html2pdf\n\nConvert multiple html or xhtml files to pdfs using the power of [wkhtmltopdf][].\n\nNote: starting from version `0.1.0` this gem will be release based on [Semantic Versioning][] convention.\n\n### Installation\n\n### Mandatory Requirement\n\n- [wkhtmltopdf][] - please see [wkhtmltopdf installation][] for detail\n\n### Usage\n\n```sh\ngem install html2pdf\n```\n\nFor list of usage type\n\n```sh\nhtml2pdf\n```\n\nWhich should give the following output\n\n```\nUsage:\nhtml2pdf\n\nOptions:\n  -b, [--base-dir=BASE_DIR]                # Base directory\n                                           # Default: . (current directory)\n  -r, [--recursive], [--no-recursive]      # Search for files recursively\n                                           # Default: true\n  -v, [--version], [--no-version]          # Display version information\n```\n\n### Example Usage\n\n- Convert all `xhtml` and `html` from `test/fixtures/samples` directory\n  recursively\n```\nhtml2pdf -b test/fixtures/samples -r\n```\nBefore the run\n```\ntest/fixtures/samples/\n├── demo1_xxx.rb.xhtml\n├── demo2_xxx.rb.xhtml\n└── sub_dir\n    ├── demo3_xxx.rb.xhtml\n    └── demo4_xxx.rb.xhtml\n```\nAfter the above command is executed:\n\nYou should get the output `html2pdf_samples.tar.gz`\nwhich contain the pdf version of the input files above.\ne.g.\n\n```\n├── demo1_xxx.rb.xhtml.pdf\n├── demo2_xxx.rb.xhtml.pdf\n└── sub_dir\n    ├── demo3_xxx.rb.xhtml.pdf\n    └── demo4_xxx.rb.xhtml.pdf\n```\n\n### Usage Tips\n\nThis is my personal use case\n\n- Use [vim_printer][] which export any source code to list of (x)html files in\na single tar.gzipped file.\n\n- Use the output from [vim_printer][] as input to this program so that you get\nthe pdf version of it.\n\n- Then combine the generated pdf files using [pdfs2pdf][] gem to produce one pdf file\n\n### Customization\n\nIf you like to adjust the output for pdf you can override the default settings by\nset your own configuration in the file `lib/html2pdf/config/html2pdf.rb`\n\nFor more customization please see the [wkhtmltopdf manual][] page for detail.\n\n```ruby\nmodule Html2Pdf\n  class \u003c\u003c self\n    # rubocop:disable MethodLength\n    def update_config\n      Html2Pdf.configure do |config|\n        # Note: or add your own path here if `wkhtmltopdf` is not in the $PATH environment\n        config.options[:wkhtmltopdf]   = (defined?(Bundler::GemfileError) ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp\n        config.options[:page_settings] = [\n          \"--margin-top 8\",\n          \"--margin-bottom 8\",\n          \"--margin-left 8\",\n          \"--margin-right 8\",\n          '--header-center \"[webpage] :: [page]/[topage]\"',\n          \"--header-spacing 1\",\n          \"--header-font-size 8\",\n          \"--header-line\",\n          \"--footer-spacing 1\",\n          \"--footer-font-size 8\",\n          \"--footer-line\"\n        ]\n      end\n    end\n    # rubocop:enable All\n  end\nend\n```\n\n### Contributing\n\n1. Fork it ( http://github.com/agilecreativity/html2pdf/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n[vim_printer]: https://github.com/agilecreativity/vim_printer\n[pdfs2pdf]: https://github.com/agilecreativity/pdfs2pdf\n[wkhtmltopdf]: http://wkhtmltopdf.org/\n[wkhtmltopdf installation]: https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF\n[wkhtmltopdf manual]: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt\n[Semantic Versioning]: http://semver.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilecreativity%2Fhtml2pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagilecreativity%2Fhtml2pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilecreativity%2Fhtml2pdf/lists"}