Project

pdf_to_png

0.0
No commit activity in last 3 years
No release in over 3 years
A simple lib to change PDF files to PNG files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 10.0
~> 3.0
 Project Readme

PdfToPng

Maintainability

Dependency Status

Build Status (Travis CI)

Coverage Status

Inline docs

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.