PdfToPng
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/pdf_to_png
. To experiment with that code, run bin/console
for an interactive prompt.
A processor based on https://github.com/FinalCAD/file_model FileModel::Processor::Base
The goal is to change PDF files to PNG files
Installation
Add this line to your application's Gemfile:
gem 'pdf_to_png'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pdf_to_png
Usage
You need to add file_model
gem https://rubygems.org/gems/file_model
require 'file_model'
Define your model based on FileModel::Model::File
to override behavior
class PdfFile
include FileModel::Model::File
def skip?
extension.to_s != '.pdf'
end
end
Use the FileModel::Import::Dir
of file_model
source_path = '../file_model/spec/fixtures/archive/input'
import = FileModel::Import::Dir.new(source_path: source_path, model: PdfFile)
Create the directory where you want your PNG files (Could be the same as input if you want to work in the same directory)
export_path = "tmp/#{Time.now.to_s(:number)}"
FileUtils.mkdir_p(export_path)
get an instance of the processor
processor = PdfToPng::Processor::Base.new({ export_path: Pathname(export_path) })
process your files
import.each do |model|
processor.process(model: model)
puts("File: #{model.source_path} Successfully treated")
end
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pdf_to_png. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the PdfToPng project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.