{"id":28125142,"url":"https://github.com/xing/pdf_cover","last_synced_at":"2025-05-14T09:20:38.701Z","repository":{"id":53450241,"uuid":"52450574","full_name":"xing/pdf_cover","owner":"xing","description":"Generate PDF cover images with Paperclip and Carrierwave","archived":false,"fork":false,"pushed_at":"2021-03-30T12:33:18.000Z","size":36555,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-04-24T15:10:11.922Z","etag":null,"topics":[],"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/xing.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-24T14:59:42.000Z","updated_at":"2021-08-18T21:40:11.000Z","dependencies_parsed_at":"2022-09-07T00:41:06.450Z","dependency_job_id":null,"html_url":"https://github.com/xing/pdf_cover","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fpdf_cover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fpdf_cover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fpdf_cover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xing%2Fpdf_cover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xing","download_url":"https://codeload.github.com/xing/pdf_cover/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110399,"owners_count":22016393,"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":"2025-05-14T09:20:21.022Z","updated_at":"2025-05-14T09:20:38.693Z","avatar_url":"https://github.com/xing.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PdfCover [![Build Status](https://travis-ci.org/xing/pdf_cover.svg?branch=master)](https://travis-ci.org/xing/pdf_cover) [![Code Climate](https://codeclimate.com/github/xing/pdf_cover/badges/gpa.svg)](https://codeclimate.com/github/xing/pdf_cover) [![Coverage Status](https://coveralls.io/repos/github/xing/pdf_cover/badge.svg?branch=master)](https://coveralls.io/github/xing/pdf_cover?branch=master)\n\nWith this gem you can easily have attachments for PDF files that have associated\nimages generated for their first page.\n\nSupport is provided both for [Paperclip](https://github.com/thoughtbot/paperclip)\nand [CarrierWave](https://github.com/carrierwaveuploader/carrierwave).\n\nIn both cases the JPEG quality and resolution are optional and will be set to 85%\nand 300dpi respectively when not provided.\n\n## Paperclip Support\n\nTo add a PDF cover style to your attachments you can do something like this:\n\n```Ruby\nclass WithPaperclip \u003c ActiveRecord::Base\n  include PdfCover\n\n  pdf_cover_attachment :pdf, styles: { pdf_cover: ['', :jpeg]},\n    convert_options: { all: '-quality 95 -density 300' },\n\n  validates_attachment_content_type :pdf, content_type: %w(application/pdf)\nend\n```\n\nThis will define an attachment called `pdf` which has a `pdf_cover` style attached\nto it that is a JPEG of the first page in the PDF. You can pass any option that you\nwould normally pass to `has_attached_file` in the options hash and it will be\npassed through to the underlying `has_attached_file` call.\n\n## CarrierWave\n\nWhen using CarrierWave you can implement this gem's functionality\nyou can do something like this:\n\n```Ruby\nclass WithCarrierwaveUploader \u003c CarrierWave::Uploader::Base\n  include PdfCover\n\n  storage :file\n\n  version :image do\n    pdf_cover_attachment quality: 95, resolution: 300\n  end\nend\n```\n\nIn this case, when we mix the `PdfCover` module in, it adds the `pdf_cover_attachment`\nmethod to our uploader. We only need to call it inside one of our versions to get the\npdf to image feature.\n\n# Developing this gem\n\nAfter cloning this gem locally just run the `bin/setup` script to set everything\nup. This will:\n\n- Run `bundle` to install the development dependencies.\n- Initialize the database used by the `spec/dummy` rails application that\nwe use to test the ActiveRecord+(Paperclip|CarrierWave) integration.\n- Generate JPEG files used in the specs.\n\n## Running the specs\n\nOnce you have setup the gem locally you can just run `rake` from the root folder\nof the gem to run the specs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxing%2Fpdf_cover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxing%2Fpdf_cover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxing%2Fpdf_cover/lists"}