{"id":15603373,"url":"https://github.com/hidakatsuya/pdf_matcher","last_synced_at":"2025-04-24T07:36:40.856Z","repository":{"id":56887692,"uuid":"361085846","full_name":"hidakatsuya/pdf_matcher","owner":"hidakatsuya","description":"A gem to compare two PDFs and output the differences using diff-pdf","archived":false,"fork":false,"pushed_at":"2023-12-30T14:23:16.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T02:06:24.779Z","etag":null,"topics":["pdf","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/pdf_matcher","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/hidakatsuya.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}},"created_at":"2021-04-24T06:14:57.000Z","updated_at":"2023-04-08T11:52:33.000Z","dependencies_parsed_at":"2023-12-30T14:44:26.334Z","dependency_job_id":null,"html_url":"https://github.com/hidakatsuya/pdf_matcher","commit_stats":{"total_commits":38,"total_committers":3,"mean_commits":"12.666666666666666","dds":0.1842105263157895,"last_synced_commit":"98ccc584d9996d1c3f707a4b76473dc425b971c5"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidakatsuya%2Fpdf_matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidakatsuya%2Fpdf_matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidakatsuya%2Fpdf_matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidakatsuya%2Fpdf_matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hidakatsuya","download_url":"https://codeload.github.com/hidakatsuya/pdf_matcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242432357,"owners_count":20127384,"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":["pdf","ruby"],"created_at":"2024-10-03T03:02:59.295Z","updated_at":"2025-03-07T17:31:29.594Z","avatar_url":"https://github.com/hidakatsuya.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PdfMatcher\n\n[![Gem Version](https://badge.fury.io/rb/pdf_matcher.svg)](https://badge.fury.io/rb/pdf_matcher)\n[![Test](https://github.com/hidakatsuya/pdf_matcher/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/hidakatsuya/pdf_matcher/actions/workflows/test.yml)\n\nA gem to compare two PDFs and output the differences using [diff-pdf](https://github.com/vslavik/diff-pdf).\n\n## Prerequisites\n\n### diff-pdf Required\n\nThis gem requires [diff-pdf](https://github.com/vslavik/diff-pdf). See [the README.md](https://github.com/vslavik/diff-pdf) for how to install it.\n\nNote that you can install it with [hidakatsuya/setup-diff-pdf](https://github.com/hidakatsuya/setup-diff-pdf) in GitHub Action.\n\n### Supported Ruby Versions\n\n3.0, 3.1, 3.2, 3.3\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'pdf_matcher'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install pdf_matcher\n\n## Usage\n\n### PdfMatcher.match?\n\nReturns true if the PDFs match, false otherwise.\n\n```ruby\nPdfMatcher.match?(pdf_a_data, pdf_b_data)\nPdfMatcher.match?('/path/to/a.pdf', '/path/to/b.pdf')\nPdfMatcher.match?(Pathname('/path/to/a.pdf'), Pathname('/path/to/b.pdf'))\n```\n\n#### `output_diff` option:\n\nIf the PDFs do not match, a difference PDF file will be generated at the path specified.\n\n```ruby\nPdfMatcher.match?(pdf_a_data, pdf_b_data, output_diff: '/path/to/diff.pdf')\n```\n\n#### `diff_pdf_opts` option:\n\nThe specified values will be set as options for the `diff-pdf` command.\n\n```ruby\nPdfMatcher.match?(pdf_a_data, pdf_b_data, diff_pdf_opts: ['--mark-differences', '--dpi=600'])\n```\n\n### PdfMatcher.match\n\nReturns the PDF match result as a `PdfMatcher::MatchResult` object.\n\n```ruby\nresult = PdfMatcher.match(\n  pdf_a, pdf_b,\n  output_diff: nil,\n  diff_pdf_opts: nil\n)\n\nresult.matched? #=\u003e boolean\n\n# Returns nil if pdf data is passed, otherwise returns path as Pathname.\nresult.pdf1_path #=\u003e Pathname or nil\nresult.pdf2_path #=\u003e Pathname or nil\n\nresult.pdf1_data #=\u003e \"%PDF-...\"\nresult.pdf2_data #=\u003e \"%PDF-...\"\n\n# Returns nil if the output_diff parameter is nil or the PDFs do not match.\nresult.diff_pdf_path #=\u003e Pathname or nil\nresult.diff_pdf_data #=\u003e \"%PDF-...\" or nil\n```\n\n### Configuring the default options for the diff-pdf command\n\n```ruby\nPdfMatcher.config.diff_pdf_opts = %w(\n  --mark-differences\n  --channel-tolerance=40\n)\n```\n\nSee `diff-pdf --help` for available options of the diff-pdf.\n\n## Use in Testing Frameworks\n\nTry [pdf_matcher-testing gem](https://github.com/hidakatsuya/pdf_matcher-testing).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hidakatsuya/pdf_matcher. 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/hidakatsuya/pdf_matcher/blob/master/CODE_OF_CONDUCT.md).\n\n## Testing\n\n```\n$ bundle exec rake test\n```\n\nHowever, this gem requires diff-pdf. You can install it locally or use a docker container.\n\n```\n$ docker pull ghcr.io/hidakatsuya/ruby-with-diff-pdf:3.2\n$ docker run -v $PWD:/src:cached -it ghcr.io/hidakatsuya/ruby-with-diff-pdf bash\n\n\u003e src# bundle install\n\u003e src# bundle exec rake test\n```\n\nOr, you can run tests instantlly like this:\n\n```\n$ docker run --rm -v $PWD:/src -it ghcr.io/hidakatsuya/ruby-with-diff-pdf bash -c \"bundle install \u0026\u0026 bundle exec rake test\"\n```\n\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 PdfMatcher project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hidakatsuya/pdf_matcher/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhidakatsuya%2Fpdf_matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhidakatsuya%2Fpdf_matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhidakatsuya%2Fpdf_matcher/lists"}